]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
fix byte ordering in check_sysid
authorMichael Meffie <mmeffie@sinenomine.net>
Fri, 14 Nov 2014 21:57:53 +0000 (16:57 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Sat, 14 Nov 2015 16:59:56 +0000 (11:59 -0500)
Several uuid fields as well as the ip addreses in the sysid file are in
network byte order.  Fix the check_sysid utility to decode these fields
properly.  In addition, print the server uuid in the common string
format used to display uuids, instead of by individual uuid fields.

Reviewed-on: http://gerrit.openafs.org/11603
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Daria Brashear <shadow@your-file-system.com>
(cherry picked from commit 52b8073a6c1ef11f1a47fb26d77efd87425be556)

Note: Although this fix is marked as a "cherry-pick", this patch was
rewritten for the 1.6 branch since the opr uuid handling functions are
not available in the 1.6 branch.

Change-Id: I52e74fc28b30f06a8180ff65a8006c9281162fe9
Reviewed-on: http://gerrit.openafs.org/12090
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/viced/check_sysid.c

index 7c89a6218462012186b53bdf714da9f2260ad811..c76ecfbd52a2d662576f799bcba6981a86c8861e 100644 (file)
@@ -24,8 +24,8 @@
 #define SYSIDVERSION    1
 
 struct versionStamp {          /* Stolen from <afs/volume.h> */
-    int magic;
-    int version;
+    int magic;   /* stored in host byte order */
+    int version; /* stored in host byte order */
 };
 
 int
@@ -69,6 +69,19 @@ main(int argc, char **argv)
               errno);
        exit(3);
     }
+
+    /* These uuid fields are in network byte order */
+    uuid.time_low = ntohl(uuid.time_low);
+    uuid.time_mid = ntohs(uuid.time_mid);
+    uuid.time_hi_and_version = ntohs(uuid.time_hi_and_version);
+
+    printf("UUID                 = %08x-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x\n",
+            uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
+            (unsigned char)uuid.clock_seq_hi_and_reserved,
+            (unsigned char)uuid.clock_seq_low, (unsigned char)uuid.node[0],
+            (unsigned char)uuid.node[1], (unsigned char)uuid.node[2],
+            (unsigned char)uuid.node[3], (unsigned char)uuid.node[4],
+            (unsigned char)uuid.node[5]);
     printf("UUID.time(hi.mid.low)= 0x%03x.%04x.%08x\n",
           uuid.time_hi_and_version & 0x0fff, uuid.time_mid & 0xffff,
           uuid.time_low);
@@ -101,6 +114,7 @@ main(int argc, char **argv)
                   i + 1, size, errno);
            exit(5);
        }
+       addr = ntohl(addr);
        printf("Address              = %d.%d.%d.%d (0x%x)\n",
               (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff,
               (addr) & 0xff, addr);