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>

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  * Delphix (c) 2012 by Delphix. All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
  */
 
 
 /*
  * Dump driver.  Provides ioctls to get/set crash dump configuration.

@@ -44,10 +45,11 @@
 #include <vm/anon.h>
 #include <sys/stat.h>
 #include <sys/conf.h>
 #include <sys/ddi.h>
 #include <sys/sunddi.h>
+#include <sys/uuid.h>
 
 static dev_info_t *dump_devi;
 
 static int
 dump_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)

@@ -93,11 +95,11 @@
 {
         uint64_t size;
         uint64_t dumpsize_in_pages;
         int error = 0;
         char *pathbuf = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
-        char uuidbuf[36 + 1];
+        char uuidbuf[UUID_PRINTABLE_STRING_LENGTH];
         size_t len;
         vnode_t *vp;
 
         switch (cmd) {
         case DIOCGETDUMPSIZE:

@@ -180,10 +182,23 @@
                 mutex_exit(&dump_lock);
                 VN_RELE(vp);
                 break;
 
         case DIOCDUMP:
+                if ((error = copyinstr((char *)arg, uuidbuf, sizeof (uuidbuf),
+                    &len)) != 0)
+                        break;
+
+                if (len != UUID_PRINTABLE_STRING_LENGTH) {
+                        error = EINVAL;
+                        break;
+                }
+                if ((error = dump_update_uuid(uuidbuf)) != 0) {
+                        error = EINVAL;
+                        break;
+                }
+
                 mutex_enter(&dump_lock);
                 if (dumpvp == NULL)
                         error = ENODEV;
                 else if (dumpvp->v_flag & VISSWAP)
                         error = EBUSY;

@@ -195,20 +210,21 @@
         case DIOCSETUUID:
                 if ((error = copyinstr((char *)arg, uuidbuf, sizeof (uuidbuf),
                     &len)) != 0)
                         break;
 
-                if (len != 37) {
+                if (len != UUID_PRINTABLE_STRING_LENGTH) {
                         error = EINVAL;
                         break;
                 }
 
                 error = dump_set_uuid(uuidbuf);
                 break;
 
         case DIOCGETUUID:
-                error = copyoutstr(dump_get_uuid(), (void *)arg, 37, NULL);
+                error = copyoutstr(dump_get_uuid(), (void *)arg,
+                    UUID_PRINTABLE_STRING_LENGTH, NULL);
                 break;
 
         case DIOCRMDEV:
                 mutex_enter(&dump_lock);
                 if (dumpvp != NULL)