Print this page
4833 Remove volrmmount
4845 rm(u)mount don't always print mount/unmount errors
4846 HAL partition names don't match real parition names
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
@@ -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;
}
+ /*
+ * We can't mount or unmount a drive that has no volumes.
+ * Either the media isn't inserted or it's not formatted
+ */
+ if (volumes == NULL && (action != EJECT && action != CLOSETRAY)) {
+ (void) fprintf(stderr, libhal_drive_requires_eject(d) ?
+ gettext("no volumes in '%s' to %s\n") :
+ gettext("no volumes on '%s' to %s\n"),
+ name, action_strings[action]);
+ 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,11 +970,13 @@
rmm_volume_aa_free(aap);
}
}
out:
+ if (volumes != NULL)
rmm_volumes_free(volumes);
+ if (d != NULL)
libhal_drive_free(d);
return (ret);
}