Skip to content

Commit daff6b7

Browse files
robnbehlendorf
authored andcommitted
libspl: move utsname() etc to sys/misc.h; initialise in libspl_init()
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
1 parent 6cf6f09 commit daff6b7

File tree

5 files changed

+54
-14
lines changed

5 files changed

+54
-14
lines changed

include/sys/zfs_context.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ extern "C" {
113113
#include <sys/sysevent/eventdefs.h>
114114
#include <sys/sunddi.h>
115115
#include <sys/debug.h>
116-
#include <sys/utsname.h>
117116
#include <sys/trace_zfs.h>
118117

119118
#include <sys/mutex.h>
@@ -131,6 +130,7 @@ extern "C" {
131130
#include <sys/callb.h>
132131
#include <sys/trace.h>
133132
#include <sys/systm.h>
133+
#include <sys/misc.h>
134134

135135
#include <sys/zfs_context_os.h>
136136

@@ -267,9 +267,6 @@ extern uint32_t zone_get_hostid(void *zonep);
267267
extern int ddi_strtoull(const char *str, char **nptr, int base,
268268
u_longlong_t *result);
269269

270-
typedef struct utsname utsname_t;
271-
extern utsname_t *utsname(void);
272-
273270
/* ZFS Boot Related stuff. */
274271

275272
struct _buf {

lib/libspl/include/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ libspl_sys_HEADERS = \
4343
%D%/sys/kstat.h \
4444
%D%/sys/list.h \
4545
%D%/sys/list_impl.h \
46+
%D%/sys/misc.h \
4647
%D%/sys/mhd.h \
4748
%D%/sys/mkdev.h \
4849
%D%/sys/mod.h \

lib/libspl/include/sys/misc.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: CDDL-1.0
2+
/*
3+
* CDDL HEADER START
4+
*
5+
* The contents of this file are subject to the terms of the
6+
* Common Development and Distribution License (the "License").
7+
* You may not use this file except in compliance with the License.
8+
*
9+
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10+
* or https://opensource.org/licenses/CDDL-1.0.
11+
* See the License for the specific language governing permissions
12+
* and limitations under the License.
13+
*
14+
* When distributing Covered Code, include this CDDL HEADER in each
15+
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16+
* If applicable, add the following below this CDDL HEADER, with the
17+
* fields enclosed by brackets "[]" replaced with your own identifying
18+
* information: Portions Copyright [yyyy] [name of copyright owner]
19+
*
20+
* CDDL HEADER END
21+
*/
22+
/*
23+
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24+
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25+
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
26+
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
27+
*/
28+
29+
#ifndef _LIBSPL_SYS_MISC_H
30+
#define _LIBSPL_SYS_MISC_H
31+
32+
#include <sys/utsname.h>
33+
34+
/*
35+
* Hostname information
36+
*/
37+
typedef struct utsname utsname_t;
38+
extern utsname_t *utsname(void);
39+
40+
#endif

lib/libspl/libspl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,26 @@
2828
*/
2929

3030
#include <libspl.h>
31+
#include <assert.h>
3132
#include <unistd.h>
33+
#include <sys/misc.h>
34+
#include <sys/utsname.h>
3235

3336
uint64_t physmem;
37+
struct utsname hw_utsname;
38+
39+
utsname_t *
40+
utsname(void)
41+
{
42+
return (&hw_utsname);
43+
}
3444

3545
void
3646
libspl_init(void)
3747
{
3848
physmem = sysconf(_SC_PHYS_PAGES);
49+
50+
VERIFY0(uname(&hw_utsname));
3951
}
4052

4153
void

lib/libzpool/kernel.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include <sys/systeminfo.h>
4545
#include <sys/time.h>
4646
#include <sys/tsd.h>
47-
#include <sys/utsname.h>
4847

4948
#include <libspl.h>
5049
#include <libzpool.h>
@@ -61,7 +60,6 @@
6160
*/
6261

6362
uint32_t hostid;
64-
struct utsname hw_utsname;
6563

6664
/* If set, all blocks read will be copied to the specified directory. */
6765
char *vn_dumpdir = NULL;
@@ -405,12 +403,6 @@ ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result)
405403
return (0);
406404
}
407405

408-
utsname_t *
409-
utsname(void)
410-
{
411-
return (&hw_utsname);
412-
}
413-
414406
/*
415407
* =========================================================================
416408
* kernel emulation setup & teardown
@@ -515,8 +507,6 @@ kernel_init(int mode)
515507

516508
random_init();
517509

518-
VERIFY0(uname(&hw_utsname));
519-
520510
system_taskq_init();
521511
icp_init();
522512

0 commit comments

Comments
 (0)