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.
This commit is contained in:
Darik Horn
2011-04-25 10:18:07 -05:00
parent a1cc0b3290
commit 492b8e9e7b
3 changed files with 5 additions and 12 deletions
+3 -1
View File
@@ -1533,7 +1533,9 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID,
&hostid) == 0) {
if ((unsigned long)hostid != gethostid()) {
unsigned long system_hostid = gethostid() & 0xffffffff;
if ((unsigned long)hostid != system_hostid) {
char *hostname;
uint64_t timestamp;
time_t t;