Print this page
2447 beadm should be more descriptive about some errors

@@ -121,25 +121,25 @@
         (void) fprintf(stderr, _("usage:\n"
             "\tbeadm subcommand cmd_options\n"
             "\n"
             "\tsubcommands:\n"
             "\n"
-            "\tbeadm activate beName\n"
-            "\tbeadm create [-d BE_desc]\n"
+            "\tbeadm activate [-v] beName\n"
+            "\tbeadm create [-a] [-d BE_desc]\n"
             "\t\t[-o property=value] ... [-p zpool] \n"
-            "\t\t[-e nonActiveBe | beName@snapshot] beName\n"
+            "\t\t[-e nonActiveBe | beName@snapshot] [-v] beName\n"
             "\tbeadm create [-d BE_desc]\n"
-            "\t\t[-o property=value] ... [-p zpool] beName@snapshot\n"
-            "\tbeadm destroy [-Ffs] beName \n"
-            "\tbeadm destroy [-F] beName@snapshot \n"
-            "\tbeadm list [[-a] | [-d] [-s]] [-H] [beName]\n"
-            "\tbeadm mount [-s ro|rw] beName [mountpoint]\n"
-            "\tbeadm unmount [-f] beName | mountpoint\n"
-            "\tbeadm umount [-f] beName | mountpoint\n"
-            "\tbeadm rename origBeName newBeName\n"
-            "\tbeadm rollback beName snapshot\n"
-            "\tbeadm rollback beName@snapshot\n"));
+            "\t\t[-o property=value] ... [-p zpool] [-v] beName@snapshot\n"
+            "\tbeadm destroy [-Ffsv] beName \n"
+            "\tbeadm destroy [-Fv] beName@snapshot \n"
+            "\tbeadm list [[-a] | [-d] [-s]] [-H] [-v] [beName]\n"
+            "\tbeadm mount [-s ro|rw] [-v] beName [mountpoint]\n"
+            "\tbeadm unmount [-fv] beName | mountpoint\n"
+            "\tbeadm umount [-fv] beName | mountpoint\n"
+            "\tbeadm rename [-v] origBeName newBeName\n"
+            "\tbeadm rollback [-v] beName snapshot\n"
+            "\tbeadm rollback [-v] beName@snapshot\n"));
 }
 
 static int
 run_be_cmd(const char *cmdname, int argc, char **argv)
 {

@@ -662,12 +662,24 @@
 static int
 be_do_activate(int argc, char **argv)
 {
         nvlist_t        *be_attrs;
         int             err = 1;
+        int             c;
         char            *obe_name;
 
+        while ((c = getopt(argc, argv, "v")) != -1) {
+                switch (c) {
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
+                default:
+                        usage();
+                        return (1);
+                }
+        }
+
         argc -= optind;
         argv += optind;
 
         if (argc != 1) {
                 usage();

@@ -726,11 +738,11 @@
         char            *nbe_desc = NULL;
         char            *propname = NULL;
         char            *propval = NULL;
         char            *strval = NULL;
 
-        while ((c = getopt(argc, argv, "ad:e:io:p:")) != -1) {
+        while ((c = getopt(argc, argv, "ad:e:io:p:v")) != -1) {
                 switch (c) {
                 case 'a':
                         activate = B_TRUE;
                         break;
                 case 'd':

@@ -764,10 +776,13 @@
 
                         break;
                 case 'p':
                         nbe_zpool = optarg;
                         break;
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
                 default:
                         usage();
                         goto out2;
                 }
         }

@@ -937,18 +952,21 @@
         int             c;
         int             destroy_flags = 0;
         char            *snap_name;
         char            *be_name;
 
-        while ((c = getopt(argc, argv, "fFs")) != -1) {
+        while ((c = getopt(argc, argv, "fFsv")) != -1) {
                 switch (c) {
                 case 'f':
                         destroy_flags |= BE_DESTROY_FLAG_FORCE_UNMOUNT;
                         break;
                 case 's':
                         destroy_flags |= BE_DESTROY_FLAG_SNAPSHOTS;
                         break;
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
                 case 'F':
                         suppress_prompt = B_TRUE;
                         break;
                 default:
                         usage();

@@ -1059,11 +1077,11 @@
         boolean_t       parsable = B_FALSE;
         int             err = 1;
         int             c = 0;
         char            *be_name = NULL;
 
-        while ((c = getopt(argc, argv, "nadsH")) != -1) {
+        while ((c = getopt(argc, argv, "adsvH")) != -1) {
                 switch (c) {
                 case 'a':
                         all = B_TRUE;
                         break;
                 case 'd':

@@ -1070,10 +1088,13 @@
                         dsets = B_TRUE;
                         break;
                 case 's':
                         snaps = B_TRUE;
                         break;
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
                 case 'H':
                         parsable = B_TRUE;
                         break;
                 default:
                         usage();

@@ -1143,11 +1164,11 @@
         int             mount_flags = 0;
         char            *obe_name;
         char            *mountpoint;
         char            *tmp_mp = NULL;
 
-        while ((c = getopt(argc, argv, "s:")) != -1) {
+        while ((c = getopt(argc, argv, "s:v")) != -1) {
                 switch (c) {
                 case 's':
                         shared_fs = B_TRUE;
 
                         mount_flags |= BE_MOUNT_FLAG_SHARED_FS;

@@ -1160,10 +1181,13 @@
                                 usage();
                                 return (1);
                         }
 
                         break;
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
                 default:
                         usage();
                         return (1);
                 }
         }

@@ -1221,11 +1245,10 @@
         switch (err) {
         case BE_SUCCESS:
                 (void) printf(_("Mounted successfully on: '%s'\n"), mountpoint);
                 break;
         case BE_ERR_BE_NOENT:
-                err = 1;
                 (void) fprintf(stderr, _("%s does not exist or appear "
                     "to be a valid BE.\nPlease check that the name of "
                     "the BE provided is correct.\n"), obe_name);
                 break;
         case BE_ERR_MOUNTED:

@@ -1233,17 +1256,15 @@
                     "Please unmount the BE before mounting it again.\n"),
                     obe_name);
                 break;
         case BE_ERR_PERM:
         case BE_ERR_ACCESS:
-                err = 1;
                 (void) fprintf(stderr, _("Unable to mount %s.\n"), obe_name);
                 (void) fprintf(stderr, _("You have insufficient privileges to "
                     "execute this command.\n"));
                 break;
         default:
-                err = 1;
                 (void) fprintf(stderr, _("Unable to mount %s.\n"), obe_name);
                 (void) fprintf(stderr, "%s\n", be_err_to_str(err));
         }
 
 out:

@@ -1260,15 +1281,18 @@
         char            *obe_name;
         int             err = 1;
         int             c;
         int             unmount_flags = 0;
 
-        while ((c = getopt(argc, argv, "f")) != -1) {
+        while ((c = getopt(argc, argv, "fv")) != -1) {
                 switch (c) {
                 case 'f':
                         unmount_flags |= BE_UNMOUNT_FLAG_FORCE;
                         break;
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
                 default:
                         usage();
                         return (1);
                 }
         }

@@ -1335,11 +1359,23 @@
 {
         nvlist_t        *be_attrs;
         char            *obe_name;
         char            *nbe_name;
         int err = 1;
+        int c;
 
+        while ((c = getopt(argc, argv, "v")) != -1) {
+                switch (c) {
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
+                default:
+                        usage();
+                        return (1);
+                }
+        }
+
         argc -= optind;
         argv += optind;
 
         if (argc != 2) {
                 usage();

@@ -1392,11 +1428,23 @@
 {
         nvlist_t        *be_attrs;
         char            *obe_name;
         char            *snap_name;
         int             err = 1;
+        int             c;
 
+        while ((c = getopt(argc, argv, "v")) != -1) {
+                switch (c) {
+                case 'v':
+                        libbe_print_errors(B_TRUE);
+                        break;
+                default:
+                        usage();
+                        return (1);
+                }
+        }
+
         argc -= optind;
         argv += optind;
 
         if (argc < 1 || argc > 2) {
                 usage();