Skip to content

Commit

Permalink
Remove hw_serial, ddi_strtoul()
Browse files Browse the repository at this point in the history
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes openzfs#13434
  • Loading branch information
nabijaczleweli authored and behlendorf committed May 13, 2022
1 parent 0c11a27 commit c25b281
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 47 deletions.
2 changes: 0 additions & 2 deletions include/os/freebsd/spl/sys/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion include/os/freebsd/spl/sys/sunddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
1 change: 0 additions & 1 deletion include/os/linux/spl/sys/sunddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
4 changes: 0 additions & 4 deletions include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
19 changes: 3 additions & 16 deletions lib/libzpool/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 0 additions & 4 deletions module/os/freebsd/spl/spl_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions module/os/freebsd/spl/spl_sunddi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
12 changes: 6 additions & 6 deletions module/os/linux/spl/spl-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c25b281

Please sign in to comment.