]>
git.proxmox.com Git - mirror_spl.git/blob - modules/spl/spl-generic.c
1 #include <sys/sysmacros.h>
2 #include <sys/vmsystm.h>
7 #include <linux/kmod.h>
10 #ifdef DEBUG_SUBSYSTEM
11 #undef DEBUG_SUBSYSTEM
14 #define DEBUG_SUBSYSTEM S_GENERIC
17 EXPORT_SYMBOL(spl_hostid
);
19 char hw_serial
[11] = "<none>";
20 EXPORT_SYMBOL(hw_serial
);
25 vmem_t
*zio_alloc_arena
= NULL
;
26 EXPORT_SYMBOL(zio_alloc_arena
);
29 highbit(unsigned long i
)
36 #if BITS_PER_LONG == 64
37 if (i
& 0xffffffff00000000ul
) {
58 EXPORT_SYMBOL(highbit
);
61 ddi_strtoul(const char *str
, char **nptr
, int base
, unsigned long *result
)
64 return (*result
= simple_strtoul(str
, &end
, base
));
66 EXPORT_SYMBOL(ddi_strtoul
);
71 char sh_path
[] = "/bin/sh";
72 char *argv
[] = { sh_path
,
74 "/usr/bin/hostid >/proc/sys/spl/hostid",
76 char *envp
[] = { "HOME=/",
78 "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
81 /* Doing address resolution in the kernel is tricky and just
82 * not a good idea in general. So to set the proper 'hw_serial'
83 * use the usermodehelper support to ask '/bin/sh' to run
84 * '/usr/bin/hostid' and redirect the result to /proc/sys/spl/hostid
85 * for us to use. It's a horific solution but it will do for now.
87 return call_usermodehelper(sh_path
, argv
, envp
, 1);
90 static int __init
spl_init(void)
95 if ((rc
= debug_init()))
98 if ((rc
= kmem_init()))
101 if ((rc
= vn_init()))
104 if ((rc
= proc_init()))
107 if ((rc
= set_hostid()))
108 GOTO(out4
, rc
= -EADDRNOTAVAIL
);
110 printk("SPL: Loaded Solaris Porting Layer v%s\n", VERSION
);
121 printk("SPL: Failed to Load Solaris Porting Layer v%s, "
122 "rc = %d\n", VERSION
, rc
);
126 static void spl_fini(void)
130 printk("SPL: Unloaded Solaris Porting Layer v%s\n", VERSION
);
139 module_init(spl_init
);
140 module_exit(spl_fini
);
142 MODULE_AUTHOR("Lawrence Livermore National Labs");
143 MODULE_DESCRIPTION("Solaris Porting Layer");
144 MODULE_LICENSE("GPL");