4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
32 #include <sys/signal.h>
35 #include <sys/processor.h>
36 #include <sys/zfs_context.h>
37 #include <sys/utsname.h>
39 #include <sys/mount.h> /* for BLKGETSIZE64 */
40 #include <sys/systeminfo.h>
43 * Emulation of kernel services in userland.
48 vnode_t *rootdir = (vnode_t *)0xabcd1234;
49 char hw_serial[HW_HOSTID_LEN];
51 struct utsname utsname = {
52 "userland", "libzpool", "1", "1", "na"
55 /* this only exists to have its address taken */
59 * =========================================================================
61 * =========================================================================
64 pthread_cond_t kthread_cond = PTHREAD_COND_INITIALIZER;
65 pthread_mutex_t kthread_lock = PTHREAD_MUTEX_INITIALIZER;
66 pthread_key_t kthread_key;
74 VERIFY3S(pthread_key_create(&kthread_key, NULL), ==, 0);
76 /* Create entry for primary kthread */
77 kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL);
78 kt->t_tid = pthread_self();
81 VERIFY3S(pthread_setspecific(kthread_key, kt), ==, 0);
83 /* Only the main thread should be running at the moment */
84 ASSERT3S(kthread_nr, ==, 0);
91 kthread_t *kt = curthread;
93 ASSERT(pthread_equal(kt->t_tid, pthread_self()));
94 ASSERT3P(kt->t_func, ==, NULL);
96 umem_free(kt, sizeof(kthread_t));
98 /* Wait for all threads to exit via thread_exit() */
99 VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0);
101 kthread_nr--; /* Main thread is exiting */
103 while (kthread_nr > 0)
104 VERIFY3S(pthread_cond_wait(&kthread_cond, &kthread_lock), ==,
107 ASSERT3S(kthread_nr, ==, 0);
108 VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0);
110 VERIFY3S(pthread_key_delete(kthread_key), ==, 0);
114 zk_thread_current(void)
116 kthread_t *kt = pthread_getspecific(kthread_key);
118 ASSERT3P(kt, !=, NULL);
124 zk_thread_helper(void *arg)
126 kthread_t *kt = (kthread_t *) arg;
128 VERIFY3S(pthread_setspecific(kthread_key, kt), ==, 0);
130 VERIFY3S(pthread_mutex_lock(&kthread_lock), ==, 0);
132 VERIFY3S(pthread_mutex_unlock(&kthread_lock), ==, 0);
134 kt->t_tid = pthread_self();
135 ((thread_func_arg_t) kt->t_func)(kt->t_arg);
137 /* Unreachable, thread must exit with thread_exit() */
144 zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg,
145 size_t len, proc_t *pp, int state, pri_t pri)
151 ASSERT3S(state & ~TS_RUN, ==, 0);
153 kt = umem_zalloc(sizeof(kthread_t), UMEM_NOFAIL);
158 * The Solaris kernel stack size is 24k for x86/x86_64.
159 * The Linux kernel stack size is 8k for x86/x86_64.
161 * We reduce the default stack size in userspace, to ensure
162 * we observe stack overruns in user space as well as in
163 * kernel space. PTHREAD_STACK_MIN is the minimum stack
164 * required for a NULL procedure in user space and is added
165 * in to the stack requirements.
167 * Some buggy NPTL threading implementations include the
168 * guard area within the stack size allocations. In
169 * this case we allocate an extra page to account for the
170 * guard area since we only have two pages of usable stack
174 stack = PTHREAD_STACK_MIN + MAX(stksize, STACK_SIZE) +
177 VERIFY3S(pthread_attr_init(&attr), ==, 0);
178 VERIFY3S(pthread_attr_setstacksize(&attr, stack), ==, 0);
179 VERIFY3S(pthread_attr_setguardsize(&attr, PAGESIZE), ==, 0);
181 VERIFY3S(pthread_create(&kt->t_tid, &attr, &zk_thread_helper, kt),
184 VERIFY3S(pthread_attr_destroy(&attr), ==, 0);
192 kthread_t *kt = curthread;
194 ASSERT(pthread_equal(kt->t_tid, pthread_self()));
196 umem_free(kt, sizeof(kthread_t));
198 pthread_mutex_lock(&kthread_lock);
200 pthread_mutex_unlock(&kthread_lock);
202 pthread_cond_broadcast(&kthread_cond);
203 pthread_exit((void *)TS_MAGIC);
207 zk_thread_join(kt_did_t tid)
211 pthread_join((pthread_t)tid, &ret);
212 VERIFY3P(ret, ==, (void *)TS_MAGIC);
216 * =========================================================================
218 * =========================================================================
222 kstat_create(char *module, int instance, char *name, char *class,
223 uchar_t type, ulong_t ndata, uchar_t ks_flag)
230 kstat_install(kstat_t *ksp)
235 kstat_delete(kstat_t *ksp)
239 * =========================================================================
241 * =========================================================================
245 mutex_init(kmutex_t *mp, char *name, int type, void *cookie)
247 ASSERT3S(type, ==, MUTEX_DEFAULT);
248 ASSERT3P(cookie, ==, NULL);
249 mp->m_owner = MTX_INIT;
250 mp->m_magic = MTX_MAGIC;
251 VERIFY3S(pthread_mutex_init(&mp->m_lock, NULL), ==, 0);
255 mutex_destroy(kmutex_t *mp)
257 ASSERT3U(mp->m_magic, ==, MTX_MAGIC);
258 ASSERT3P(mp->m_owner, ==, MTX_INIT);
259 VERIFY3S(pthread_mutex_destroy(&(mp)->m_lock), ==, 0);
260 mp->m_owner = MTX_DEST;
265 mutex_enter(kmutex_t *mp)
267 ASSERT3U(mp->m_magic, ==, MTX_MAGIC);
268 ASSERT3P(mp->m_owner, !=, MTX_DEST);
269 ASSERT3P(mp->m_owner, !=, curthread);
270 VERIFY3S(pthread_mutex_lock(&mp->m_lock), ==, 0);
271 ASSERT3P(mp->m_owner, ==, MTX_INIT);
272 mp->m_owner = curthread;
276 mutex_tryenter(kmutex_t *mp)
278 ASSERT3U(mp->m_magic, ==, MTX_MAGIC);
279 ASSERT3P(mp->m_owner, !=, MTX_DEST);
280 if (0 == pthread_mutex_trylock(&mp->m_lock)) {
281 ASSERT3P(mp->m_owner, ==, MTX_INIT);
282 mp->m_owner = curthread;
290 mutex_exit(kmutex_t *mp)
292 ASSERT3U(mp->m_magic, ==, MTX_MAGIC);
293 ASSERT3P(mutex_owner(mp), ==, curthread);
294 mp->m_owner = MTX_INIT;
295 VERIFY3S(pthread_mutex_unlock(&mp->m_lock), ==, 0);
299 mutex_owner(kmutex_t *mp)
301 ASSERT3U(mp->m_magic, ==, MTX_MAGIC);
302 return (mp->m_owner);
306 mutex_held(kmutex_t *mp)
308 return (mp->m_owner == curthread);
312 * =========================================================================
314 * =========================================================================
318 rw_init(krwlock_t *rwlp, char *name, int type, void *arg)
320 ASSERT3S(type, ==, RW_DEFAULT);
321 ASSERT3P(arg, ==, NULL);
322 VERIFY3S(pthread_rwlock_init(&rwlp->rw_lock, NULL), ==, 0);
323 rwlp->rw_owner = RW_INIT;
324 rwlp->rw_wr_owner = RW_INIT;
325 rwlp->rw_readers = 0;
326 rwlp->rw_magic = RW_MAGIC;
330 rw_destroy(krwlock_t *rwlp)
332 ASSERT3U(rwlp->rw_magic, ==, RW_MAGIC);
334 VERIFY3S(pthread_rwlock_destroy(&rwlp->rw_lock), ==, 0);
339 rw_enter(krwlock_t *rwlp, krw_t rw)
341 ASSERT3U(rwlp->rw_magic, ==, RW_MAGIC);
342 ASSERT3P(rwlp->rw_owner, !=, curthread);
343 ASSERT3P(rwlp->rw_wr_owner, !=, curthread);
345 if (rw == RW_READER) {
346 VERIFY3S(pthread_rwlock_rdlock(&rwlp->rw_lock), ==, 0);
347 ASSERT3P(rwlp->rw_wr_owner, ==, RW_INIT);
349 atomic_inc_uint(&rwlp->rw_readers);
351 VERIFY3S(pthread_rwlock_wrlock(&rwlp->rw_lock), ==, 0);
352 ASSERT3P(rwlp->rw_wr_owner, ==, RW_INIT);
353 ASSERT3U(rwlp->rw_readers, ==, 0);
355 rwlp->rw_wr_owner = curthread;
358 rwlp->rw_owner = curthread;
362 rw_exit(krwlock_t *rwlp)
364 ASSERT3U(rwlp->rw_magic, ==, RW_MAGIC);
365 ASSERT(RW_LOCK_HELD(rwlp));
367 if (RW_READ_HELD(rwlp))
368 atomic_dec_uint(&rwlp->rw_readers);
370 rwlp->rw_wr_owner = RW_INIT;
372 rwlp->rw_owner = RW_INIT;
373 VERIFY3S(pthread_rwlock_unlock(&rwlp->rw_lock), ==, 0);
377 rw_tryenter(krwlock_t *rwlp, krw_t rw)
381 ASSERT3U(rwlp->rw_magic, ==, RW_MAGIC);
384 rv = pthread_rwlock_tryrdlock(&rwlp->rw_lock);
386 rv = pthread_rwlock_trywrlock(&rwlp->rw_lock);
389 ASSERT3P(rwlp->rw_wr_owner, ==, RW_INIT);
392 atomic_inc_uint(&rwlp->rw_readers);
394 ASSERT3U(rwlp->rw_readers, ==, 0);
395 rwlp->rw_wr_owner = curthread;
398 rwlp->rw_owner = curthread;
402 VERIFY3S(rv, ==, EBUSY);
408 rw_tryupgrade(krwlock_t *rwlp)
410 ASSERT3U(rwlp->rw_magic, ==, RW_MAGIC);
416 * =========================================================================
417 * condition variables
418 * =========================================================================
422 cv_init(kcondvar_t *cv, char *name, int type, void *arg)
424 ASSERT3S(type, ==, CV_DEFAULT);
425 cv->cv_magic = CV_MAGIC;
426 VERIFY3S(pthread_cond_init(&cv->cv, NULL), ==, 0);
430 cv_destroy(kcondvar_t *cv)
432 ASSERT3U(cv->cv_magic, ==, CV_MAGIC);
433 VERIFY3S(pthread_cond_destroy(&cv->cv), ==, 0);
438 cv_wait(kcondvar_t *cv, kmutex_t *mp)
440 ASSERT3U(cv->cv_magic, ==, CV_MAGIC);
441 ASSERT3P(mutex_owner(mp), ==, curthread);
442 mp->m_owner = MTX_INIT;
443 int ret = pthread_cond_wait(&cv->cv, &mp->m_lock);
445 VERIFY3S(ret, ==, EINTR);
446 mp->m_owner = curthread;
450 cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
457 ASSERT3U(cv->cv_magic, ==, CV_MAGIC);
460 delta = abstime - ddi_get_lbolt();
464 VERIFY(gettimeofday(&tv, NULL) == 0);
466 ts.tv_sec = tv.tv_sec + delta / hz;
467 ts.tv_nsec = tv.tv_usec * 1000 + (delta % hz) * (NANOSEC / hz);
468 if (ts.tv_nsec >= NANOSEC) {
470 ts.tv_nsec -= NANOSEC;
473 ASSERT3P(mutex_owner(mp), ==, curthread);
474 mp->m_owner = MTX_INIT;
475 error = pthread_cond_timedwait(&cv->cv, &mp->m_lock, &ts);
476 mp->m_owner = curthread;
478 if (error == ETIMEDOUT)
484 VERIFY3S(error, ==, 0);
490 cv_signal(kcondvar_t *cv)
492 ASSERT3U(cv->cv_magic, ==, CV_MAGIC);
493 VERIFY3S(pthread_cond_signal(&cv->cv), ==, 0);
497 cv_broadcast(kcondvar_t *cv)
499 ASSERT3U(cv->cv_magic, ==, CV_MAGIC);
500 VERIFY3S(pthread_cond_broadcast(&cv->cv), ==, 0);
504 * =========================================================================
506 * =========================================================================
509 * Note: for the xxxat() versions of these functions, we assume that the
510 * starting vp is always rootdir (which is true for spa_directory.c, the only
511 * ZFS consumer of these interfaces). We assert this is true, and then emulate
512 * them by adding '/' in front of the path.
517 vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3)
526 realpath = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
529 * If we're accessing a real disk from userland, we need to use
530 * the character interface to avoid caching. This is particularly
531 * important if we're trying to look at a real in-kernel storage
532 * pool from userland, e.g. via zdb, because otherwise we won't
533 * see the changes occurring under the segmap cache.
534 * On the other hand, the stupid character device returns zero
535 * for its size. So -- gag -- we open the block device to get
536 * its size, and remember it for subsequent VOP_GETATTR().
538 #if defined(__sun__) || defined(__sun)
539 if (strncmp(path, "/dev/", 5) == 0) {
544 fd = open64(path, O_RDONLY);
550 if (fstat64(fd, &st) == -1) {
557 (void) sprintf(realpath, "%s", path);
558 dsk = strstr(path, "/dsk/");
560 (void) sprintf(realpath + (dsk - path) + 1, "r%s",
563 (void) sprintf(realpath, "%s", path);
564 if (!(flags & FCREAT) && stat64(realpath, &st) == -1) {
571 if (!(flags & FCREAT) && S_ISBLK(st.st_mode)) {
575 /* We shouldn't be writing to block devices in userspace */
576 VERIFY(!(flags & FWRITE));
580 old_umask = umask(0);
583 * The construct 'flags - FREAD' conveniently maps combinations of
584 * FREAD and FWRITE to the corresponding O_RDONLY, O_WRONLY, and O_RDWR.
586 fd = open64(realpath, flags - FREAD, mode);
590 (void) umask(old_umask);
595 if (fstat64(fd, &st) == -1) {
602 /* In Linux, use an ioctl to get the size of a block device. */
603 if (S_ISBLK(st.st_mode)) {
604 if (ioctl(fd, BLKGETSIZE64, &st.st_size) != 0) {
611 (void) fcntl(fd, F_SETFD, FD_CLOEXEC);
613 *vpp = vp = umem_zalloc(sizeof (vnode_t), UMEM_NOFAIL);
616 vp->v_size = st.st_size;
617 vp->v_path = spa_strdup(path);
624 vn_openat(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2,
625 int x3, vnode_t *startvp, int fd)
627 char *realpath = umem_alloc(strlen(path) + 2, UMEM_NOFAIL);
630 ASSERT(startvp == rootdir);
631 (void) sprintf(realpath, "/%s", path);
633 /* fd ignored for now, need if want to simulate nbmand support */
634 ret = vn_open(realpath, x1, flags, mode, vpp, x2, x3);
636 umem_free(realpath, strlen(path) + 2);
643 vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
644 int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp)
646 ssize_t rc, done = 0, split;
648 if (uio == UIO_READ) {
649 rc = pread64(vp->v_fd, addr, len, offset);
652 * To simulate partial disk writes, we split writes into two
653 * system calls so that the process can be killed in between.
655 split = (len > 0 ? rand() % len : 0);
656 rc = pwrite64(vp->v_fd, addr, split, offset);
659 rc = pwrite64(vp->v_fd, (char *)addr + split,
660 len - split, offset + split);
665 if (rc == -1 && errno == EINVAL) {
667 * Under Linux, this most likely means an alignment issue
668 * (memory or disk) due to O_DIRECT, so we abort() in order to
669 * catch the offender.
680 *residp = len - done;
681 else if (done != len)
687 vn_close(vnode_t *vp)
690 spa_strfree(vp->v_path);
691 umem_free(vp, sizeof (vnode_t));
695 * At a minimum we need to update the size since vdev_reopen()
696 * will no longer call vn_openat().
699 fop_getattr(vnode_t *vp, vattr_t *vap)
703 if (fstat64(vp->v_fd, &st) == -1) {
708 vap->va_size = st.st_size;
715 * =========================================================================
716 * Figure out which debugging statements to print
717 * =========================================================================
720 static char *dprintf_string;
721 static int dprintf_print_all;
724 dprintf_find_string(const char *string)
726 char *tmp_str = dprintf_string;
727 int len = strlen(string);
730 * Find out if this is a string we want to print.
731 * String format: file1.c,function_name1,file2.c,file3.c
734 while (tmp_str != NULL) {
735 if (strncmp(tmp_str, string, len) == 0 &&
736 (tmp_str[len] == ',' || tmp_str[len] == '\0'))
738 tmp_str = strchr(tmp_str, ',');
740 tmp_str++; /* Get rid of , */
746 dprintf_setup(int *argc, char **argv)
751 * Debugging can be specified two ways: by setting the
752 * environment variable ZFS_DEBUG, or by including a
753 * "debug=..." argument on the command line. The command
754 * line setting overrides the environment variable.
757 for (i = 1; i < *argc; i++) {
758 int len = strlen("debug=");
759 /* First look for a command line argument */
760 if (strncmp("debug=", argv[i], len) == 0) {
761 dprintf_string = argv[i] + len;
762 /* Remove from args */
763 for (j = i; j < *argc; j++)
770 if (dprintf_string == NULL) {
771 /* Look for ZFS_DEBUG environment variable */
772 dprintf_string = getenv("ZFS_DEBUG");
776 * Are we just turning on all debugging?
778 if (dprintf_find_string("on"))
779 dprintf_print_all = 1;
783 * =========================================================================
785 * =========================================================================
788 __dprintf(const char *file, const char *func, int line, const char *fmt, ...)
794 * Get rid of annoying "../common/" prefix to filename.
796 newfile = strrchr(file, '/');
797 if (newfile != NULL) {
798 newfile = newfile + 1; /* Get rid of leading / */
803 if (dprintf_print_all ||
804 dprintf_find_string(newfile) ||
805 dprintf_find_string(func)) {
806 /* Print out just the function name if requested */
808 if (dprintf_find_string("pid"))
809 (void) printf("%d ", getpid());
810 if (dprintf_find_string("tid"))
811 (void) printf("%u ", (uint_t) pthread_self());
812 if (dprintf_find_string("cpu"))
813 (void) printf("%u ", getcpuid());
814 if (dprintf_find_string("time"))
815 (void) printf("%llu ", gethrtime());
816 if (dprintf_find_string("long"))
817 (void) printf("%s, line %d: ", newfile, line);
818 (void) printf("%s: ", func);
820 (void) vprintf(fmt, adx);
826 #endif /* ZFS_DEBUG */
829 * =========================================================================
830 * cmn_err() and panic()
831 * =========================================================================
833 static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" };
834 static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
837 vpanic(const char *fmt, va_list adx)
839 (void) fprintf(stderr, "error: ");
840 (void) vfprintf(stderr, fmt, adx);
841 (void) fprintf(stderr, "\n");
843 abort(); /* think of it as a "user-level crash dump" */
847 panic(const char *fmt, ...)
857 vcmn_err(int ce, const char *fmt, va_list adx)
861 if (ce != CE_NOTE) { /* suppress noise in userland stress testing */
862 (void) fprintf(stderr, "%s", ce_prefix[ce]);
863 (void) vfprintf(stderr, fmt, adx);
864 (void) fprintf(stderr, "%s", ce_suffix[ce]);
870 cmn_err(int ce, const char *fmt, ...)
875 vcmn_err(ce, fmt, adx);
880 * =========================================================================
882 * =========================================================================
885 kobj_open_file(char *name)
890 /* set vp as the _fd field of the file */
891 if (vn_openat(name, UIO_SYSSPACE, FREAD, 0, &vp, 0, 0, rootdir,
893 return ((void *)-1UL);
895 file = umem_zalloc(sizeof (struct _buf), UMEM_NOFAIL);
896 file->_fd = (intptr_t)vp;
901 kobj_read_file(struct _buf *file, char *buf, unsigned size, unsigned off)
905 vn_rdwr(UIO_READ, (vnode_t *)file->_fd, buf, size, (offset_t)off,
906 UIO_SYSSPACE, 0, 0, 0, &resid);
908 return (size - resid);
912 kobj_close_file(struct _buf *file)
914 vn_close((vnode_t *)file->_fd);
915 umem_free(file, sizeof (struct _buf));
919 kobj_get_filesize(struct _buf *file, uint64_t *size)
922 vnode_t *vp = (vnode_t *)file->_fd;
924 if (fstat64(vp->v_fd, &st) == -1) {
933 * =========================================================================
935 * =========================================================================
941 poll(0, 0, ticks * (1000 / hz));
945 * Find highest one bit set.
946 * Returns bit number + 1 of highest bit that is set, otherwise returns 0.
947 * High order bit is 31 (or 63 in _LP64 kernel).
957 if (i & 0xffffffff00000000ul) {
961 if (i & 0xffff0000) {
979 static int random_fd = -1, urandom_fd = -1;
982 random_get_bytes_common(uint8_t *ptr, size_t len, int fd)
990 bytes = read(fd, ptr, resid);
991 ASSERT3S(bytes, >=, 0);
1000 random_get_bytes(uint8_t *ptr, size_t len)
1002 return (random_get_bytes_common(ptr, len, random_fd));
1006 random_get_pseudo_bytes(uint8_t *ptr, size_t len)
1008 return (random_get_bytes_common(ptr, len, urandom_fd));
1012 ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result)
1016 *result = strtoul(hw_serial, &end, base);
1023 ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result)
1027 *result = strtoull(str, &end, base);
1034 * =========================================================================
1035 * kernel emulation setup & teardown
1036 * =========================================================================
1039 umem_out_of_memory(void)
1041 char errmsg[] = "out of memory -- generating core dump\n";
1043 (void) fprintf(stderr, "%s", errmsg);
1049 kernel_init(int mode)
1051 umem_nofail_callback(umem_out_of_memory);
1053 physmem = sysconf(_SC_PHYS_PAGES);
1055 dprintf("physmem = %llu pages (%.2f GB)\n", physmem,
1056 (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30));
1058 (void) snprintf(hw_serial, sizeof (hw_serial), "%ld",
1059 (mode & FWRITE) ? gethostid() : 0);
1061 VERIFY((random_fd = open("/dev/random", O_RDONLY)) != -1);
1062 VERIFY((urandom_fd = open("/dev/urandom", O_RDONLY)) != -1);
1065 system_taskq_init();
1075 system_taskq_fini();
1086 crgetuid(cred_t *cr)
1092 crgetgid(cred_t *cr)
1098 crgetngroups(cred_t *cr)
1104 crgetgroups(cred_t *cr)
1110 zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr)
1116 zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr)
1122 zfs_secpolicy_destroy_perms(const char *name, cred_t *cr)
1128 ksid_lookupdomain(const char *dom)
1132 kd = umem_zalloc(sizeof (ksiddomain_t), UMEM_NOFAIL);
1133 kd->kd_name = spa_strdup(dom);
1138 ksiddomain_rele(ksiddomain_t *ksid)
1140 spa_strfree(ksid->kd_name);
1141 umem_free(ksid, sizeof (ksiddomain_t));
1145 kmem_vasprintf(const char *fmt, va_list adx)
1150 va_copy(adx_copy, adx);
1151 VERIFY(vasprintf(&buf, fmt, adx_copy) != -1);
1158 kmem_asprintf(const char *fmt, ...)
1164 VERIFY(vasprintf(&buf, fmt, adx) != -1);
1172 zfs_onexit_fd_hold(int fd, minor_t *minorp)
1180 zfs_onexit_fd_rele(int fd)
1186 zfs_onexit_add_cb(minor_t minor, void (*func)(void *), void *data,
1187 uint64_t *action_handle)
1194 zfs_onexit_del_cb(minor_t minor, uint64_t action_handle, boolean_t fire)
1201 zfs_onexit_cb_data(minor_t minor, uint64_t action_handle, void **data)