Print this page
4845 rm(u)mount don't always print mount/unmount errors
@@ -15,14 +15,16 @@
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
- */
-/*
+ *
+ *
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2014 Andrew Stormont.
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
@@ -805,10 +807,12 @@
char dev_str[MAXPATHLEN];
char *mountp;
DBusError error;
boolean_t ret = B_FALSE;
+ dprintf("rmm_action_one %s %s\n", name, action_strings[action]);
+
if (strcmp(name, dev) == 0) {
(void) snprintf(dev_str, sizeof (dev_str), name);
} else {
(void) snprintf(dev_str, sizeof (dev_str), "%s %s", name, dev);
}
@@ -819,20 +823,14 @@
case EJECT:
ret = rmm_hal_eject(hal_ctx, udi, &error);
break;
case INSERT:
case REMOUNT:
- if (libhal_volume_is_mounted(v)) {
- goto done;
- }
ret = rmm_hal_mount(hal_ctx, udi,
opts, num_opts, mountpoint, &error);
break;
case UNMOUNT:
- if (!libhal_volume_is_mounted(v)) {
- goto done;
- }
ret = rmm_hal_unmount(hal_ctx, udi, &error);
break;
case CLOSETRAY:
ret = rmm_hal_closetray(hal_ctx, udi, &error);
break;
@@ -917,10 +915,22 @@
*/
if ((action == EJECT) && !libhal_drive_requires_eject(d)) {
action = UNMOUNT;
}
+ /*
+ * Assume anything other than EJECT and CLOSETRAY is a
+ * variant of mount or unmount and requires the device
+ * to have at least one volume.
+ */
+ if (volumes == NULL && (action != EJECT && action != CLOSETRAY)) {
+ (void) fprintf(stderr,
+ gettext("cannot %s device '%s' with no volumes\n"),
+ action_strings[action], name);
+ goto out;
+ }
+
/* per drive action */
if ((action == EJECT) || (action == CLOSETRAY)) {
ret = rmm_action_one(hal_ctx, name, action, d_dev, d_udi, NULL,
opts, num_opts, NULL);
@@ -960,10 +970,11 @@
rmm_volume_aa_free(aap);
}
}
out:
+ if (volumes != NULL)
rmm_volumes_free(volumes);
libhal_drive_free(d);
return (ret);
}