hostid is a long, and that ship has sailed, but still 64-bit archs should
not truncate the value.

I would like somebody to test this on a 64-bit machine.  Even try
setting a 64-bit hostid maybe.

Index: kern_sysctl.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.205
diff -u -r1.205 kern_sysctl.c
--- kern_sysctl.c       27 Jun 2011 03:40:35 -0000      1.205
+++ kern_sysctl.c       2 Jul 2011 00:59:56 -0000
@@ -349,9 +349,18 @@
                        domainnamelen = newlen;
                return (error);
        case KERN_HOSTID:
-               inthostid = hostid;  /* XXX assumes sizeof long <= sizeof int */
-               error =  sysctl_int(oldp, oldlenp, newp, newlen, &inthostid);
-               hostid = inthostid;
+#ifdef LP64
+               if (*oldlenp == sizeof(int64_t) || newlen == sizeof(int64_t)) {
+                       error = sysctl_quad(oldp, oldlenp, newp, newlen,
+                           &hostid);
+               } else
+#endif
+               {
+                       inthostid = hostid;
+                       error =  sysctl_int(oldp, oldlenp, newp, newlen,
+                           &inthostid);
+                       hostid = inthostid;
+               }
                return (error);
        case KERN_CLOCKRATE:
                return (sysctl_clockrate(oldp, oldlenp, newp));

Reply via email to