changeset 3168:18866604610a

6490549 Tamarack fails when a sparc system is bfu'd with nightly archives built with gcc 6495813 rmmount should allow foldcase and nofoldcase for pcfs 6495819 eject/rmmount -l output not quite correct
author artem
date Fri, 24 Nov 2006 10:18:28 -0800
parents e74c60596d27
children 1dea14abfe17
files usr/src/cmd/hal/fdi/policy/10osvendor/20-storage-methods.fdi usr/src/cmd/hal/hald-runner/main.c usr/src/cmd/hal/hald-runner/runner.c usr/src/cmd/rmmount/rmmount.c usr/src/cmd/rmvolmgr/rmm_common.c usr/src/cmd/rmvolmgr/rmm_common.h
diffstat 6 files changed, 111 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/hal/fdi/policy/10osvendor/20-storage-methods.fdi	Fri Nov 24 08:45:37 2006 -0800
+++ b/usr/src/cmd/hal/fdi/policy/10osvendor/20-storage-methods.fdi	Fri Nov 24 10:18:28 2006 -0800
@@ -184,6 +184,12 @@
 	<append key="volume.mount.valid_options" type="strlist">iocharset=</append>
       </match>
 
+      <!-- pcfs -->
+      <match key="volume.fstype" string="pcfs">
+	<append key="volume.mount.valid_options" type="strlist">foldcase</append>
+	<append key="volume.mount.valid_options" type="strlist">nofoldcase</append>
+      </match>
+
       <!-- allow these unmount options -->
       <append key="volume.unmount.valid_options" type="strlist">lazy</append>
 
--- a/usr/src/cmd/hal/hald-runner/main.c	Fri Nov 24 08:45:37 2006 -0800
+++ b/usr/src/cmd/hal/hald-runner/main.c	Fri Nov 24 10:18:28 2006 -0800
@@ -112,6 +112,7 @@
 	DBusMessageIter iter;
 	run_request *r;
 	GPid pid;
+	dbus_int64_t pid64;
 
 	r = new_run_request();
 	g_assert(dbus_message_iter_init(msg, &iter));
@@ -120,9 +121,10 @@
 		goto malformed;
 
 	if (run_request_run(r, con, NULL, &pid)) {
+		pid64 = pid;
 		reply = dbus_message_new_method_return(msg);
 		dbus_message_append_args (reply, 
-					  DBUS_TYPE_INT64, &pid,
+					  DBUS_TYPE_INT64, &pid64,
 					  DBUS_TYPE_INVALID);
 					  
 	} else {
--- a/usr/src/cmd/hal/hald-runner/runner.c	Fri Nov 24 08:45:37 2006 -0800
+++ b/usr/src/cmd/hal/hald-runner/runner.c	Fri Nov 24 10:18:28 2006 -0800
@@ -175,11 +175,13 @@
 	/* emit a signal that this PID exited */
 	if(rd->con != NULL && rd->emit_pid_exited) {
 		DBusMessage *signal;
+		dbus_int64_t pid64;
 		signal = dbus_message_new_signal ("/org/freedesktop/HalRunner",
 						  "org.freedesktop.HalRunner",
 						  "StartedProcessExited");
+		pid64 = rd->pid;
 		dbus_message_append_args (signal, 
-					  DBUS_TYPE_INT64, &(rd->pid),
+					  DBUS_TYPE_INT64, &pid64,
 					  DBUS_TYPE_INVALID);
 		dbus_connection_send(rd->con, signal, NULL);
 	}
--- a/usr/src/cmd/rmmount/rmmount.c	Fri Nov 24 08:45:37 2006 -0800
+++ b/usr/src/cmd/rmmount/rmmount.c	Fri Nov 24 10:18:28 2006 -0800
@@ -82,6 +82,7 @@
 	int		num_opts = 0;
 	char		*mountpoint = NULL;
 	char		**p;
+	int		print_mask;
 	int		ret = 0;
 
 	progname = basename(argv[0]);
@@ -157,7 +158,11 @@
 		(void) printf(gettext("Default device is: %s\n"), default_name);
 	} else if (l_opt) {
 		/* -l: list volumes and exit */
-		rmm_print_volume_nicknames(hal_ctx, &error);
+		print_mask = RMM_PRINT_MOUNTABLE;
+		if (eject_opt) {
+			print_mask |= RMM_PRINT_EJECTABLE;
+		}
+		rmm_print_volume_nicknames(hal_ctx, &error, print_mask);
 	} else if (optind == argc) {
 		/* no name provided, use default */
 		if ((d = rmm_hal_volume_find_default(hal_ctx, &error,
--- a/usr/src/cmd/rmvolmgr/rmm_common.c	Fri Nov 24 08:45:37 2006 -0800
+++ b/usr/src/cmd/rmvolmgr/rmm_common.c	Fri Nov 24 10:18:28 2006 -0800
@@ -48,6 +48,8 @@
 
 #include "rmm_common.h"
 
+#define	RMM_PRINT_DEVICE_WIDTH	20
+
 extern int rmm_debug;
 
 static const char *action_strings[] = {
@@ -296,78 +298,121 @@
 	return (drive);
 }
 
+static void
+rmm_print_nicknames_one(LibHalDrive *d, LibHalVolume *v,
+    const char *device, char **drive_nicknames)
+{
+	const char	*volume_label = NULL;
+	const char	*mount_point = NULL;
+	boolean_t	comma;
+	int		i;
+
+	(void) printf("%-*s ", RMM_PRINT_DEVICE_WIDTH, device);
+	comma = B_FALSE;
+
+	if (drive_nicknames != NULL) {
+		for (i = 0; drive_nicknames[i] != NULL; i++) {
+			(void) printf("%s%s", comma ? "," : "",
+			    drive_nicknames[i]);
+			comma = B_TRUE;
+		}
+	}
+
+	if ((v != NULL) &&
+	    ((volume_label = libhal_volume_get_label(v)) != NULL) &&
+	    (strlen(volume_label) > 0)) {
+		(void) printf("%s%s", comma ? "," : "", volume_label);
+		comma = B_TRUE;
+	}
+
+	if ((v != NULL) &&
+	    ((mount_point = libhal_volume_get_mount_point(v)) != NULL) &&
+	    (strlen(mount_point) > 0)) {
+		(void) printf("%s%s", comma ? "," : "", mount_point);
+		comma = B_TRUE;
+	}
+
+	(void) printf("\n");
+}
 
 /*
  * print nicknames for each available volume
+ *
+ * print_mask:
+ *   RMM_PRINT_MOUNTABLE	print only mountable volumes
+ *   RMM_PRINT_EJECTABLE	print volume-less ejectable drives
  */
 void
-rmm_print_volume_nicknames(LibHalContext *hal_ctx, DBusError *error)
+rmm_print_volume_nicknames(LibHalContext *hal_ctx, DBusError *error,
+    int print_mask)
 {
 	char		**udis;
 	int		num_udis;
-	char		*block_device;
-	char		*drive_udi;
-	char		*volume_label;
-	char		*mount_point;
-	boolean_t	comma;
+	GSList		*volumes = NULL;
+	LibHalDrive	*d, *d_tmp;
+	LibHalVolume	*v;
+	const char	*device;
 	char		**nicknames;
-	int		i, j;
+	int		i;
+	GSList		*j;
+	int		nprinted;
 
 	dbus_error_init(error);
 
-	if ((udis = libhal_find_device_by_capability(hal_ctx, "volume",
+	if ((udis = libhal_find_device_by_capability(hal_ctx, "storage",
 	    &num_udis, error)) == NULL) {
+		rmm_dbus_error_free(error);
 		return;
 	}
 
 	for (i = 0; i < num_udis; i++) {
-		if ((block_device = libhal_device_get_property_string(hal_ctx,
-		    udis[i], "block.device", NULL)) == NULL) {
-			continue;
-		}
-		if ((drive_udi = libhal_device_get_property_string(hal_ctx,
-		    udis[i], "block.storage_device", NULL)) == NULL) {
-			libhal_free_string(block_device);
+		if ((d = libhal_drive_from_udi(hal_ctx, udis[i])) == NULL) {
 			continue;
 		}
-		(void) printf("%s\t", block_device);
-		comma = B_FALSE;
 
-		if ((nicknames = libhal_device_get_property_strlist(hal_ctx,
-		    drive_udi, "storage.solaris.nicknames", NULL)) != NULL) {
-			for (j = 0; nicknames[j] != NULL; j++) {
-				(void) printf("%s%s", comma ? "," : "",
-				    nicknames[j]);
-				comma = B_TRUE;
-			}
+		/* find volumes belonging to this drive */
+		if ((d_tmp = rmm_hal_volume_findby(hal_ctx,
+		    "block.storage_device", udis[i], &volumes)) != NULL) {
+			libhal_drive_free(d_tmp);
 		}
 
-		if (((volume_label = libhal_device_get_property_string(hal_ctx,
-		    udis[i], "volume.label", NULL)) != NULL) &&
-		    (strlen(volume_label) > 0)) {
-			(void) printf("%s%s", comma ? "," : "", volume_label);
-			comma = B_TRUE;
+		nicknames = libhal_device_get_property_strlist(hal_ctx,
+		    udis[i], "storage.solaris.nicknames", NULL);
+
+		nprinted = 0;
+		for (j = volumes; j != NULL; j = g_slist_next(j)) {
+			v = (LibHalVolume *)(j->data);
+
+			if ((device = libhal_volume_get_device_file(v)) ==
+			    NULL) {
+				continue;
+			}
+			if ((print_mask & RMM_PRINT_MOUNTABLE) &&
+			    (libhal_volume_get_fsusage(v) !=
+			    LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM)) {
+				continue;
+			}
+
+			rmm_print_nicknames_one(d, v, device, nicknames);
+			nprinted++;
 		}
 
-		if (((mount_point = libhal_device_get_property_string(hal_ctx,
-		    udis[i], "volume.mount_point", NULL)) != NULL) &&
-		    (strlen(mount_point) > 0)) {
-			(void) printf("%s%s", comma ? "," : "", mount_point);
-			comma = B_TRUE;
+		if ((nprinted == 0) &&
+		    (print_mask & RMM_PRINT_EJECTABLE) &&
+		    libhal_drive_requires_eject(d) &&
+		    ((device = libhal_drive_get_device_file(d)) != NULL)) {
+			rmm_print_nicknames_one(d, NULL, device, nicknames);
 		}
 
-		(void) printf("\n");
+		libhal_free_string_array(nicknames);
+		libhal_drive_free(d);
+		rmm_volumes_free(volumes);
+		volumes = NULL;
+	}
 
-		libhal_free_string_array(nicknames);
-		libhal_free_string(drive_udi);
-		libhal_free_string(volume_label);
-		libhal_free_string(mount_point);
-		libhal_free_string(block_device);
-	}
 	libhal_free_string_array(udis);
 }
 
-
 /*
  * find volume by nickname
  * returns the LibHalDrive object and a list of LibHalVolume objects.
--- a/usr/src/cmd/rmvolmgr/rmm_common.h	Fri Nov 24 08:45:37 2006 -0800
+++ b/usr/src/cmd/rmvolmgr/rmm_common.h	Fri Nov 24 10:18:28 2006 -0800
@@ -48,6 +48,11 @@
 	RMM_EHAL_CONNECT	/* cannot connect to HAL */
 } rmm_error_t;
 
+enum {
+	RMM_PRINT_MOUNTABLE	= 0x1,
+	RMM_PRINT_EJECTABLE	= 0x2
+};
+
 #define	HAL_BRANCH_LOCAL	"/org/freedesktop/Hal/devices/local"
 
 #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
@@ -66,7 +71,7 @@
 		const char *, GSList **);
 LibHalDrive	*rmm_hal_volume_findby_nickname(LibHalContext *, const char *,
 		GSList **);
-void		rmm_print_volume_nicknames(LibHalContext *, DBusError *);
+void		rmm_print_volume_nicknames(LibHalContext *, DBusError *, int);
 void		rmm_volumes_free(GSList *);
 
 boolean_t	rmm_hal_mount(LibHalContext *, const char *,