summaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2014-10-01 15:02:12 -0400
committerBrian Behlendorf <[email protected]>2014-10-17 14:58:57 -0700
commitf0e324f25d5ada5da5f8930fc1789af6896c72b4 (patch)
tree33c81bcfd6c68a7844952f4ea356ed2bfe88d480 /module/zfs
parent050d22b06834876c3b0554647108f06a05b3ba96 (diff)
Update utsname support
Modify the code to use the utsname() kernel function rather than a global variable. This results is cleaner more portable code because utsname() is already provided by the kernel and can be easily emulated in user space via uname(2). This means that it will behave consistently in both contexts. This is also has the benefit that it allows the removal of a few _KERNEL pre-processor conditions. And it also is a pre-requisite for a proper FUSE port because we need to provide a valid utsname. Finally, it allows us to remove this functionality from the SPL and all the related compatibility code. Signed-off-by: Brian Behlendorf <[email protected]> Issue #2757
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/spa_config.c5
-rw-r--r--module/zfs/spa_history.c11
2 files changed, 7 insertions, 9 deletions
diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c
index c8fe79ed5..a08456d56 100644
--- a/module/zfs/spa_config.c
+++ b/module/zfs/spa_config.c
@@ -32,7 +32,6 @@
#include <sys/fs/zfs.h>
#include <sys/vdev_impl.h>
#include <sys/zfs_ioctl.h>
-#include <sys/utsname.h>
#include <sys/systeminfo.h>
#include <sys/sunddi.h>
#include <sys/zfeature.h>
@@ -408,8 +407,8 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_HOSTID,
hostid) == 0);
}
- VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_HOSTNAME,
- utsname.nodename) == 0);
+ VERIFY0(nvlist_add_string(config, ZPOOL_CONFIG_HOSTNAME,
+ utsname()->nodename));
if (vd != rvd) {
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_TOP_GUID,
diff --git a/module/zfs/spa_history.c b/module/zfs/spa_history.c
index 5b82238b9..1c434197d 100644
--- a/module/zfs/spa_history.c
+++ b/module/zfs/spa_history.c
@@ -32,7 +32,6 @@
#include <sys/dmu_objset.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_dir.h>
-#include <sys/utsname.h>
#include <sys/cmn_err.h>
#include <sys/sunddi.h>
#include <sys/cred.h>
@@ -236,9 +235,8 @@ spa_history_log_sync(void *arg, dmu_tx_t *tx)
#endif
fnvlist_add_uint64(nvl, ZPOOL_HIST_TIME, gethrestime_sec());
-#ifdef _KERNEL
- fnvlist_add_string(nvl, ZPOOL_HIST_HOST, utsname.nodename);
-#endif
+ fnvlist_add_string(nvl, ZPOOL_HIST_HOST, utsname()->nodename);
+
if (nvlist_exists(nvl, ZPOOL_HIST_CMD)) {
zfs_dbgmsg("command: %s",
fnvlist_lookup_string(nvl, ZPOOL_HIST_CMD));
@@ -546,11 +544,12 @@ spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
void
spa_history_log_version(spa_t *spa, const char *operation)
{
+ utsname_t *u = utsname();
+
spa_history_log_internal(spa, operation, NULL,
"pool version %llu; software version %llu/%d; uts %s %s %s %s",
(u_longlong_t)spa_version(spa), SPA_VERSION, ZPL_VERSION,
- utsname.nodename, utsname.release, utsname.version,
- utsname.machine);
+ u->nodename, u->release, u->version, u->machine);
}
#if defined(_KERNEL) && defined(HAVE_SPL)