equal
deleted
inserted
replaced
35 #include <sys/spa.h> |
35 #include <sys/spa.h> |
36 #include <sys/stat.h> |
36 #include <sys/stat.h> |
37 #include <sys/processor.h> |
37 #include <sys/processor.h> |
38 #include <sys/zfs_context.h> |
38 #include <sys/zfs_context.h> |
39 #include <sys/zmod.h> |
39 #include <sys/zmod.h> |
|
40 #include <sys/utsname.h> |
40 |
41 |
41 /* |
42 /* |
42 * Emulation of kernel services in userland. |
43 * Emulation of kernel services in userland. |
43 */ |
44 */ |
44 |
45 |
45 uint64_t physmem; |
46 uint64_t physmem; |
46 vnode_t *rootdir = (vnode_t *)0xabcd1234; |
47 vnode_t *rootdir = (vnode_t *)0xabcd1234; |
|
48 char hw_serial[11]; |
|
49 |
|
50 struct utsname utsname = { |
|
51 "userland", "libzpool", "1", "1", "na" |
|
52 }; |
47 |
53 |
48 /* |
54 /* |
49 * ========================================================================= |
55 * ========================================================================= |
50 * threads |
56 * threads |
51 * ========================================================================= |
57 * ========================================================================= |
721 random_get_pseudo_bytes(uint8_t *ptr, size_t len) |
727 random_get_pseudo_bytes(uint8_t *ptr, size_t len) |
722 { |
728 { |
723 return (random_get_bytes_common(ptr, len, "/dev/urandom")); |
729 return (random_get_bytes_common(ptr, len, "/dev/urandom")); |
724 } |
730 } |
725 |
731 |
|
732 int |
|
733 ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result) |
|
734 { |
|
735 char *end; |
|
736 |
|
737 *result = strtoul(hw_serial, &end, base); |
|
738 if (*result == 0) |
|
739 return (errno); |
|
740 return (0); |
|
741 } |
|
742 |
726 /* |
743 /* |
727 * ========================================================================= |
744 * ========================================================================= |
728 * kernel emulation setup & teardown |
745 * kernel emulation setup & teardown |
729 * ========================================================================= |
746 * ========================================================================= |
730 */ |
747 */ |
746 physmem = sysconf(_SC_PHYS_PAGES); |
763 physmem = sysconf(_SC_PHYS_PAGES); |
747 |
764 |
748 dprintf("physmem = %llu pages (%.2f GB)\n", physmem, |
765 dprintf("physmem = %llu pages (%.2f GB)\n", physmem, |
749 (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30)); |
766 (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30)); |
750 |
767 |
|
768 snprintf(hw_serial, sizeof (hw_serial), "%ld", gethostid()); |
|
769 |
751 spa_init(mode); |
770 spa_init(mode); |
752 } |
771 } |
753 |
772 |
754 void |
773 void |
755 kernel_fini(void) |
774 kernel_fini(void) |