]> git.proxmox.com Git - mirror_zfs.git/blob - module/spl/spl-generic.c
Fix ARM 64-bit division
[mirror_zfs.git] / module / spl / spl-generic.c
1 /*****************************************************************************\
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6 * UCRL-CODE-235197
7 *
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://github.com/behlendorf/spl/>.
10 *
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 *****************************************************************************
24 * Solaris Porting Layer (SPL) Generic Implementation.
25 \*****************************************************************************/
26
27 #include <sys/sysmacros.h>
28 #include <sys/systeminfo.h>
29 #include <sys/vmsystm.h>
30 #include <sys/kobj.h>
31 #include <sys/kmem.h>
32 #include <sys/mutex.h>
33 #include <sys/rwlock.h>
34 #include <sys/taskq.h>
35 #include <sys/tsd.h>
36 #include <sys/zmod.h>
37 #include <sys/debug.h>
38 #include <sys/proc.h>
39 #include <sys/kstat.h>
40 #include <sys/utsname.h>
41 #include <sys/file.h>
42 #include <linux/kmod.h>
43 #include <linux/proc_compat.h>
44 #include <spl-debug.h>
45
46 #ifdef SS_DEBUG_SUBSYS
47 #undef SS_DEBUG_SUBSYS
48 #endif
49
50 #define SS_DEBUG_SUBSYS SS_GENERIC
51
52 char spl_version[32] = "SPL v" SPL_META_VERSION "-" SPL_META_RELEASE;
53 EXPORT_SYMBOL(spl_version);
54
55 unsigned long spl_hostid = HW_INVALID_HOSTID;
56 EXPORT_SYMBOL(spl_hostid);
57 module_param(spl_hostid, ulong, 0644);
58 MODULE_PARM_DESC(spl_hostid, "The system hostid.");
59
60 char hw_serial[HW_HOSTID_LEN] = "<none>";
61 EXPORT_SYMBOL(hw_serial);
62
63 proc_t p0 = { 0 };
64 EXPORT_SYMBOL(p0);
65
66 #ifndef HAVE_KALLSYMS_LOOKUP_NAME
67 kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn = SYMBOL_POISON;
68 #endif
69
70 int
71 highbit(unsigned long i)
72 {
73 register int h = 1;
74 SENTRY;
75
76 if (i == 0)
77 SRETURN(0);
78 #if BITS_PER_LONG == 64
79 if (i & 0xffffffff00000000ul) {
80 h += 32; i >>= 32;
81 }
82 #endif
83 if (i & 0xffff0000) {
84 h += 16; i >>= 16;
85 }
86 if (i & 0xff00) {
87 h += 8; i >>= 8;
88 }
89 if (i & 0xf0) {
90 h += 4; i >>= 4;
91 }
92 if (i & 0xc) {
93 h += 2; i >>= 2;
94 }
95 if (i & 0x2) {
96 h += 1;
97 }
98 SRETURN(h);
99 }
100 EXPORT_SYMBOL(highbit);
101
102 #if BITS_PER_LONG == 32
103 /*
104 * Support 64/64 => 64 division on a 32-bit platform. While the kernel
105 * provides a div64_u64() function for this we do not use it because the
106 * implementation is flawed. There are cases which return incorrect
107 * results as late as linux-2.6.35. Until this is fixed upstream the
108 * spl must provide its own implementation.
109 *
110 * This implementation is a slightly modified version of the algorithm
111 * proposed by the book 'Hacker's Delight'. The original source can be
112 * found here and is available for use without restriction.
113 *
114 * http://www.hackersdelight.org/HDcode/newCode/divDouble.c
115 */
116
117 /*
118 * Calculate number of leading of zeros for a 64-bit value.
119 */
120 static int
121 nlz64(uint64_t x) {
122 register int n = 0;
123
124 if (x == 0)
125 return 64;
126
127 if (x <= 0x00000000FFFFFFFFULL) {n = n + 32; x = x << 32;}
128 if (x <= 0x0000FFFFFFFFFFFFULL) {n = n + 16; x = x << 16;}
129 if (x <= 0x00FFFFFFFFFFFFFFULL) {n = n + 8; x = x << 8;}
130 if (x <= 0x0FFFFFFFFFFFFFFFULL) {n = n + 4; x = x << 4;}
131 if (x <= 0x3FFFFFFFFFFFFFFFULL) {n = n + 2; x = x << 2;}
132 if (x <= 0x7FFFFFFFFFFFFFFFULL) {n = n + 1;}
133
134 return n;
135 }
136
137 /*
138 * Newer kernels have a div_u64() function but we define our own
139 * to simplify portibility between kernel versions.
140 */
141 static inline uint64_t
142 __div_u64(uint64_t u, uint32_t v)
143 {
144 (void) do_div(u, v);
145 return u;
146 }
147
148 /*
149 * Implementation of 64-bit unsigned division for 32-bit machines.
150 *
151 * First the procedure takes care of the case in which the divisor is a
152 * 32-bit quantity. There are two subcases: (1) If the left half of the
153 * dividend is less than the divisor, one execution of do_div() is all that
154 * is required (overflow is not possible). (2) Otherwise it does two
155 * divisions, using the grade school method.
156 */
157 uint64_t
158 __udivdi3(uint64_t u, uint64_t v)
159 {
160 uint64_t u0, u1, v1, q0, q1, k;
161 int n;
162
163 if (v >> 32 == 0) { // If v < 2**32:
164 if (u >> 32 < v) { // If u/v cannot overflow,
165 return __div_u64(u, v); // just do one division.
166 } else { // If u/v would overflow:
167 u1 = u >> 32; // Break u into two halves.
168 u0 = u & 0xFFFFFFFF;
169 q1 = __div_u64(u1, v); // First quotient digit.
170 k = u1 - q1 * v; // First remainder, < v.
171 u0 += (k << 32);
172 q0 = __div_u64(u0, v); // Seconds quotient digit.
173 return (q1 << 32) + q0;
174 }
175 } else { // If v >= 2**32:
176 n = nlz64(v); // 0 <= n <= 31.
177 v1 = (v << n) >> 32; // Normalize divisor, MSB is 1.
178 u1 = u >> 1; // To ensure no overflow.
179 q1 = __div_u64(u1, v1); // Get quotient from
180 q0 = (q1 << n) >> 31; // Undo normalization and
181 // division of u by 2.
182 if (q0 != 0) // Make q0 correct or
183 q0 = q0 - 1; // too small by 1.
184 if ((u - q0 * v) >= v)
185 q0 = q0 + 1; // Now q0 is correct.
186
187 return q0;
188 }
189 }
190 EXPORT_SYMBOL(__udivdi3);
191
192 /*
193 * Implementation of 64-bit signed division for 32-bit machines.
194 */
195 int64_t
196 __divdi3(int64_t u, int64_t v)
197 {
198 int64_t q, t;
199 q = __udivdi3(abs64(u), abs64(v));
200 t = (u ^ v) >> 63; // If u, v have different
201 return (q ^ t) - t; // signs, negate q.
202 }
203 EXPORT_SYMBOL(__divdi3);
204
205 /*
206 * Implementation of 64-bit unsigned modulo for 32-bit machines.
207 */
208 uint64_t
209 __umoddi3(uint64_t dividend, uint64_t divisor)
210 {
211 return (dividend - (divisor * __udivdi3(dividend, divisor)));
212 }
213 EXPORT_SYMBOL(__umoddi3);
214
215 #if defined(__arm) || defined(__arm__)
216 /*
217 * Implementation of 64-bit (un)signed division for 32-bit arm machines.
218 *
219 * Run-time ABI for the ARM Architecture (page 20). A pair of (unsigned)
220 * long longs is returned in {{r0, r1}, {r2,r3}}, the quotient in {r0, r1},
221 * and the remainder in {r2, r3}. The return type is specifically left
222 * set to 'void' to ensure the compiler does not overwrite these registers
223 * during the return. All results are in registers as per ABI
224 */
225 void
226 __aeabi_uldivmod(uint64_t u, uint64_t v)
227 {
228 uint64_t res;
229 uint64_t mod;
230
231 res = __udivdi3(u, v);
232 mod = __umoddi3(u, v);
233 {
234 register uint32_t r0 asm("r0") = (res & 0xFFFFFFFF);
235 register uint32_t r1 asm("r1") = (res >> 32);
236 register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF);
237 register uint32_t r3 asm("r3") = (mod >> 32);
238
239 asm volatile(""
240 : "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
241 : "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
242
243 return; /* r0; */
244 }
245 }
246 EXPORT_SYMBOL(__aeabi_uldivmod);
247
248 void
249 __aeabi_ldivmod(int64_t u, int64_t v)
250 {
251 int64_t res;
252 uint64_t mod;
253
254 res = __divdi3(u, v);
255 mod = __umoddi3(u, v);
256 {
257 register uint32_t r0 asm("r0") = (res & 0xFFFFFFFF);
258 register uint32_t r1 asm("r1") = (res >> 32);
259 register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF);
260 register uint32_t r3 asm("r3") = (mod >> 32);
261
262 asm volatile(""
263 : "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
264 : "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
265
266 return; /* r0; */
267 }
268 }
269 EXPORT_SYMBOL(__aeabi_ldivmod);
270 #endif /* __arm || __arm__ */
271 #endif /* BITS_PER_LONG */
272
273 /* NOTE: The strtoxx behavior is solely based on my reading of the Solaris
274 * ddi_strtol(9F) man page. I have not verified the behavior of these
275 * functions against their Solaris counterparts. It is possible that I
276 * may have misinterpreted the man page or the man page is incorrect.
277 */
278 int ddi_strtoul(const char *, char **, int, unsigned long *);
279 int ddi_strtol(const char *, char **, int, long *);
280 int ddi_strtoull(const char *, char **, int, unsigned long long *);
281 int ddi_strtoll(const char *, char **, int, long long *);
282
283 #define define_ddi_strtoux(type, valtype) \
284 int ddi_strtou##type(const char *str, char **endptr, \
285 int base, valtype *result) \
286 { \
287 valtype last_value, value = 0; \
288 char *ptr = (char *)str; \
289 int flag = 1, digit; \
290 \
291 if (strlen(ptr) == 0) \
292 return EINVAL; \
293 \
294 /* Auto-detect base based on prefix */ \
295 if (!base) { \
296 if (str[0] == '0') { \
297 if (tolower(str[1])=='x' && isxdigit(str[2])) { \
298 base = 16; /* hex */ \
299 ptr += 2; \
300 } else if (str[1] >= '0' && str[1] < 8) { \
301 base = 8; /* octal */ \
302 ptr += 1; \
303 } else { \
304 return EINVAL; \
305 } \
306 } else { \
307 base = 10; /* decimal */ \
308 } \
309 } \
310 \
311 while (1) { \
312 if (isdigit(*ptr)) \
313 digit = *ptr - '0'; \
314 else if (isalpha(*ptr)) \
315 digit = tolower(*ptr) - 'a' + 10; \
316 else \
317 break; \
318 \
319 if (digit >= base) \
320 break; \
321 \
322 last_value = value; \
323 value = value * base + digit; \
324 if (last_value > value) /* Overflow */ \
325 return ERANGE; \
326 \
327 flag = 1; \
328 ptr++; \
329 } \
330 \
331 if (flag) \
332 *result = value; \
333 \
334 if (endptr) \
335 *endptr = (char *)(flag ? ptr : str); \
336 \
337 return 0; \
338 } \
339
340 #define define_ddi_strtox(type, valtype) \
341 int ddi_strto##type(const char *str, char **endptr, \
342 int base, valtype *result) \
343 { \
344 int rc; \
345 \
346 if (*str == '-') { \
347 rc = ddi_strtou##type(str + 1, endptr, base, result); \
348 if (!rc) { \
349 if (*endptr == str + 1) \
350 *endptr = (char *)str; \
351 else \
352 *result = -*result; \
353 } \
354 } else { \
355 rc = ddi_strtou##type(str, endptr, base, result); \
356 } \
357 \
358 return rc; \
359 }
360
361 define_ddi_strtoux(l, unsigned long)
362 define_ddi_strtox(l, long)
363 define_ddi_strtoux(ll, unsigned long long)
364 define_ddi_strtox(ll, long long)
365
366 EXPORT_SYMBOL(ddi_strtoul);
367 EXPORT_SYMBOL(ddi_strtol);
368 EXPORT_SYMBOL(ddi_strtoll);
369 EXPORT_SYMBOL(ddi_strtoull);
370
371 int
372 ddi_copyin(const void *from, void *to, size_t len, int flags)
373 {
374 /* Fake ioctl() issued by kernel, 'from' is a kernel address */
375 if (flags & FKIOCTL) {
376 memcpy(to, from, len);
377 return 0;
378 }
379
380 return copyin(from, to, len);
381 }
382 EXPORT_SYMBOL(ddi_copyin);
383
384 int
385 ddi_copyout(const void *from, void *to, size_t len, int flags)
386 {
387 /* Fake ioctl() issued by kernel, 'from' is a kernel address */
388 if (flags & FKIOCTL) {
389 memcpy(to, from, len);
390 return 0;
391 }
392
393 return copyout(from, to, len);
394 }
395 EXPORT_SYMBOL(ddi_copyout);
396
397 #ifndef HAVE_PUT_TASK_STRUCT
398 /*
399 * This is only a stub function which should never be used. The SPL should
400 * never be putting away the last reference on a task structure so this will
401 * not be called. However, we still need to define it so the module does not
402 * have undefined symbol at load time. That all said if this impossible
403 * thing does somehow happen PANIC immediately so we know about it.
404 */
405 void
406 __put_task_struct(struct task_struct *t)
407 {
408 PANIC("Unexpectly put last reference on task %d\n", (int)t->pid);
409 }
410 EXPORT_SYMBOL(__put_task_struct);
411 #endif /* HAVE_PUT_TASK_STRUCT */
412
413 struct new_utsname *__utsname(void)
414 {
415 #ifdef HAVE_INIT_UTSNAME
416 return init_utsname();
417 #else
418 return &system_utsname;
419 #endif
420 }
421 EXPORT_SYMBOL(__utsname);
422
423
424 /*
425 * Read the unique system identifier from the /etc/hostid file.
426 *
427 * The behavior of /usr/bin/hostid on Linux systems with the
428 * regular eglibc and coreutils is:
429 *
430 * 1. Generate the value if the /etc/hostid file does not exist
431 * or if the /etc/hostid file is less than four bytes in size.
432 *
433 * 2. If the /etc/hostid file is at least 4 bytes, then return
434 * the first four bytes [0..3] in native endian order.
435 *
436 * 3. Always ignore bytes [4..] if they exist in the file.
437 *
438 * Only the first four bytes are significant, even on systems that
439 * have a 64-bit word size.
440 *
441 * See:
442 *
443 * eglibc: sysdeps/unix/sysv/linux/gethostid.c
444 * coreutils: src/hostid.c
445 *
446 * Notes:
447 *
448 * The /etc/hostid file on Solaris is a text file that often reads:
449 *
450 * # DO NOT EDIT
451 * "0123456789"
452 *
453 * Directly copying this file to Linux results in a constant
454 * hostid of 4f442023 because the default comment constitutes
455 * the first four bytes of the file.
456 *
457 */
458
459 char *spl_hostid_path = HW_HOSTID_PATH;
460 module_param(spl_hostid_path, charp, 0444);
461 MODULE_PARM_DESC(spl_hostid_path, "The system hostid file (/etc/hostid)");
462
463 static int
464 hostid_read(void)
465 {
466 int result;
467 uint64_t size;
468 struct _buf *file;
469 unsigned long hostid = 0;
470
471 file = kobj_open_file(spl_hostid_path);
472
473 if (file == (struct _buf *)-1)
474 return -1;
475
476 result = kobj_get_filesize(file, &size);
477
478 if (result != 0) {
479 printk(KERN_WARNING
480 "SPL: kobj_get_filesize returned %i on %s\n",
481 result, spl_hostid_path);
482 kobj_close_file(file);
483 return -2;
484 }
485
486 if (size < sizeof(HW_HOSTID_MASK)) {
487 printk(KERN_WARNING
488 "SPL: Ignoring the %s file because it is %llu bytes; "
489 "expecting %lu bytes instead.\n",
490 spl_hostid_path, size, sizeof(HW_HOSTID_MASK));
491 kobj_close_file(file);
492 return -3;
493 }
494
495 /* Read directly into the variable like eglibc does. */
496 /* Short reads are okay; native behavior is preserved. */
497 result = kobj_read_file(file, (char *)&hostid, sizeof(hostid), 0);
498
499 if (result < 0) {
500 printk(KERN_WARNING
501 "SPL: kobj_read_file returned %i on %s\n",
502 result, spl_hostid_path);
503 kobj_close_file(file);
504 return -4;
505 }
506
507 /* Mask down to 32 bits like coreutils does. */
508 spl_hostid = hostid & HW_HOSTID_MASK;
509 kobj_close_file(file);
510 return 0;
511 }
512
513 #define GET_HOSTID_CMD \
514 "exec 0</dev/null " \
515 " 1>/proc/sys/kernel/spl/hostid " \
516 " 2>/dev/null; " \
517 "hostid"
518
519 static int
520 hostid_exec(void)
521 {
522 char *argv[] = { "/bin/sh",
523 "-c",
524 GET_HOSTID_CMD,
525 NULL };
526 char *envp[] = { "HOME=/",
527 "TERM=linux",
528 "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
529 NULL };
530 int rc;
531
532 /* Doing address resolution in the kernel is tricky and just
533 * not a good idea in general. So to set the proper 'hw_serial'
534 * use the usermodehelper support to ask '/bin/sh' to run
535 * '/usr/bin/hostid' and redirect the result to /proc/sys/spl/hostid
536 * for us to use. It's a horrific solution but it will do for now.
537 */
538 rc = call_usermodehelper(argv[0], argv, envp, 1);
539 if (rc)
540 printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
541 argv[0], argv[1], argv[2], rc);
542
543 return rc;
544 }
545
546 uint32_t
547 zone_get_hostid(void *zone)
548 {
549 unsigned long hostid;
550
551 /* Only the global zone is supported */
552 ASSERT(zone == NULL);
553
554 if (ddi_strtoul(hw_serial, NULL, HW_HOSTID_LEN-1, &hostid) != 0)
555 return HW_INVALID_HOSTID;
556
557 return (uint32_t)hostid;
558 }
559 EXPORT_SYMBOL(zone_get_hostid);
560
561 #ifndef HAVE_KALLSYMS_LOOKUP_NAME
562 /*
563 * The kallsyms_lookup_name() kernel function is not an exported symbol in
564 * Linux 2.6.19 through 2.6.32 inclusive.
565 *
566 * This function replaces the functionality by performing an upcall to user
567 * space where /proc/kallsyms is consulted for the requested address.
568 *
569 */
570
571 #define GET_KALLSYMS_ADDR_CMD \
572 "exec 0</dev/null " \
573 " 1>/proc/sys/kernel/spl/kallsyms_lookup_name " \
574 " 2>/dev/null; " \
575 "awk '{ if ( $3 == \"kallsyms_lookup_name\" ) { print $1 } }' " \
576 " /proc/kallsyms "
577
578 static int
579 set_kallsyms_lookup_name(void)
580 {
581 char *argv[] = { "/bin/sh",
582 "-c",
583 GET_KALLSYMS_ADDR_CMD,
584 NULL };
585 char *envp[] = { "HOME=/",
586 "TERM=linux",
587 "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
588 NULL };
589 int rc;
590
591 rc = call_usermodehelper(argv[0], argv, envp, 1);
592 if (rc)
593 printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
594 argv[0], argv[1], argv[2], rc);
595
596 return rc;
597 }
598 #endif
599
600 static int
601 __init spl_init(void)
602 {
603 int rc = 0;
604
605 if ((rc = spl_debug_init()))
606 return rc;
607
608 if ((rc = spl_kmem_init()))
609 SGOTO(out1, rc);
610
611 if ((rc = spl_mutex_init()))
612 SGOTO(out2, rc);
613
614 if ((rc = spl_rw_init()))
615 SGOTO(out3, rc);
616
617 if ((rc = spl_taskq_init()))
618 SGOTO(out4, rc);
619
620 if ((rc = spl_vn_init()))
621 SGOTO(out5, rc);
622
623 if ((rc = spl_proc_init()))
624 SGOTO(out6, rc);
625
626 if ((rc = spl_kstat_init()))
627 SGOTO(out7, rc);
628
629 if ((rc = spl_tsd_init()))
630 SGOTO(out8, rc);
631
632 if ((rc = spl_zlib_init()))
633 SGOTO(out9, rc);
634
635 /*
636 * Get the hostid if it was not passed as a module parameter. Try
637 * reading the /etc/hostid file directly, and then fall back to calling
638 * the /usr/bin/hostid utility.
639 */
640
641 if (spl_hostid == HW_INVALID_HOSTID
642 && (rc = hostid_read()) && (rc = hostid_exec()))
643 SGOTO(out10, rc = -EADDRNOTAVAIL);
644
645 #ifndef HAVE_KALLSYMS_LOOKUP_NAME
646 if ((rc = set_kallsyms_lookup_name()))
647 SGOTO(out10, rc = -EADDRNOTAVAIL);
648 #endif /* HAVE_KALLSYMS_LOOKUP_NAME */
649
650 if ((rc = spl_kmem_init_kallsyms_lookup()))
651 SGOTO(out10, rc);
652
653 if ((rc = spl_vn_init_kallsyms_lookup()))
654 SGOTO(out10, rc);
655
656 printk(KERN_NOTICE "SPL: Loaded module v%s-%s%s, using hostid "
657 "0x%08x\n", SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR,
658 (unsigned int) spl_hostid);
659 SRETURN(rc);
660 out10:
661 spl_zlib_fini();
662 out9:
663 spl_tsd_fini();
664 out8:
665 spl_kstat_fini();
666 out7:
667 spl_proc_fini();
668 out6:
669 spl_vn_fini();
670 out5:
671 spl_taskq_fini();
672 out4:
673 spl_rw_fini();
674 out3:
675 spl_mutex_fini();
676 out2:
677 spl_kmem_fini();
678 out1:
679 spl_debug_fini();
680
681 printk(KERN_NOTICE "SPL: Failed to Load Solaris Porting Layer "
682 "v%s-%s%s, rc = %d\n", SPL_META_VERSION, SPL_META_RELEASE,
683 SPL_DEBUG_STR, rc);
684 return rc;
685 }
686
687 static void
688 spl_fini(void)
689 {
690 SENTRY;
691
692 printk(KERN_NOTICE "SPL: Unloaded module v%s-%s%s\n",
693 SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR);
694 spl_zlib_fini();
695 spl_tsd_fini();
696 spl_kstat_fini();
697 spl_proc_fini();
698 spl_vn_fini();
699 spl_taskq_fini();
700 spl_rw_fini();
701 spl_mutex_fini();
702 spl_kmem_fini();
703 spl_debug_fini();
704 }
705
706 /* Called when a dependent module is loaded */
707 void
708 spl_setup(void)
709 {
710 int rc;
711
712 /*
713 * At module load time the pwd is set to '/' on a Solaris system.
714 * On a Linux system will be set to whatever directory the caller
715 * was in when executing insmod/modprobe.
716 */
717 rc = vn_set_pwd("/");
718 if (rc)
719 printk("SPL: Warning unable to set pwd to '/': %d\n", rc);
720 }
721 EXPORT_SYMBOL(spl_setup);
722
723 /* Called when a dependent module is unloaded */
724 void
725 spl_cleanup(void)
726 {
727 }
728 EXPORT_SYMBOL(spl_cleanup);
729
730 module_init(spl_init);
731 module_exit(spl_fini);
732
733 MODULE_AUTHOR("Lawrence Livermore National Labs");
734 MODULE_DESCRIPTION("Solaris Porting Layer");
735 MODULE_LICENSE("GPL");