Bug #2803

zfs get guid pretty-prints the output

Added by Garrett D'Amore almost 2 years ago. Updated almost 2 years ago.

Status:Resolved Start date:2012-05-30
Priority:Normal Due date:
Assignee:Garrett D'Amore % Done:

100%

Category:zfs - Zettabyte File System Spent time: -
Target version:-
Difficulty:Medium Tags:

Description

ZFS tools treat the GUID for an object as a numeric and try pretty printing, which leads to garbage.

  1. zfs get guid src
    NAME PROPERTY VALUE SOURCE
    src guid 9.47E -

The GUID is really an identifier, and should not be treated this way.

History

Updated by Garrett D'Amore almost 2 years ago

Here's the proposed trivial fix for it:


--- a/usr/src/lib/libzfs/common/libzfs_dataset.c    Tue May 29 13:58:04 2012 -0700
+++ b/usr/src/lib/libzfs/common/libzfs_dataset.c    Tue May 29 23:42:35 2012 -0700
@@ -23,6 +23,7 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 DEY Storage Systems, Inc.  All rights reserved.
  */

 #include <ctype.h>
@@ -2280,6 +2281,12 @@
         }
         break;

+    case ZFS_PROP_GUID:
+        if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
+            return (-1);
+        (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t)val);
+        break;
+
     default:
         switch (zfs_prop_get_type(prop)) {
         case PROP_TYPE_NUMBER:

Here are tests from before and after:

before:

garrett@velocity{212}> zfs get guid rpoolNAME   PROPERTY  VALUE  SOURCE
rpool  guid      11.2E  -

after:


garrett@velocity{211}> env LD_PRELOAD=/ws/dey/build-dist/src/illumos-gate/usr/src/lib/libzfs/i386/libzfs.so.1 zfs get guid rpool
NAME   PROPERTY  VALUE  SOURCE
rpool  guid      12937182491779411210  -

Updated by Garrett D'Amore almost 2 years ago

  • Status changed from New to Resolved
  • Tags deleted (needs-triage)

Resolved in:

changeset: 13715:351036203e4b
tag: tip
user: Garrett D'Amore <>
date: Wed Jun 06 10:01:43 2012 -0700
description:
2803 zfs get guid pretty-prints the output
Reviewed by: Eric Schrock <>
Reviewed by: Richard Elling <>
Reviewed by: Alexander Eremin <>
Approved by: Dan McDonald <>

Also available in: Atom PDF