diff --git a/include/os/freebsd/spl/sys/misc.h b/include/os/freebsd/spl/sys/misc.h index 3481507d2c..2e4efc6054 100644 --- a/include/os/freebsd/spl/sys/misc.h +++ b/include/os/freebsd/spl/sys/misc.h @@ -52,8 +52,6 @@ struct opensolaris_utsname { char *machine; }; -extern char hw_serial[11]; - #define task_io_account_read(n) #define task_io_account_write(n) diff --git a/include/os/freebsd/spl/sys/sunddi.h b/include/os/freebsd/spl/sys/sunddi.h index bfbc3e10a1..28d40121d9 100644 --- a/include/os/freebsd/spl/sys/sunddi.h +++ b/include/os/freebsd/spl/sys/sunddi.h @@ -48,7 +48,6 @@ typedef int ddi_devid_t; #define ddi_prop_free(x) (void)0 #define ddi_root_node() (void)0 -extern int ddi_strtoul(const char *, char **, int, unsigned long *); extern int ddi_strtol(const char *, char **, int, long *); extern int ddi_strtoull(const char *, char **, int, unsigned long long *); extern int ddi_strtoll(const char *, char **, int, long long *); diff --git a/include/os/linux/spl/sys/sunddi.h b/include/os/linux/spl/sys/sunddi.h index 8524ec9c30..df6a204d5c 100644 --- a/include/os/linux/spl/sys/sunddi.h +++ b/include/os/linux/spl/sys/sunddi.h @@ -46,7 +46,6 @@ typedef int ddi_devid_t; #define ddi_prop_free(x) (void)0 #define ddi_root_node() (void)0 -extern int ddi_strtoul(const char *, char **, int, unsigned long *); extern int ddi_strtol(const char *, char **, int, long *); extern int ddi_strtoull(const char *, char **, int, unsigned long long *); extern int ddi_strtoll(const char *, char **, int, long long *); diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 944acdcfbe..50257f1d6f 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -692,10 +692,6 @@ extern char *kmem_asprintf(const char *fmt, ...); /* * Hostname information */ -extern char hw_serial[]; /* for userland-emulated hostid access */ -extern int ddi_strtoul(const char *str, char **nptr, int base, - unsigned long *result); - extern int ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result); diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 89151f70ec..011f9d2110 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -53,7 +53,7 @@ */ uint64_t physmem; -char hw_serial[HW_HOSTID_LEN]; +uint32_t hostid; struct utsname hw_utsname; /* If set, all blocks read will be copied to the specified directory. */ @@ -299,7 +299,7 @@ zone_get_hostid(void *zonep) * We're emulating the system's hostid in userland. */ (void) zonep; - return (strtoul(hw_serial, NULL, 10)); + return (hostid); } int @@ -766,18 +766,6 @@ random_get_pseudo_bytes(uint8_t *ptr, size_t len) return (random_get_bytes_common(ptr, len, urandom_fd)); } -int -ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result) -{ - (void) nptr; - char *end; - - *result = strtoul(hw_serial, &end, base); - if (*result == 0) - return (errno); - return (0); -} - int ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result) { @@ -823,8 +811,7 @@ kernel_init(int mode) dprintf("physmem = %llu pages (%.2f GB)\n", (u_longlong_t)physmem, (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30)); - (void) snprintf(hw_serial, sizeof (hw_serial), "%ld", - (mode & SPA_MODE_WRITE) ? get_system_hostid() : 0); + hostid = (mode & SPA_MODE_WRITE) ? get_system_hostid() : 0; random_init(); diff --git a/module/os/freebsd/spl/spl_misc.c b/module/os/freebsd/spl/spl_misc.c index 0354b986cd..e46271a039 100644 --- a/module/os/freebsd/spl/spl_misc.c +++ b/module/os/freebsd/spl/spl_misc.c @@ -43,15 +43,11 @@ static struct opensolaris_utsname hw_utsname = { .machine = MACHINE }; -#ifndef KERNEL_STATIC -char hw_serial[11] = "0"; - utsname_t * utsname(void) { return (&hw_utsname); } -#endif static void opensolaris_utsname_init(void *arg) diff --git a/module/os/freebsd/spl/spl_sunddi.c b/module/os/freebsd/spl/spl_sunddi.c index ebec77bdb3..2a3c027c93 100644 --- a/module/os/freebsd/spl/spl_sunddi.c +++ b/module/os/freebsd/spl/spl_sunddi.c @@ -45,19 +45,6 @@ ddi_strtol(const char *str, char **nptr, int base, long *result) return (0); } -int -ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result) -{ - - if (str == hw_serial) { - *result = prison0.pr_hostid; - return (0); - } - - *result = strtoul(str, nptr, base); - return (0); -} - int ddi_strtoull(const char *str, char **nptr, int base, unsigned long long *result) { diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c index 143f345985..6fa564b855 100644 --- a/module/os/linux/spl/spl-generic.c +++ b/module/os/linux/spl/spl-generic.c @@ -425,13 +425,13 @@ EXPORT_SYMBOL(__aeabi_ldivmod); * functions against their Solaris counterparts. It is possible that I * may have misinterpreted the man page or the man page is incorrect. */ -int ddi_strtoul(const char *, char **, int, unsigned long *); +static int ddi_strtoul(const char *, char **, int, unsigned long *); int ddi_strtol(const char *, char **, int, long *); int ddi_strtoull(const char *, char **, int, unsigned long long *); int ddi_strtoll(const char *, char **, int, long long *); -#define define_ddi_strtoux(type, valtype) \ -int ddi_strtou##type(const char *str, char **endptr, \ +#define define_ddi_strtoux(type, valtype, ...) \ +__VA_ARGS__ int ddi_strtou##type(const char *str, char **endptr, \ int base, valtype *result) \ { \ valtype last_value, value = 0; \ @@ -508,12 +508,12 @@ int ddi_strto##type(const char *str, char **endptr, \ return (rc); \ } -define_ddi_strtoux(l, unsigned long) +#define blank +define_ddi_strtoux(l, unsigned long, static) define_ddi_strtox(l, long) -define_ddi_strtoux(ll, unsigned long long) +define_ddi_strtoux(ll, unsigned long long, blank) define_ddi_strtox(ll, long long) -EXPORT_SYMBOL(ddi_strtoul); EXPORT_SYMBOL(ddi_strtol); EXPORT_SYMBOL(ddi_strtoll); EXPORT_SYMBOL(ddi_strtoull);