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 https://opensource.org/licenses/CDDL-1.0.
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.
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
25 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
28 #ifndef _SYS_ZFS_CONTEXT_H
29 #define _SYS_ZFS_CONTEXT_H
36 * This code compiles in three different contexts. When __KERNEL__ is defined,
37 * the code uses "unix-like" kernel interfaces. When _STANDALONE is defined, the
38 * code is running in a reduced capacity environment of the boot loader which is
39 * generally a subset of both POSIX and kernel interfaces (with a few unique
40 * interfaces too). When neither are defined, it's in a userland POSIX or
41 * similar environment.
43 #if defined(__KERNEL__) || defined(_STANDALONE)
44 #include <sys/types.h>
45 #include <sys/atomic.h>
46 #include <sys/sysmacros.h>
47 #include <sys/vmsystm.h>
48 #include <sys/condvar.h>
49 #include <sys/cmn_err.h>
51 #include <sys/kmem_cache.h>
54 #include <sys/taskq.h>
55 #include <sys/param.h>
57 #include <sys/debug.h>
58 #include <sys/random.h>
59 #include <sys/string.h>
60 #include <sys/byteorder.h>
64 #include <sys/kstat.h>
65 #include <sys/zfs_debug.h>
66 #include <sys/sysevent.h>
67 #include <sys/sysevent/eventdefs.h>
68 #include <sys/zfs_delay.h>
69 #include <sys/sunddi.h>
70 #include <sys/ctype.h>
72 #include <sys/trace.h>
73 #include <sys/procfs_list.h>
75 #include <sys/uio_impl.h>
76 #include <sys/zfs_context_os.h>
77 #else /* _KERNEL || _STANDALONE */
81 #define _SYS_CONDVAR_H
105 #include <sys/mman.h>
106 #include <sys/types.h>
107 #include <sys/cred.h>
108 #include <sys/sysmacros.h>
109 #include <sys/resource.h>
110 #include <sys/byteorder.h>
111 #include <sys/list.h>
114 #include <sys/zfs_debug.h>
115 #include <sys/kstat.h>
116 #include <sys/u8_textprep.h>
117 #include <sys/sysevent.h>
118 #include <sys/sysevent/eventdefs.h>
119 #include <sys/sunddi.h>
120 #include <sys/debug.h>
121 #include <sys/utsname.h>
122 #include <sys/trace_zfs.h>
124 #include <sys/zfs_context_os.h>
130 #define noinline __attribute__((noinline))
131 #define likely(x) __builtin_expect((x), 1)
132 #define unlikely(x) __builtin_expect((x), 0)
139 * Note that we are not using the debugging levels.
142 #define CE_CONT 0 /* continuation */
143 #define CE_NOTE 1 /* notice */
144 #define CE_WARN 2 /* warning */
145 #define CE_PANIC 3 /* panic */
146 #define CE_IGNORE 4 /* print nothing */
152 extern void dprintf_setup(int *argc
, char **argv
);
154 extern void cmn_err(int, const char *, ...)
155 __attribute__((format(printf
, 2, 3)));
156 extern void vcmn_err(int, const char *, va_list)
157 __attribute__((format(printf
, 2, 0)));
158 extern void panic(const char *, ...)
159 __attribute__((format(printf
, 1, 2), noreturn
));
160 extern void vpanic(const char *, va_list)
161 __attribute__((format(printf
, 1, 0), noreturn
));
163 #define fm_panic panic
166 * DTrace SDT probes have different signatures in userland than they do in
167 * the kernel. If they're being used in kernel code, re-define them out of
168 * existence for their counterparts in libzpool.
170 * Here's an example of how to use the set-error probes in userland:
171 * zfs$target:::set-error /arg0 == EBUSY/ {stack();}
173 * Here's an example of how to use DTRACE_PROBE probes in userland:
174 * If there is a probe declared as follows:
175 * DTRACE_PROBE2(zfs__probe_name, uint64_t, blkid, dnode_t *, dn);
176 * Then you can use it as follows:
177 * zfs$target:::probe2 /copyinstr(arg0) == "zfs__probe_name"/
178 * {printf("%u %p\n", arg1, arg2);}
183 #endif /* DTRACE_PROBE */
184 #define DTRACE_PROBE(a)
188 #endif /* DTRACE_PROBE1 */
189 #define DTRACE_PROBE1(a, b, c)
193 #endif /* DTRACE_PROBE2 */
194 #define DTRACE_PROBE2(a, b, c, d, e)
198 #endif /* DTRACE_PROBE3 */
199 #define DTRACE_PROBE3(a, b, c, d, e, f, g)
203 #endif /* DTRACE_PROBE4 */
204 #define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i)
209 typedef struct zfs_kernel_param
{
210 const char *name
; /* unused stub */
211 } zfs_kernel_param_t
;
213 #define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc)
214 #define ZFS_MODULE_PARAM_ARGS void
215 #define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, \
221 typedef pthread_t kthread_t
;
223 #define TS_RUN 0x00000002
224 #define TS_JOINABLE 0x00000004
226 #define curthread ((void *)(uintptr_t)pthread_self())
227 #define getcomm() "unknown"
229 #define thread_create_named(name, stk, stksize, func, arg, len, \
231 zk_thread_create(func, arg, stksize, state)
232 #define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
233 zk_thread_create(func, arg, stksize, state)
234 #define thread_exit() pthread_exit(NULL)
235 #define thread_join(t) pthread_join((pthread_t)(t), NULL)
237 #define newproc(f, a, cid, pri, ctp, pid) (ENOSYS)
239 /* in libzpool, p0 exists only to have its address taken */
240 typedef struct proc
{
241 uintptr_t this_is_never_used_dont_dereference_it
;
244 extern struct proc p0
;
245 #define curproc (&p0)
249 extern kthread_t
*zk_thread_create(void (*func
)(void *), void *arg
,
250 size_t stksize
, int state
);
252 #define issig(why) (FALSE)
253 #define ISSIG(thr, why) (FALSE)
255 #define KPREEMPT_SYNC (-1)
257 #define kpreempt(x) sched_yield()
258 #define kpreempt_disable() ((void)0)
259 #define kpreempt_enable() ((void)0)
264 typedef struct kmutex
{
265 pthread_mutex_t m_lock
;
269 #define MUTEX_DEFAULT 0
270 #define MUTEX_NOLOCKDEP MUTEX_DEFAULT
271 #define MUTEX_HELD(mp) pthread_equal((mp)->m_owner, pthread_self())
272 #define MUTEX_NOT_HELD(mp) !MUTEX_HELD(mp)
274 extern void mutex_init(kmutex_t
*mp
, char *name
, int type
, void *cookie
);
275 extern void mutex_destroy(kmutex_t
*mp
);
276 extern void mutex_enter(kmutex_t
*mp
);
277 extern int mutex_enter_check_return(kmutex_t
*mp
);
278 extern void mutex_exit(kmutex_t
*mp
);
279 extern int mutex_tryenter(kmutex_t
*mp
);
281 #define NESTED_SINGLE 1
282 #define mutex_enter_nested(mp, class) mutex_enter(mp)
283 #define mutex_enter_interruptible(mp) mutex_enter_check_return(mp)
287 typedef struct krwlock
{
288 pthread_rwlock_t rw_lock
;
297 #define RW_DEFAULT RW_READER
298 #define RW_NOLOCKDEP RW_READER
300 #define RW_READ_HELD(rw) ((rw)->rw_readers > 0)
301 #define RW_WRITE_HELD(rw) pthread_equal((rw)->rw_owner, pthread_self())
302 #define RW_LOCK_HELD(rw) (RW_READ_HELD(rw) || RW_WRITE_HELD(rw))
304 extern void rw_init(krwlock_t
*rwlp
, char *name
, int type
, void *arg
);
305 extern void rw_destroy(krwlock_t
*rwlp
);
306 extern void rw_enter(krwlock_t
*rwlp
, krw_t rw
);
307 extern int rw_tryenter(krwlock_t
*rwlp
, krw_t rw
);
308 extern int rw_tryupgrade(krwlock_t
*rwlp
);
309 extern void rw_exit(krwlock_t
*rwlp
);
310 #define rw_downgrade(rwlp) do { } while (0)
315 extern uid_t
crgetuid(cred_t
*cr
);
316 extern uid_t
crgetruid(cred_t
*cr
);
317 extern gid_t
crgetgid(cred_t
*cr
);
318 extern int crgetngroups(cred_t
*cr
);
319 extern gid_t
*crgetgroups(cred_t
*cr
);
322 * Condition variables
324 typedef pthread_cond_t kcondvar_t
;
327 #define CALLOUT_FLAG_ABSOLUTE 0x2
329 extern void cv_init(kcondvar_t
*cv
, char *name
, int type
, void *arg
);
330 extern void cv_destroy(kcondvar_t
*cv
);
331 extern void cv_wait(kcondvar_t
*cv
, kmutex_t
*mp
);
332 extern int cv_wait_sig(kcondvar_t
*cv
, kmutex_t
*mp
);
333 extern int cv_timedwait(kcondvar_t
*cv
, kmutex_t
*mp
, clock_t abstime
);
334 extern int cv_timedwait_hires(kcondvar_t
*cvp
, kmutex_t
*mp
, hrtime_t tim
,
335 hrtime_t res
, int flag
);
336 extern void cv_signal(kcondvar_t
*cv
);
337 extern void cv_broadcast(kcondvar_t
*cv
);
339 #define cv_timedwait_io(cv, mp, at) cv_timedwait(cv, mp, at)
340 #define cv_timedwait_idle(cv, mp, at) cv_timedwait(cv, mp, at)
341 #define cv_timedwait_sig(cv, mp, at) cv_timedwait(cv, mp, at)
342 #define cv_wait_io(cv, mp) cv_wait(cv, mp)
343 #define cv_wait_idle(cv, mp) cv_wait(cv, mp)
344 #define cv_wait_io_sig(cv, mp) cv_wait_sig(cv, mp)
345 #define cv_timedwait_sig_hires(cv, mp, t, r, f) \
346 cv_timedwait_hires(cv, mp, t, r, f)
347 #define cv_timedwait_idle_hires(cv, mp, t, r, f) \
348 cv_timedwait_hires(cv, mp, t, r, f)
351 * Thread-specific data
353 #define tsd_get(k) pthread_getspecific(k)
354 #define tsd_set(k, v) pthread_setspecific(k, v)
355 #define tsd_create(kp, d) pthread_key_create((pthread_key_t *)kp, d)
356 #define tsd_destroy(kp) /* nothing */
358 typedef off_t loff_t
;
362 * kstat creation, installation and deletion
364 extern kstat_t
*kstat_create(const char *, int,
365 const char *, const char *, uchar_t
, ulong_t
, uchar_t
);
366 extern void kstat_install(kstat_t
*);
367 extern void kstat_delete(kstat_t
*);
368 extern void kstat_set_raw_ops(kstat_t
*ksp
,
369 int (*headers
)(char *buf
, size_t size
),
370 int (*data
)(char *buf
, size_t size
, void *data
),
371 void *(*addr
)(kstat_t
*ksp
, loff_t index
));
374 * procfs list manipulation
377 typedef struct procfs_list
{
382 size_t pl_node_offset
;
387 void seq_printf(struct seq_file
*m
, const char *fmt
, ...);
389 typedef struct procfs_list_node
{
390 list_node_t pln_link
;
392 } procfs_list_node_t
;
394 void procfs_list_install(const char *module
,
395 const char *submodule
,
398 procfs_list_t
*procfs_list
,
399 int (*show
)(struct seq_file
*f
, void *p
),
400 int (*show_header
)(struct seq_file
*f
),
401 int (*clear
)(procfs_list_t
*procfs_list
),
402 size_t procfs_list_node_off
);
403 void procfs_list_uninstall(procfs_list_t
*procfs_list
);
404 void procfs_list_destroy(procfs_list_t
*procfs_list
);
405 void procfs_list_add(procfs_list_t
*procfs_list
, void *p
);
411 #define KM_SLEEP UMEM_NOFAIL
412 #define KM_PUSHPAGE KM_SLEEP
413 #define KM_NOSLEEP UMEM_DEFAULT
414 #define KM_NORMALPRI 0 /* not needed with UMEM_DEFAULT */
415 #define KMC_NODEBUG UMC_NODEBUG
416 #define KMC_KVMEM 0x0
417 #define kmem_alloc(_s, _f) umem_alloc(_s, _f)
418 #define kmem_zalloc(_s, _f) umem_zalloc(_s, _f)
419 #define kmem_free(_b, _s) umem_free(_b, _s)
420 #define vmem_alloc(_s, _f) kmem_alloc(_s, _f)
421 #define vmem_zalloc(_s, _f) kmem_zalloc(_s, _f)
422 #define vmem_free(_b, _s) kmem_free(_b, _s)
423 #define kmem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) \
424 umem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i)
425 #define kmem_cache_destroy(_c) umem_cache_destroy(_c)
426 #define kmem_cache_alloc(_c, _f) umem_cache_alloc(_c, _f)
427 #define kmem_cache_free(_c, _b) umem_cache_free(_c, _b)
428 #define kmem_debugging() 0
429 #define kmem_cache_reap_now(_c) umem_cache_reap_now(_c);
430 #define kmem_cache_set_move(_c, _cb) /* nothing */
431 #define POINTER_INVALIDATE(_pp) /* nothing */
432 #define POINTER_IS_VALID(_p) 0
434 typedef umem_cache_t kmem_cache_t
;
436 typedef enum kmem_cbrc
{
448 #define TASKQ_NAMELEN 31
450 typedef uintptr_t taskqid_t
;
451 typedef void (task_func_t
)(void *);
453 typedef struct taskq_ent
{
454 struct taskq_ent
*tqent_next
;
455 struct taskq_ent
*tqent_prev
;
456 task_func_t
*tqent_func
;
458 uintptr_t tqent_flags
;
461 typedef struct taskq
{
462 char tq_name
[TASKQ_NAMELEN
+ 1];
464 krwlock_t tq_threadlock
;
465 kcondvar_t tq_dispatch_cv
;
466 kcondvar_t tq_wait_cv
;
467 kthread_t
**tq_threadlist
;
474 kcondvar_t tq_maxalloc_cv
;
475 int tq_maxalloc_wait
;
476 taskq_ent_t
*tq_freelist
;
480 #define TQENT_FLAG_PREALLOC 0x1 /* taskq_dispatch_ent used */
482 #define TASKQ_PREPOPULATE 0x0001
483 #define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */
484 #define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */
485 #define TASKQ_THREADS_CPU_PCT 0x0008 /* Scale # threads by # cpus */
486 #define TASKQ_DC_BATCH 0x0010 /* Mark threads as batch */
488 #define TQ_SLEEP KM_SLEEP /* Can block for memory */
489 #define TQ_NOSLEEP KM_NOSLEEP /* cannot block for memory; may fail */
490 #define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */
491 #define TQ_FRONT 0x08 /* Queue in front */
493 #define TASKQID_INVALID ((taskqid_t)0)
495 extern taskq_t
*system_taskq
;
496 extern taskq_t
*system_delay_taskq
;
498 extern taskq_t
*taskq_create(const char *, int, pri_t
, int, int, uint_t
);
499 #define taskq_create_proc(a, b, c, d, e, p, f) \
500 (taskq_create(a, b, c, d, e, f))
501 #define taskq_create_sysdc(a, b, d, e, p, dc, f) \
502 ((void) sizeof (dc), taskq_create(a, b, maxclsyspri, d, e, f))
503 extern taskqid_t
taskq_dispatch(taskq_t
*, task_func_t
, void *, uint_t
);
504 extern taskqid_t
taskq_dispatch_delay(taskq_t
*, task_func_t
, void *, uint_t
,
506 extern void taskq_dispatch_ent(taskq_t
*, task_func_t
, void *, uint_t
,
508 extern int taskq_empty_ent(taskq_ent_t
*);
509 extern void taskq_init_ent(taskq_ent_t
*);
510 extern void taskq_destroy(taskq_t
*);
511 extern void taskq_wait(taskq_t
*);
512 extern void taskq_wait_id(taskq_t
*, taskqid_t
);
513 extern void taskq_wait_outstanding(taskq_t
*, taskqid_t
);
514 extern int taskq_member(taskq_t
*, kthread_t
*);
515 extern taskq_t
*taskq_of_curthread(void);
516 extern int taskq_cancel_id(taskq_t
*, taskqid_t
);
517 extern void system_taskq_init(void);
518 extern void system_taskq_fini(void);
520 #define XVA_MAPSIZE 3
521 #define XVA_MAGIC 0x78766174
523 extern char *vn_dumpdir
;
524 #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
526 typedef struct xoptattr
{
527 inode_timespec_t xoa_createtime
; /* Create time of file */
530 uint8_t xoa_readonly
;
532 uint8_t xoa_nounlink
;
533 uint8_t xoa_immutable
;
534 uint8_t xoa_appendonly
;
536 uint8_t xoa_settable
;
538 uint8_t xoa_av_quarantined
;
539 uint8_t xoa_av_modified
;
540 uint8_t xoa_av_scanstamp
[AV_SCANSTAMP_SZ
];
546 typedef struct vattr
{
547 uint_t va_mask
; /* bit-mask of attributes */
548 u_offset_t va_size
; /* file size in bytes */
552 typedef struct xvattr
{
553 vattr_t xva_vattr
; /* Embedded vattr structure */
554 uint32_t xva_magic
; /* Magic Number */
555 uint32_t xva_mapsize
; /* Size of attr bitmap (32-bit words) */
556 uint32_t *xva_rtnattrmapp
; /* Ptr to xva_rtnattrmap[] */
557 uint32_t xva_reqattrmap
[XVA_MAPSIZE
]; /* Requested attrs */
558 uint32_t xva_rtnattrmap
[XVA_MAPSIZE
]; /* Returned attrs */
559 xoptattr_t xva_xoptattrs
; /* Optional attributes */
562 typedef struct vsecattr
{
563 uint_t vsa_mask
; /* See below */
564 int vsa_aclcnt
; /* ACL entry count */
565 void *vsa_aclentp
; /* pointer to ACL entries */
566 int vsa_dfaclcnt
; /* default ACL entry count */
567 void *vsa_dfaclentp
; /* pointer to default ACL entries */
568 size_t vsa_aclentsz
; /* ACE size in bytes of vsa_aclentp */
571 #define AT_MODE 0x00002
572 #define AT_UID 0x00004
573 #define AT_GID 0x00008
574 #define AT_FSID 0x00010
575 #define AT_NODEID 0x00020
576 #define AT_NLINK 0x00040
577 #define AT_SIZE 0x00080
578 #define AT_ATIME 0x00100
579 #define AT_MTIME 0x00200
580 #define AT_CTIME 0x00400
581 #define AT_RDEV 0x00800
582 #define AT_BLKSIZE 0x01000
583 #define AT_NBLOCKS 0x02000
584 #define AT_SEQ 0x08000
585 #define AT_XVATTR 0x10000
590 #define FIGNORECASE 0x80000 /* request case-insensitive lookups */
595 #define ddi_get_lbolt() (gethrtime() >> 23)
596 #define ddi_get_lbolt64() (gethrtime() >> 23)
597 #define hz 119 /* frequency when using gethrtime() >> 23 for lbolt */
599 #define ddi_time_before(a, b) (a < b)
600 #define ddi_time_after(a, b) ddi_time_before(b, a)
601 #define ddi_time_before_eq(a, b) (!ddi_time_after(a, b))
602 #define ddi_time_after_eq(a, b) ddi_time_before_eq(b, a)
604 #define ddi_time_before64(a, b) (a < b)
605 #define ddi_time_after64(a, b) ddi_time_before64(b, a)
606 #define ddi_time_before_eq64(a, b) (!ddi_time_after64(a, b))
607 #define ddi_time_after_eq64(a, b) ddi_time_before_eq64(b, a)
609 extern void delay(clock_t ticks
);
611 #define SEC_TO_TICK(sec) ((sec) * hz)
612 #define MSEC_TO_TICK(msec) (howmany((hrtime_t)(msec) * hz, MILLISEC))
613 #define USEC_TO_TICK(usec) (howmany((hrtime_t)(usec) * hz, MICROSEC))
614 #define NSEC_TO_TICK(nsec) (howmany((hrtime_t)(nsec) * hz, NANOSEC))
617 #define boot_ncpus (sysconf(_SC_NPROCESSORS_ONLN))
620 * Process priorities as defined by setpriority(2) and getpriority(2).
622 #define minclsyspri 19
623 #define maxclsyspri -20
624 #define defclsyspri 0
626 #define CPU_SEQID ((uintptr_t)pthread_self() & (max_ncpus - 1))
627 #define CPU_SEQID_UNSTABLE CPU_SEQID
632 #define ptob(x) ((x) * PAGESIZE)
634 #define NN_DIVISOR_1000 (1U << 0)
635 #define NN_NUMBUF_SZ (6)
637 extern uint64_t physmem
;
638 extern const char *random_path
;
639 extern const char *urandom_path
;
641 extern int highbit64(uint64_t i
);
642 extern int lowbit64(uint64_t i
);
643 extern int random_get_bytes(uint8_t *ptr
, size_t len
);
644 extern int random_get_pseudo_bytes(uint8_t *ptr
, size_t len
);
646 static __inline__
uint32_t
647 random_in_range(uint32_t range
)
656 (void) random_get_pseudo_bytes((uint8_t *)&r
, sizeof (r
));
661 extern void kernel_init(int mode
);
662 extern void kernel_fini(void);
663 extern void random_init(void);
664 extern void random_fini(void);
667 extern void show_pool_stats(struct spa
*);
668 extern int set_global_var(char const *arg
);
670 typedef struct callb_cpr
{
674 #define CALLB_CPR_INIT(cp, lockp, func, name) { \
675 (cp)->cc_lockp = lockp; \
678 #define CALLB_CPR_SAFE_BEGIN(cp) { \
679 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
682 #define CALLB_CPR_SAFE_END(cp, lockp) { \
683 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
686 #define CALLB_CPR_EXIT(cp) { \
687 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
688 mutex_exit((cp)->cc_lockp); \
691 #define zone_dataset_visible(x, y) (1)
692 #define INGLOBALZONE(z) (1)
693 extern uint32_t zone_get_hostid(void *zonep
);
695 extern char *kmem_vasprintf(const char *fmt
, va_list adx
);
696 extern char *kmem_asprintf(const char *fmt
, ...);
697 #define kmem_strfree(str) kmem_free((str), strlen(str) + 1)
698 #define kmem_strdup(s) strdup(s)
701 extern int kmem_scnprintf(char *restrict str
, size_t size
,
702 const char *restrict fmt
, ...);
706 * Hostname information
708 extern int ddi_strtoull(const char *str
, char **nptr
, int base
,
709 u_longlong_t
*result
);
711 typedef struct utsname utsname_t
;
712 extern utsname_t
*utsname(void);
714 /* ZFS Boot Related stuff. */
724 typedef struct ace_object
{
726 uint32_t a_access_mask
;
729 uint8_t a_obj_type
[16];
730 uint8_t a_inherit_obj_type
[16];
734 #define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05
735 #define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06
736 #define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07
737 #define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08
739 extern int zfs_secpolicy_snapshot_perms(const char *name
, cred_t
*cr
);
740 extern int zfs_secpolicy_rename_perms(const char *from
, const char *to
,
742 extern int zfs_secpolicy_destroy_perms(const char *name
, cred_t
*cr
);
743 extern int secpolicy_zfs(const cred_t
*cr
);
744 extern int secpolicy_zfs_proc(const cred_t
*cr
, proc_t
*proc
);
745 extern zoneid_t
getzoneid(void);
748 typedef struct ksiddomain
{
754 ksiddomain_t
*ksid_lookupdomain(const char *);
755 void ksiddomain_rele(ksiddomain_t
*);
757 #define DDI_SLEEP KM_SLEEP
758 #define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) \
759 sysevent_post_event(_c, _d, _b, "libzpool", _e, _f)
761 #define zfs_sleep_until(wakeup) \
763 hrtime_t delta = wakeup - gethrtime(); \
764 struct timespec ts; \
765 ts.tv_sec = delta / NANOSEC; \
766 ts.tv_nsec = delta % NANOSEC; \
767 (void) nanosleep(&ts, NULL); \
770 typedef int fstrans_cookie_t
;
772 extern fstrans_cookie_t
spl_fstrans_mark(void);
773 extern void spl_fstrans_unmark(fstrans_cookie_t
);
774 extern int __spl_pf_fstrans_check(void);
775 extern int kmem_cache_reap_active(void);
784 #endif /* _KERNEL || _STANDALONE */
790 #endif /* _SYS_ZFS_CONTEXT_H */