Print this page
5819 want dumpadm(1m) option to print estimated dump size

@@ -18,10 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  */
 
 #include <sys/stat.h>
 #include <locale.h>
 #include <unistd.h>

@@ -32,14 +33,14 @@
 #include "dconf.h"
 #include "minfree.h"
 #include "utils.h"
 
 static const char USAGE[] = "\
-Usage: %s [-nuy] [-c kernel | curproc | all ] [-d dump-device | swap ]\n\
+Usage: %s [-enuy] [-c kernel | curproc | all ] [-d dump-device | swap ]\n\
         [-m min {k|m|%%} ] [-s savecore-dir] [-r root-dir] [-z on|off]\n";
 
-static const char OPTS[] = "inuyc:d:m:s:r:z:";
+static const char OPTS[] = "einuyc:d:m:s:r:z:";
 
 static const char PATH_DEVICE[] = "/dev/dump";
 static const char PATH_CONFIG[] = "/etc/dumpadm.conf";
 
 int

@@ -49,10 +50,11 @@
 
         u_longlong_t minf;
         struct stat st;
         int c;
         int dflag = 0;                  /* for checking in use during -d ops */
+        int eflag = 0;                  /* print estimated dump size */
         int dcmode = DC_CURRENT;        /* kernel settings override unless -u */
         int modified = 0;               /* have we modified the dump config? */
         char *minfstr = NULL;           /* string value of -m argument */
         dumpconf_t dc;                  /* current configuration */
         int chrooted = 0;

@@ -119,11 +121,13 @@
                                 if (dconf_str2device(&dc, optarg) == -1)
                                         return (E_USAGE);
                                 dflag++;
                                 modified++;
                                 break;
-
+                        case 'e':
+                                eflag++;
+                                break;
                         case 'i':
                                 /* undocumented option */
                                 if (chrooted) {
                                         warn(gettext("-i and -r cannot be "
                                             "used together\n"));

@@ -166,10 +170,18 @@
                                 break;
                         }
                 }
         }
 
+        if (eflag) {
+                if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'e' &&
+                    !argv[1][2])
+                        return (dconf_get_dumpsize(&dc) ? E_SUCCESS : E_ERROR);
+                else
+                        die(gettext("-e cannot be used with other options\n"));
+        }
+
         if (douuid)
                 return (dconf_write_uuid(&dc) ? E_SUCCESS : E_ERROR);
 
         if (minfstr != NULL) {
                 if (minfree_compute(dc.dc_savdir, minfstr, &minf) == -1)