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
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/uts/common/io/dump.c
          +++ new/usr/src/uts/common/io/dump.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   * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Delphix (c) 2012 by Delphix. All rights reserved.
       24 + * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
  24   25   */
  25   26  
  26   27  
  27   28  /*
  28   29   * Dump driver.  Provides ioctls to get/set crash dump configuration.
  29   30   */
  30   31  
  31   32  #include <sys/types.h>
  32   33  #include <sys/param.h>
  33   34  #include <sys/systm.h>
↓ open down ↓ 5 lines elided ↑ open up ↑
  39   40  #include <sys/modctl.h>
  40   41  #include <sys/dumphdr.h>
  41   42  #include <sys/dumpadm.h>
  42   43  #include <sys/pathname.h>
  43   44  #include <sys/file.h>
  44   45  #include <vm/anon.h>
  45   46  #include <sys/stat.h>
  46   47  #include <sys/conf.h>
  47   48  #include <sys/ddi.h>
  48   49  #include <sys/sunddi.h>
       50 +#include <sys/uuid.h>
  49   51  
  50   52  static dev_info_t *dump_devi;
  51   53  
  52   54  static int
  53   55  dump_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
  54   56  {
  55   57          if (cmd != DDI_ATTACH)
  56   58                  return (DDI_FAILURE);
  57   59          if (ddi_create_minor_node(devi, "dump", S_IFCHR, 0, DDI_PSEUDO, NULL) ==
  58   60              DDI_FAILURE) {
↓ open down ↓ 29 lines elided ↑ open up ↑
  88   90  }
  89   91  
  90   92  /*ARGSUSED*/
  91   93  int
  92   94  dump_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cred, int *rvalp)
  93   95  {
  94   96          uint64_t size;
  95   97          uint64_t dumpsize_in_pages;
  96   98          int error = 0;
  97   99          char *pathbuf = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
  98      -        char uuidbuf[36 + 1];
      100 +        char uuidbuf[UUID_PRINTABLE_STRING_LENGTH];
  99  101          size_t len;
 100  102          vnode_t *vp;
 101  103  
 102  104          switch (cmd) {
 103  105          case DIOCGETDUMPSIZE:
 104  106                  if (dump_conflags & DUMP_ALL)
 105  107                          size = ptob((uint64_t)physmem) / DUMP_COMPRESS_RATIO;
 106  108                  else {
 107  109                          /*
 108  110                           * We can't give a good answer for the DUMP_CURPROC
↓ open down ↓ 66 lines elided ↑ open up ↑
 175  177                  mutex_enter(&dump_lock);
 176  178                  if (vp->v_type == VBLK)
 177  179                          error = dumpinit(vp, pathbuf, cmd == DIOCTRYDEV);
 178  180                  else
 179  181                          error = ENOTBLK;
 180  182                  mutex_exit(&dump_lock);
 181  183                  VN_RELE(vp);
 182  184                  break;
 183  185  
 184  186          case DIOCDUMP:
      187 +                if ((error = copyinstr((char *)arg, uuidbuf, sizeof (uuidbuf),
      188 +                    &len)) != 0)
      189 +                        break;
      190 +
      191 +                if (len != UUID_PRINTABLE_STRING_LENGTH) {
      192 +                        error = EINVAL;
      193 +                        break;
      194 +                }
      195 +                if ((error = dump_update_uuid(uuidbuf)) != 0) {
      196 +                        error = EINVAL;
      197 +                        break;
      198 +                }
      199 +
 185  200                  mutex_enter(&dump_lock);
 186  201                  if (dumpvp == NULL)
 187  202                          error = ENODEV;
 188  203                  else if (dumpvp->v_flag & VISSWAP)
 189  204                          error = EBUSY;
 190  205                  else
 191  206                          dumpsys();
 192  207                  mutex_exit(&dump_lock);
 193  208                  break;
 194  209  
 195  210          case DIOCSETUUID:
 196  211                  if ((error = copyinstr((char *)arg, uuidbuf, sizeof (uuidbuf),
 197  212                      &len)) != 0)
 198  213                          break;
 199  214  
 200      -                if (len != 37) {
      215 +                if (len != UUID_PRINTABLE_STRING_LENGTH) {
 201  216                          error = EINVAL;
 202  217                          break;
 203  218                  }
 204  219  
 205  220                  error = dump_set_uuid(uuidbuf);
 206  221                  break;
 207  222  
 208  223          case DIOCGETUUID:
 209      -                error = copyoutstr(dump_get_uuid(), (void *)arg, 37, NULL);
      224 +                error = copyoutstr(dump_get_uuid(), (void *)arg,
      225 +                    UUID_PRINTABLE_STRING_LENGTH, NULL);
 210  226                  break;
 211  227  
 212  228          case DIOCRMDEV:
 213  229                  mutex_enter(&dump_lock);
 214  230                  if (dumpvp != NULL)
 215  231                          dumpfini();
 216  232                  mutex_exit(&dump_lock);
 217  233                  break;
 218  234  
 219  235          default:
↓ open down ↓ 65 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX