diff options
author | Darik Horn <[email protected]> | 2011-04-25 10:18:07 -0500 |
---|---|---|
committer | Darik Horn <[email protected]> | 2011-04-25 10:36:17 -0500 |
commit | 492b8e9e7b6f3df55eed04f7288db6b62c17c668 (patch) | |
tree | d2d497ddd77b93bbd816e8c4a8ccd9ffd8bea9dc /lib/libzfs/libzfs_status.c | |
parent | a1cc0b3290dcf1b5cf759c89352d8bdb44ee41e6 (diff) |
Use gethostid in the Linux convention.
Disable the gethostid() override for Solaris behavior because Linux systems
implement the POSIX standard in a way that allows a negative result.
Mask the gethostid() result to the lower four bytes, like coreutils does in
/usr/bin/hostid, to prevent junk bits or sign-extension on systems that have an
eight byte long type. This can cause a spurious hostid mismatch that prevents
zpool import on 64-bit systems.
Diffstat (limited to 'lib/libzfs/libzfs_status.c')
-rw-r--r-- | lib/libzfs/libzfs_status.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libzfs/libzfs_status.c b/lib/libzfs/libzfs_status.c index 24725ec04..d56baf0bf 100644 --- a/lib/libzfs/libzfs_status.c +++ b/lib/libzfs/libzfs_status.c @@ -179,6 +179,7 @@ check_status(nvlist_t *config, boolean_t isimport) uint64_t stateval; uint64_t suspended; uint64_t hostid = 0; + unsigned long system_hostid = gethostid() & 0xffffffff; verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, &version) == 0); @@ -202,7 +203,7 @@ check_status(nvlist_t *config, boolean_t isimport) * Pool last accessed by another system. */ (void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID, &hostid); - if (hostid != 0 && (unsigned long)hostid != gethostid() && + if (hostid != 0 && (unsigned long)hostid != system_hostid && stateval == POOL_STATE_ACTIVE) return (ZPOOL_STATUS_HOSTID_MISMATCH); |