Print this page
NEX-9338 improve the layout of the crash directory (use sys/uuid.h)
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-9338 improve the layout of the crash directory (follow-up)
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-9338 improve the layout of the crash directory
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Steve Peng <steve.peng@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fm/modules/common/sw-diag-response/subsidiary/panic/panic_diag.c
          +++ new/usr/src/cmd/fm/modules/common/sw-diag-response/subsidiary/panic/panic_diag.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  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  /*
  23   23   * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
  24   25   */
  25   26  
  26   27  /*
  27   28   * Panic software-diagnosis subsidiary
  28   29   *
  29   30   * We model a system panic as a defect diagnosis in FMA. When a system
  30   31   * panicks, savecore publishes events which we subscribe to here.
  31   32   *
  32   33   * Our driving events are all raised by savecore, run either from
  33   34   * startup of the dumpadm service or interactively at the command line.
↓ open down ↓ 43 lines elided ↑ open up ↑
  77   78   * When the timer fires we check whether the initial event for each panic
  78   79   * case was received more than 30 minutes ago; if it was we solve the case
  79   80   * with what we have.  If we're still within the waiting period we rearm
  80   81   * for a further 10 minutes.  The timer is shared by all cases that we
  81   82   * create, which is why the fire interval is shorter than the maximum time
  82   83   * we are prepared to wait.
  83   84   */
  84   85  
  85   86  #include <strings.h>
  86   87  #include <sys/panic.h>
  87      -#include <alloca.h>
  88   88  #include <zone.h>
       89 +#include <uuid/uuid.h>
  89   90  
  90   91  #include "../../common/sw.h"
  91   92  #include "panic.h"
  92   93  
  93   94  #define MAX_STRING_LEN 160
  94   95  
  95   96  static id_t myid;
  96   97  
  97   98  static id_t mytimerid;
  98   99  
↓ open down ↓ 90 lines elided ↑ open up ↑
 189  190                  return (0);
 190  191  }
 191  192  
 192  193  static const char *dumpfiles[2] = { "unix.%lld", "vmcore.%lld" };
 193  194  static const char *dumpfiles_comp[2] = { "vmdump.%lld", NULL};
 194  195  
 195  196  static void
 196  197  swde_panic_solve(fmd_hdl_t *hdl, fmd_case_t *cp,
 197  198      nvlist_t *attr, fmd_event_t *ep, boolean_t savecore_success)
 198  199  {
 199      -        char *dumpdir, *path, *uuid;
      200 +        char path[MAXPATHLEN];
      201 +        char *dumpdir, *uuid;
 200  202          nvlist_t *defect, *rsrc;
 201  203          nvpair_t *nvp;
 202  204          int i;
 203  205  
 204  206          /*
 205  207           * Attribute members to include in event-specific defect
 206  208           * payload.  Some attributes will not be present for some
 207  209           * cases - e.g., if we timed out and solved the case without
 208  210           * a "dump_available" report.
 209  211           */
↓ open down ↓ 12 lines elided ↑ open up ↑
 222  224           * in panic_sw_fmri. This should become a generic fmri constructor
 223  225           *
 224  226           * We need to user a resource FMRI which will have a sufficiently
 225  227           * unique string representation such that fmd will not see
 226  228           * repeated panic diagnoses (all using the same defect class)
 227  229           * as duplicates and discard later cases.  We can't actually diagnose
 228  230           * the panic to anything specific (e.g., a path to a module and
 229  231           * function/line etc therein).  We could pick on a generic
 230  232           * representative such as /kernel/genunix but that could lead
 231  233           * to misunderstanding.  So we choose a path based on <dumpdir>
 232      -         * and the OS instance UUID - "<dumpdir>/.<os-instance-uuid>".
 233      -         * There's no file at that path (*) but no matter.  We can't use
 234      -         * <dumpdir>/vmdump.N or similar because if savecore is disabled
 235      -         * or failed we don't have any file or instance number.
 236      -         *
 237      -         * (*) Some day it would seem tidier to keep all files to do
 238      -         * with a single crash (unix/vmcore/vmdump, analysis output etc)
 239      -         * in a distinct directory, and <dumpdir>/.<uuid> seems like a good
 240      -         * choice.  For compatability we'd symlink into it.  So that is
 241      -         * another reason for this choice - some day it may exist!
      234 +         * and the OS instance UUID - "<dumpdir>/data/<uuid>".
 242  235           */
 243  236          (void) nvlist_lookup_string(attr, "dumpdir", &dumpdir);
 244  237          (void) nvlist_lookup_string(attr, "os-instance-uuid", &uuid);
 245      -        path = alloca(strlen(dumpdir) + 1 + 1 + 36 + 1);
 246      -        /* LINTED: E_SEC_SPRINTF_UNBOUNDED_COPY */
 247      -        (void) sprintf(path, "%s/.%s", dumpdir, uuid);
      238 +        (void) snprintf(path, sizeof (path), "%s/data/%s", dumpdir, uuid);
 248  239          rsrc = panic_sw_fmri(hdl, path);
 249  240  
 250  241          defect = fmd_nvl_create_defect(hdl, SW_SUNOS_PANIC_DEFECT,
 251  242              100, rsrc, NULL, rsrc);
 252  243          nvlist_free(rsrc);
 253  244  
 254  245          (void) nvlist_add_boolean_value(defect, "savecore-succcess",
 255  246              savecore_success);
 256  247  
 257  248          if (savecore_success) {
↓ open down ↓ 333 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX