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.
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)
45 #include <sys/types.h>
46 #include <sys/atomic.h>
47 #include <sys/sysmacros.h>
48 #include <sys/vmsystm.h>
49 #include <sys/condvar.h>
50 #include <sys/cmn_err.h>
52 #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/strings.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/zfs_context_os.h>
76 #else /* _KERNEL || _STANDALONE */
80 #define _SYS_CONDVAR_H
105 #include <sys/mman.h>
106 #include <sys/note.h>
107 #include <sys/types.h>
108 #include <sys/cred.h>
109 #include <sys/sysmacros.h>
110 #include <sys/resource.h>
111 #include <sys/byteorder.h>
112 #include <sys/list.h>
115 #include <sys/zfs_debug.h>
116 #include <sys/kstat.h>
117 #include <sys/u8_textprep.h>
118 #include <sys/sysevent.h>
119 #include <sys/sysevent/eventdefs.h>
120 #include <sys/sunddi.h>
121 #include <sys/debug.h>
122 #include <sys/utsname.h>
123 #include <sys/trace_zfs.h>
125 #include <sys/zfs_context_os.h>
131 #define noinline __attribute__((noinline))
132 #define likely(x) __builtin_expect((x), 1)
133 #define unlikely(x) __builtin_expect((x), 0)
140 * Note that we are not using the debugging levels.
143 #define CE_CONT 0 /* continuation */
144 #define CE_NOTE 1 /* notice */
145 #define CE_WARN 2 /* warning */
146 #define CE_PANIC 3 /* panic */
147 #define CE_IGNORE 4 /* print nothing */
153 extern void dprintf_setup(int *argc
, char **argv
);
155 extern void cmn_err(int, const char *, ...);
156 extern void vcmn_err(int, const char *, va_list);
157 extern void panic(const char *, ...) __NORETURN
;
158 extern void vpanic(const char *, va_list) __NORETURN
;
160 #define fm_panic panic
165 * DTrace SDT probes have different signatures in userland than they do in
166 * the kernel. If they're being used in kernel code, re-define them out of
167 * existence for their counterparts in libzpool.
169 * Here's an example of how to use the set-error probes in userland:
170 * zfs$target:::set-error /arg0 == EBUSY/ {stack();}
172 * Here's an example of how to use DTRACE_PROBE probes in userland:
173 * If there is a probe declared as follows:
174 * DTRACE_PROBE2(zfs__probe_name, uint64_t, blkid, dnode_t *, dn);
175 * Then you can use it as follows:
176 * zfs$target:::probe2 /copyinstr(arg0) == "zfs__probe_name"/
177 * {printf("%u %p\n", arg1, arg2);}
182 #endif /* DTRACE_PROBE */
183 #define DTRACE_PROBE(a)
187 #endif /* DTRACE_PROBE1 */
188 #define DTRACE_PROBE1(a, b, c)
192 #endif /* DTRACE_PROBE2 */
193 #define DTRACE_PROBE2(a, b, c, d, e)
197 #endif /* DTRACE_PROBE3 */
198 #define DTRACE_PROBE3(a, b, c, d, e, f, g)
202 #endif /* DTRACE_PROBE4 */
203 #define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i)
208 typedef struct zfs_kernel_param
{
209 const char *name
; /* unused stub */
210 } zfs_kernel_param_t
;
212 #define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc)
213 #define ZFS_MODULE_PARAM_ARGS void
214 #define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, \
220 typedef pthread_t kthread_t
;
222 #define TS_RUN 0x00000002
223 #define TS_JOINABLE 0x00000004
225 #define curthread ((void *)(uintptr_t)pthread_self())
226 #define kpreempt(x) yield()
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_disable() ((void)0)
256 #define kpreempt_enable() ((void)0)
257 #define cond_resched() sched_yield()
262 typedef struct kmutex
{
263 pthread_mutex_t m_lock
;
267 #define MUTEX_DEFAULT 0
268 #define MUTEX_NOLOCKDEP MUTEX_DEFAULT
269 #define MUTEX_HELD(mp) pthread_equal((mp)->m_owner, pthread_self())
270 #define MUTEX_NOT_HELD(mp) !MUTEX_HELD(mp)
272 extern void mutex_init(kmutex_t
*mp
, char *name
, int type
, void *cookie
);
273 extern void mutex_destroy(kmutex_t
*mp
);
274 extern void mutex_enter(kmutex_t
*mp
);
275 extern void mutex_exit(kmutex_t
*mp
);
276 extern int mutex_tryenter(kmutex_t
*mp
);
278 #define NESTED_SINGLE 1
279 #define mutex_enter_nested(mp, class) mutex_enter(mp)
283 typedef struct krwlock
{
284 pthread_rwlock_t rw_lock
;
293 #define RW_DEFAULT RW_READER
294 #define RW_NOLOCKDEP RW_READER
296 #define RW_READ_HELD(rw) ((rw)->rw_readers > 0)
297 #define RW_WRITE_HELD(rw) pthread_equal((rw)->rw_owner, pthread_self())
298 #define RW_LOCK_HELD(rw) (RW_READ_HELD(rw) || RW_WRITE_HELD(rw))
300 extern void rw_init(krwlock_t
*rwlp
, char *name
, int type
, void *arg
);
301 extern void rw_destroy(krwlock_t
*rwlp
);
302 extern void rw_enter(krwlock_t
*rwlp
, krw_t rw
);
303 extern int rw_tryenter(krwlock_t
*rwlp
, krw_t rw
);
304 extern int rw_tryupgrade(krwlock_t
*rwlp
);
305 extern void rw_exit(krwlock_t
*rwlp
);
306 #define rw_downgrade(rwlp) do { } while (0)
311 extern uid_t
crgetuid(cred_t
*cr
);
312 extern uid_t
crgetruid(cred_t
*cr
);
313 extern gid_t
crgetgid(cred_t
*cr
);
314 extern int crgetngroups(cred_t
*cr
);
315 extern gid_t
*crgetgroups(cred_t
*cr
);
318 * Condition variables
320 typedef pthread_cond_t kcondvar_t
;
323 #define CALLOUT_FLAG_ABSOLUTE 0x2
325 extern void cv_init(kcondvar_t
*cv
, char *name
, int type
, void *arg
);
326 extern void cv_destroy(kcondvar_t
*cv
);
327 extern void cv_wait(kcondvar_t
*cv
, kmutex_t
*mp
);
328 extern int cv_wait_sig(kcondvar_t
*cv
, kmutex_t
*mp
);
329 extern int cv_timedwait(kcondvar_t
*cv
, kmutex_t
*mp
, clock_t abstime
);
330 extern int cv_timedwait_hires(kcondvar_t
*cvp
, kmutex_t
*mp
, hrtime_t tim
,
331 hrtime_t res
, int flag
);
332 extern void cv_signal(kcondvar_t
*cv
);
333 extern void cv_broadcast(kcondvar_t
*cv
);
335 #define cv_timedwait_io(cv, mp, at) cv_timedwait(cv, mp, at)
336 #define cv_timedwait_idle(cv, mp, at) cv_timedwait(cv, mp, at)
337 #define cv_timedwait_sig(cv, mp, at) cv_timedwait(cv, mp, at)
338 #define cv_wait_io(cv, mp) cv_wait(cv, mp)
339 #define cv_wait_idle(cv, mp) cv_wait(cv, mp)
340 #define cv_wait_io_sig(cv, mp) cv_wait_sig(cv, mp)
341 #define cv_timedwait_sig_hires(cv, mp, t, r, f) \
342 cv_timedwait_hires(cv, mp, t, r, f)
343 #define cv_timedwait_idle_hires(cv, mp, t, r, f) \
344 cv_timedwait_hires(cv, mp, t, r, f)
347 * Thread-specific data
349 #define tsd_get(k) pthread_getspecific(k)
350 #define tsd_set(k, v) pthread_setspecific(k, v)
351 #define tsd_create(kp, d) pthread_key_create((pthread_key_t *)kp, d)
352 #define tsd_destroy(kp) /* nothing */
354 typedef off_t loff_t
;
358 * kstat creation, installation and deletion
360 extern kstat_t
*kstat_create(const char *, int,
361 const char *, const char *, uchar_t
, ulong_t
, uchar_t
);
362 extern void kstat_install(kstat_t
*);
363 extern void kstat_delete(kstat_t
*);
364 extern void kstat_waitq_enter(kstat_io_t
*);
365 extern void kstat_waitq_exit(kstat_io_t
*);
366 extern void kstat_runq_enter(kstat_io_t
*);
367 extern void kstat_runq_exit(kstat_io_t
*);
368 extern void kstat_waitq_to_runq(kstat_io_t
*);
369 extern void kstat_runq_back_to_waitq(kstat_io_t
*);
370 extern void kstat_set_raw_ops(kstat_t
*ksp
,
371 int (*headers
)(char *buf
, size_t size
),
372 int (*data
)(char *buf
, size_t size
, void *data
),
373 void *(*addr
)(kstat_t
*ksp
, loff_t index
));
376 * procfs list manipulation
379 typedef struct procfs_list
{
384 size_t pl_node_offset
;
389 void seq_printf(struct seq_file
*m
, const char *fmt
, ...);
391 typedef struct procfs_list_node
{
392 list_node_t pln_link
;
394 } procfs_list_node_t
;
396 void procfs_list_install(const char *module
,
397 const char *submodule
,
400 procfs_list_t
*procfs_list
,
401 int (*show
)(struct seq_file
*f
, void *p
),
402 int (*show_header
)(struct seq_file
*f
),
403 int (*clear
)(procfs_list_t
*procfs_list
),
404 size_t procfs_list_node_off
);
405 void procfs_list_uninstall(procfs_list_t
*procfs_list
);
406 void procfs_list_destroy(procfs_list_t
*procfs_list
);
407 void procfs_list_add(procfs_list_t
*procfs_list
, void *p
);
413 #define KM_SLEEP UMEM_NOFAIL
414 #define KM_PUSHPAGE KM_SLEEP
415 #define KM_NOSLEEP UMEM_DEFAULT
416 #define KM_NORMALPRI 0 /* not needed with UMEM_DEFAULT */
417 #define KMC_NODEBUG UMC_NODEBUG
418 #define KMC_KVMEM 0x0
419 #define kmem_alloc(_s, _f) umem_alloc(_s, _f)
420 #define kmem_zalloc(_s, _f) umem_zalloc(_s, _f)
421 #define kmem_free(_b, _s) umem_free(_b, _s)
422 #define vmem_alloc(_s, _f) kmem_alloc(_s, _f)
423 #define vmem_zalloc(_s, _f) kmem_zalloc(_s, _f)
424 #define vmem_free(_b, _s) kmem_free(_b, _s)
425 #define kmem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) \
426 umem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i)
427 #define kmem_cache_destroy(_c) umem_cache_destroy(_c)
428 #define kmem_cache_alloc(_c, _f) umem_cache_alloc(_c, _f)
429 #define kmem_cache_free(_c, _b) umem_cache_free(_c, _b)
430 #define kmem_debugging() 0
431 #define kmem_cache_reap_now(_c) umem_cache_reap_now(_c);
432 #define kmem_cache_set_move(_c, _cb) /* nothing */
433 #define POINTER_INVALIDATE(_pp) /* nothing */
434 #define POINTER_IS_VALID(_p) 0
436 typedef umem_cache_t kmem_cache_t
;
438 typedef enum kmem_cbrc
{
450 #define TASKQ_NAMELEN 31
452 typedef uintptr_t taskqid_t
;
453 typedef void (task_func_t
)(void *);
455 typedef struct taskq_ent
{
456 struct taskq_ent
*tqent_next
;
457 struct taskq_ent
*tqent_prev
;
458 task_func_t
*tqent_func
;
460 uintptr_t tqent_flags
;
463 typedef struct taskq
{
464 char tq_name
[TASKQ_NAMELEN
+ 1];
466 krwlock_t tq_threadlock
;
467 kcondvar_t tq_dispatch_cv
;
468 kcondvar_t tq_wait_cv
;
469 kthread_t
**tq_threadlist
;
476 kcondvar_t tq_maxalloc_cv
;
477 int tq_maxalloc_wait
;
478 taskq_ent_t
*tq_freelist
;
482 #define TQENT_FLAG_PREALLOC 0x1 /* taskq_dispatch_ent used */
484 #define TASKQ_PREPOPULATE 0x0001
485 #define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */
486 #define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */
487 #define TASKQ_THREADS_CPU_PCT 0x0008 /* Scale # threads by # cpus */
488 #define TASKQ_DC_BATCH 0x0010 /* Mark threads as batch */
490 #define TQ_SLEEP KM_SLEEP /* Can block for memory */
491 #define TQ_NOSLEEP KM_NOSLEEP /* cannot block for memory; may fail */
492 #define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */
493 #define TQ_FRONT 0x08 /* Queue in front */
495 #define TASKQID_INVALID ((taskqid_t)0)
497 extern taskq_t
*system_taskq
;
498 extern taskq_t
*system_delay_taskq
;
500 extern taskq_t
*taskq_create(const char *, int, pri_t
, int, int, uint_t
);
501 #define taskq_create_proc(a, b, c, d, e, p, f) \
502 (taskq_create(a, b, c, d, e, f))
503 #define taskq_create_sysdc(a, b, d, e, p, dc, f) \
504 (taskq_create(a, b, maxclsyspri, d, e, f))
505 extern taskqid_t
taskq_dispatch(taskq_t
*, task_func_t
, void *, uint_t
);
506 extern taskqid_t
taskq_dispatch_delay(taskq_t
*, task_func_t
, void *, uint_t
,
508 extern void taskq_dispatch_ent(taskq_t
*, task_func_t
, void *, uint_t
,
510 extern int taskq_empty_ent(taskq_ent_t
*);
511 extern void taskq_init_ent(taskq_ent_t
*);
512 extern void taskq_destroy(taskq_t
*);
513 extern void taskq_wait(taskq_t
*);
514 extern void taskq_wait_id(taskq_t
*, taskqid_t
);
515 extern void taskq_wait_outstanding(taskq_t
*, taskqid_t
);
516 extern int taskq_member(taskq_t
*, kthread_t
*);
517 extern taskq_t
*taskq_of_curthread(void);
518 extern int taskq_cancel_id(taskq_t
*, taskqid_t
);
519 extern void system_taskq_init(void);
520 extern void system_taskq_fini(void);
522 #define XVA_MAPSIZE 3
523 #define XVA_MAGIC 0x78766174
525 extern char *vn_dumpdir
;
526 #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
528 typedef struct xoptattr
{
529 inode_timespec_t xoa_createtime
; /* Create time of file */
532 uint8_t xoa_readonly
;
534 uint8_t xoa_nounlink
;
535 uint8_t xoa_immutable
;
536 uint8_t xoa_appendonly
;
538 uint8_t xoa_settable
;
540 uint8_t xoa_av_quarantined
;
541 uint8_t xoa_av_modified
;
542 uint8_t xoa_av_scanstamp
[AV_SCANSTAMP_SZ
];
548 typedef struct vattr
{
549 uint_t va_mask
; /* bit-mask of attributes */
550 u_offset_t va_size
; /* file size in bytes */
554 typedef struct xvattr
{
555 vattr_t xva_vattr
; /* Embedded vattr structure */
556 uint32_t xva_magic
; /* Magic Number */
557 uint32_t xva_mapsize
; /* Size of attr bitmap (32-bit words) */
558 uint32_t *xva_rtnattrmapp
; /* Ptr to xva_rtnattrmap[] */
559 uint32_t xva_reqattrmap
[XVA_MAPSIZE
]; /* Requested attrs */
560 uint32_t xva_rtnattrmap
[XVA_MAPSIZE
]; /* Returned attrs */
561 xoptattr_t xva_xoptattrs
; /* Optional attributes */
564 typedef struct vsecattr
{
565 uint_t vsa_mask
; /* See below */
566 int vsa_aclcnt
; /* ACL entry count */
567 void *vsa_aclentp
; /* pointer to ACL entries */
568 int vsa_dfaclcnt
; /* default ACL entry count */
569 void *vsa_dfaclentp
; /* pointer to default ACL entries */
570 size_t vsa_aclentsz
; /* ACE size in bytes of vsa_aclentp */
573 #define AT_MODE 0x00002
574 #define AT_UID 0x00004
575 #define AT_GID 0x00008
576 #define AT_FSID 0x00010
577 #define AT_NODEID 0x00020
578 #define AT_NLINK 0x00040
579 #define AT_SIZE 0x00080
580 #define AT_ATIME 0x00100
581 #define AT_MTIME 0x00200
582 #define AT_CTIME 0x00400
583 #define AT_RDEV 0x00800
584 #define AT_BLKSIZE 0x01000
585 #define AT_NBLOCKS 0x02000
586 #define AT_SEQ 0x08000
587 #define AT_XVATTR 0x10000
592 #define FIGNORECASE 0x80000 /* request case-insensitive lookups */
597 #define ddi_get_lbolt() (gethrtime() >> 23)
598 #define ddi_get_lbolt64() (gethrtime() >> 23)
599 #define hz 119 /* frequency when using gethrtime() >> 23 for lbolt */
601 #define ddi_time_before(a, b) (a < b)
602 #define ddi_time_after(a, b) ddi_time_before(b, a)
603 #define ddi_time_before_eq(a, b) (!ddi_time_after(a, b))
604 #define ddi_time_after_eq(a, b) ddi_time_before_eq(b, a)
606 #define ddi_time_before64(a, b) (a < b)
607 #define ddi_time_after64(a, b) ddi_time_before64(b, a)
608 #define ddi_time_before_eq64(a, b) (!ddi_time_after64(a, b))
609 #define ddi_time_after_eq64(a, b) ddi_time_before_eq64(b, a)
611 extern void delay(clock_t ticks
);
613 #define SEC_TO_TICK(sec) ((sec) * hz)
614 #define MSEC_TO_TICK(msec) (howmany((hrtime_t)(msec) * hz, MILLISEC))
615 #define USEC_TO_TICK(usec) (howmany((hrtime_t)(usec) * hz, MICROSEC))
616 #define NSEC_TO_TICK(nsec) (howmany((hrtime_t)(nsec) * hz, NANOSEC))
619 #define boot_ncpus (sysconf(_SC_NPROCESSORS_ONLN))
622 * Process priorities as defined by setpriority(2) and getpriority(2).
624 #define minclsyspri 19
625 #define maxclsyspri -20
626 #define defclsyspri 0
628 #define CPU_SEQID ((uintptr_t)pthread_self() & (max_ncpus - 1))
629 #define CPU_SEQID_UNSTABLE CPU_SEQID
634 #define ptob(x) ((x) * PAGESIZE)
636 #define NN_DIVISOR_1000 (1U << 0)
637 #define NN_NUMBUF_SZ (6)
639 extern uint64_t physmem
;
640 extern char *random_path
;
641 extern char *urandom_path
;
643 extern int highbit64(uint64_t i
);
644 extern int lowbit64(uint64_t i
);
645 extern int random_get_bytes(uint8_t *ptr
, size_t len
);
646 extern int random_get_pseudo_bytes(uint8_t *ptr
, size_t len
);
648 extern void kernel_init(int mode
);
649 extern void kernel_fini(void);
650 extern void random_init(void);
651 extern void random_fini(void);
654 extern void show_pool_stats(struct spa
*);
655 extern int set_global_var(char *arg
);
657 typedef struct callb_cpr
{
661 #define CALLB_CPR_INIT(cp, lockp, func, name) { \
662 (cp)->cc_lockp = lockp; \
665 #define CALLB_CPR_SAFE_BEGIN(cp) { \
666 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
669 #define CALLB_CPR_SAFE_END(cp, lockp) { \
670 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
673 #define CALLB_CPR_EXIT(cp) { \
674 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
675 mutex_exit((cp)->cc_lockp); \
678 #define zone_dataset_visible(x, y) (1)
679 #define INGLOBALZONE(z) (1)
680 extern uint32_t zone_get_hostid(void *zonep
);
682 extern char *kmem_vasprintf(const char *fmt
, va_list adx
);
683 extern char *kmem_asprintf(const char *fmt
, ...);
684 #define kmem_strfree(str) kmem_free((str), strlen(str) + 1)
685 #define kmem_strdup(s) strdup(s)
688 * Hostname information
690 extern char hw_serial
[]; /* for userland-emulated hostid access */
691 extern int ddi_strtoul(const char *str
, char **nptr
, int base
,
692 unsigned long *result
);
694 extern int ddi_strtoull(const char *str
, char **nptr
, int base
,
695 u_longlong_t
*result
);
697 typedef struct utsname utsname_t
;
698 extern utsname_t
*utsname(void);
700 /* ZFS Boot Related stuff. */
710 typedef struct ace_object
{
712 uint32_t a_access_mask
;
715 uint8_t a_obj_type
[16];
716 uint8_t a_inherit_obj_type
[16];
720 #define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05
721 #define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06
722 #define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07
723 #define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08
725 extern int zfs_secpolicy_snapshot_perms(const char *name
, cred_t
*cr
);
726 extern int zfs_secpolicy_rename_perms(const char *from
, const char *to
,
728 extern int zfs_secpolicy_destroy_perms(const char *name
, cred_t
*cr
);
729 extern int secpolicy_zfs(const cred_t
*cr
);
730 extern int secpolicy_zfs_proc(const cred_t
*cr
, proc_t
*proc
);
731 extern zoneid_t
getzoneid(void);
734 typedef struct ksiddomain
{
740 ksiddomain_t
*ksid_lookupdomain(const char *);
741 void ksiddomain_rele(ksiddomain_t
*);
743 #define DDI_SLEEP KM_SLEEP
744 #define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) \
745 sysevent_post_event(_c, _d, _b, "libzpool", _e, _f)
747 #define zfs_sleep_until(wakeup) \
749 hrtime_t delta = wakeup - gethrtime(); \
750 struct timespec ts; \
751 ts.tv_sec = delta / NANOSEC; \
752 ts.tv_nsec = delta % NANOSEC; \
753 (void) nanosleep(&ts, NULL); \
756 typedef int fstrans_cookie_t
;
758 extern fstrans_cookie_t
spl_fstrans_mark(void);
759 extern void spl_fstrans_unmark(fstrans_cookie_t
);
760 extern int __spl_pf_fstrans_check(void);
761 extern int kmem_cache_reap_active(void);
763 #define ____cacheline_aligned
771 #endif /* _KERNEL || _STANDALONE */
777 #endif /* _SYS_ZFS_CONTEXT_H */