Print this page
7475 savecore should not go further if there is no dumpfile

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/savecore/savecore.c
          +++ new/usr/src/cmd/savecore/savecore.c
↓ open down ↓ 64 lines elided ↑ open up ↑
  65   65  
  66   66  /* create this file if metrics collection is enabled in the kernel */
  67   67  #define METRICSFILE "METRICS.csv"
  68   68  
  69   69  static char     progname[9] = "savecore";
  70   70  static char     *savedir;               /* savecore directory */
  71   71  static char     *dumpfile;              /* source of raw crash dump */
  72   72  static long     bounds = -1;            /* numeric suffix */
  73   73  static long     pagesize;               /* dump pagesize */
  74   74  static int      dumpfd = -1;            /* dumpfile descriptor */
       75 +static boolean_t have_dumpfile = B_TRUE;        /* dumpfile existence */
  75   76  static dumphdr_t corehdr, dumphdr;      /* initial and terminal dumphdrs */
  76   77  static boolean_t dump_incomplete;       /* dumphdr indicates incomplete */
  77   78  static boolean_t fm_panic;              /* dump is the result of fm_panic */
  78   79  static offset_t endoff;                 /* offset of end-of-dump header */
  79   80  static int      verbose;                /* chatty mode */
  80   81  static int      disregard_valid_flag;   /* disregard valid flag */
  81   82  static int      livedump;               /* dump the current running system */
  82   83  static int      interactive;            /* user invoked; no syslog */
  83   84  static int      csave;                  /* save dump compressed */
  84   85  static int      filemode;               /* processing file, not dump device */
↓ open down ↓ 147 lines elided ↑ open up ↑
 232  233                          raise_event(SC_EVENT_SAVECORE_FAILURE, buf);
 233  234                  code = 2;
 234  235                  break;
 235  236  
 236  237          case SC_EXIT_FM:
 237  238                  code = 3;
 238  239                  break;
 239  240  
 240  241          case SC_EXIT_ERR:
 241  242          default:
 242      -                if (!mflag && logprint_raised++ == 0)
      243 +                if (!mflag && logprint_raised++ == 0 && have_dumpfile)
 243  244                          raise_event(SC_EVENT_SAVECORE_FAILURE, buf);
 244  245                  code = 1;
 245  246                  break;
 246  247          }
 247  248  
 248  249          exit(code);
 249  250  }
 250  251  
 251  252  /*
 252  253   * System call / libc wrappers that exit on error.
↓ open down ↓ 39 lines elided ↑ open up ↑
 292  293  Fstat(int fd, Stat_t *sb, const char *fname)
 293  294  {
 294  295          if (fstat64(fd, sb) != 0)
 295  296                  logprint(SC_SL_ERR | SC_EXIT_ERR, "fstat(\"%s\"): %s", fname,
 296  297                      strerror(errno));
 297  298  }
 298  299  
 299  300  static void
 300  301  Stat(const char *fname, Stat_t *sb)
 301  302  {
 302      -        if (stat64(fname, sb) != 0)
 303      -                logprint(SC_SL_ERR | SC_EXIT_ERR, "stat(\"%s\"): %s", fname,
 304      -                    strerror(errno));
      303 +        if (stat64(fname, sb) != 0) {
      304 +                have_dumpfile = B_FALSE;
      305 +                logprint(SC_SL_ERR | SC_EXIT_ERR, "failed to get status "
      306 +                    "of file %s", fname);
      307 +        }
 305  308  }
 306  309  
 307  310  static void
 308  311  Pread(int fd, void *buf, size_t size, offset_t off)
 309  312  {
 310  313          ssize_t sz = pread64(fd, buf, size, off);
 311  314  
 312  315          if (sz < 0)
 313  316                  logprint(SC_SL_ERR | SC_EXIT_ERR,
 314  317                      "pread: %s", strerror(errno));
↓ open down ↓ 1389 lines elided ↑ open up ↑
1704 1707          interactive = isatty(STDOUT_FILENO);
1705 1708  
1706 1709          if (cflag && livedump)
1707 1710                  usage();
1708 1711  
1709 1712          if (dumpfile == NULL || livedump)
1710 1713                  dumpfd = Open("/dev/dump", O_RDONLY, 0444);
1711 1714  
1712 1715          if (dumpfile == NULL) {
1713 1716                  dumpfile = Zalloc(MAXPATHLEN);
1714      -                if (ioctl(dumpfd, DIOCGETDEV, dumpfile) == -1)
     1717 +                if (ioctl(dumpfd, DIOCGETDEV, dumpfile) == -1) {
     1718 +                        have_dumpfile  = B_FALSE;
1715 1719                          logprint(SC_SL_NONE | SC_IF_ISATTY | SC_EXIT_ERR,
1716 1720                              "no dump device configured");
     1721 +                }
1717 1722          }
1718 1723  
1719 1724          if (mflag)
1720 1725                  return (message_save());
1721 1726  
1722 1727          if (optind == argc - 1)
1723 1728                  savedir = argv[optind];
1724 1729  
1725 1730          if (savedir == NULL || optind < argc - 1)
1726 1731                  usage();
↓ open down ↓ 270 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX