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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dumpadm/main.c
          +++ new/usr/src/cmd/dumpadm/main.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  23   24   */
  24   25  
  25   26  #include <sys/stat.h>
  26   27  #include <locale.h>
  27   28  #include <unistd.h>
  28   29  #include <stdlib.h>
  29   30  #include <stdio.h>
  30   31  #include <string.h>
  31   32  
  32   33  #include "dconf.h"
  33   34  #include "minfree.h"
  34   35  #include "utils.h"
  35   36  
  36   37  static const char USAGE[] = "\
  37      -Usage: %s [-nuy] [-c kernel | curproc | all ] [-d dump-device | swap ]\n\
       38 +Usage: %s [-enuy] [-c kernel | curproc | all ] [-d dump-device | swap ]\n\
  38   39          [-m min {k|m|%%} ] [-s savecore-dir] [-r root-dir] [-z on|off]\n";
  39   40  
  40      -static const char OPTS[] = "inuyc:d:m:s:r:z:";
       41 +static const char OPTS[] = "einuyc:d:m:s:r:z:";
  41   42  
  42   43  static const char PATH_DEVICE[] = "/dev/dump";
  43   44  static const char PATH_CONFIG[] = "/etc/dumpadm.conf";
  44   45  
  45   46  int
  46   47  main(int argc, char *argv[])
  47   48  {
  48   49          const char *pname = getpname(argv[0]);
  49   50  
  50   51          u_longlong_t minf;
  51   52          struct stat st;
  52   53          int c;
  53   54          int dflag = 0;                  /* for checking in use during -d ops */
       55 +        int eflag = 0;                  /* print estimated dump size */
  54   56          int dcmode = DC_CURRENT;        /* kernel settings override unless -u */
  55   57          int modified = 0;               /* have we modified the dump config? */
  56   58          char *minfstr = NULL;           /* string value of -m argument */
  57   59          dumpconf_t dc;                  /* current configuration */
  58   60          int chrooted = 0;
  59   61          int douuid = 0;
  60   62  
  61   63          (void) setlocale(LC_ALL, "");
  62   64          (void) textdomain(TEXT_DOMAIN);
  63   65  
↓ open down ↓ 50 lines elided ↑ open up ↑
 114  116                                  if (dconf_str2content(&dc, optarg) == -1)
 115  117                                          return (E_USAGE);
 116  118                                  modified++;
 117  119                                  break;
 118  120                          case 'd':
 119  121                                  if (dconf_str2device(&dc, optarg) == -1)
 120  122                                          return (E_USAGE);
 121  123                                  dflag++;
 122  124                                  modified++;
 123  125                                  break;
 124      -
      126 +                        case 'e':
      127 +                                eflag++;
      128 +                                break;
 125  129                          case 'i':
 126  130                                  /* undocumented option */
 127  131                                  if (chrooted) {
 128  132                                          warn(gettext("-i and -r cannot be "
 129  133                                              "used together\n"));
 130  134                                          return (E_USAGE);
 131  135                                  }
 132  136                                  douuid++;
 133  137                                  break;
 134  138  
↓ open down ↓ 26 lines elided ↑ open up ↑
 161  165  
 162  166                          case 'z':
 163  167                                  if (dconf_str2csave(&dc, optarg) == -1)
 164  168                                          return (E_USAGE);
 165  169                                  modified++;
 166  170                                  break;
 167  171                          }
 168  172                  }
 169  173          }
 170  174  
      175 +        if (eflag) {
      176 +                if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'e' &&
      177 +                    !argv[1][2])
      178 +                        return (dconf_get_dumpsize(&dc) ? E_SUCCESS : E_ERROR);
      179 +                else
      180 +                        die(gettext("-e cannot be used with other options\n"));
      181 +        }
      182 +
 171  183          if (douuid)
 172  184                  return (dconf_write_uuid(&dc) ? E_SUCCESS : E_ERROR);
 173  185  
 174  186          if (minfstr != NULL) {
 175  187                  if (minfree_compute(dc.dc_savdir, minfstr, &minf) == -1)
 176  188                          return (E_USAGE);
 177  189                  if (minfree_write(dc.dc_savdir, minf) == -1)
 178  190                          return (E_ERROR);
 179  191          }
 180  192  
↓ open down ↓ 41 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX