summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-04-26 13:30:27 -0700
committerBrian Behlendorf <[email protected]>2011-04-26 13:30:27 -0700
commit44e9e3479388ee16f39253e8c3f8f6625324dfc6 (patch)
tree48577000804ec5b3ab5aa85228070fbc64197595
parent701b1f8168ebb0ad6b6958b9593488c17adebb44 (diff)
parent492b8e9e7b6f3df55eed04f7288db6b62c17c668 (diff)
Merged pull request #212 from dajhorn/hostid.
Use gethostid in the Linux convention.
-rw-r--r--cmd/zpool/zpool_main.c4
-rw-r--r--lib/libspl/include/unistd.h10
-rw-r--r--lib/libzfs/libzfs_status.c3
3 files changed, 5 insertions, 12 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index bad4e2a4f..3b8157392 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -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;
diff --git a/lib/libspl/include/unistd.h b/lib/libspl/include/unistd.h
index 44173d2a4..dc95e28b5 100644
--- a/lib/libspl/include/unistd.h
+++ b/lib/libspl/include/unistd.h
@@ -44,14 +44,4 @@
# define issetugid() (geteuid() == 0 || getegid() == 0)
#endif
-#if !defined(__sun__) && !defined(__sun)
-/* It seems Solaris only returns positive host ids */
-static inline long fake_gethostid(void)
-{
- long id = gethostid();
- return id >= 0 ? id : -id;
-}
-#define gethostid() fake_gethostid()
-#endif
-
#endif /* _LIBSPL_UNISTD_H */
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);