1 /* $NetBSD: zfs_context.h,v 1.16 2014/03/28 02:50:18 ozaki-r Exp $ */ 2 3 /* 4 * CDDL HEADER START 5 * 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License, Version 1.0 only 8 * (the "License"). You may not use this file except in compliance 9 * with the License. 10 * 11 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 12 * or http://www.opensolaris.org/os/licensing. 13 * See the License for the specific language governing permissions 14 * and limitations under the License. 15 * 16 * When distributing Covered Code, include this CDDL HEADER in each 17 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 18 * If applicable, add the following below this CDDL HEADER, with the 19 * fields enclosed by brackets "[]" replaced with your own identifying 20 * information: Portions Copyright [yyyy] [name of copyright owner] 21 * 22 * CDDL HEADER END 23 */ 24 /* 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29 #ifndef _SYS_ZFS_CONTEXT_H 30 #define _SYS_ZFS_CONTEXT_H 31 32 #pragma ident "%Z%%M% %I% %E% SMI" 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #include <sys/types.h> 39 40 #ifndef _KERNEL 41 42 #include <sys/mutex.h> 43 #include <sys/rwlock.h> 44 #include <sys/condvar.h> 45 46 #define _SYS_SYSTM_H 47 #define _SYS_DEBUG_H 48 #define _SYS_T_LOCK_H 49 #define _SYS_VNODE_H 50 #define _SYS_VFS_H 51 #define _SYS_SUNDDI_H 52 #define _SYS_CALLB_H 53 #define _SYS_SCHED_H 54 #define _SYS_TASKQ_ 55 56 #include <thread.h> 57 #include <umem.h> 58 #include <paths.h> 59 #include <strings.h> 60 #include <string.h> 61 #include <stdio.h> 62 #include <stdlib.h> 63 #include <errno.h> 64 #include <unistd.h> 65 66 #include <sys/kstat.h> 67 #include <sys/param.h> 68 #include <sys/stdint.h> 69 #include <sys/note.h> 70 #include <sys/uio.h> 71 #include <sys/atomic.h> 72 #include <sys/zfs_debug.h> 73 #include <sys/misc.h> 74 #include <sys/sdt.h> 75 #include <sys/list.h> 76 #include <sys/ccompile.h> 77 #include <sys/byteorder.h> 78 #include <sys/utsname.h> 79 #include <sys/cred.h> 80 #include <sys/pset.h> 81 #include <sys/u8_textprep.h> 82 #include <sys/zone.h> 83 #include <sys/pathname.h> 84 #include <sys/sysevent.h> 85 86 extern void panic(const char *, ...); 87 88 #include <sys/cmn_err.h> 89 90 #include <sys/sysevent/eventdefs.h> 91 92 /* #include <libzfs.h> */ 93 94 #ifndef ABS 95 #define ABS(a) ((a) < 0 ? -(a) : (a)) 96 #endif 97 98 extern int aok; 99 100 /* 101 * Debugging 102 */ 103 104 /* 105 * Note that we are not using the debugging levels. 106 */ 107 108 #define CE_CONT 0 /* continuation */ 109 #define CE_NOTE 1 /* notice */ 110 #define CE_WARN 2 /* warning */ 111 #define CE_PANIC 3 /* panic */ 112 #define CE_IGNORE 4 /* print nothing */ 113 114 /* 115 * ZFS debugging 116 */ 117 118 #define ZFS_LOG(...) do { } while (0) 119 120 typedef u_longlong_t rlim64_t; 121 #define RLIM64_INFINITY ((rlim64_t)-3) 122 123 #ifdef ZFS_DEBUG 124 extern void dprintf_setup(int *argc, char **argv); 125 #endif /* ZFS_DEBUG */ 126 127 /* extern void cmn_err(int, const char *, ...); 128 extern void vcmn_err(int, const char *, va_list); */ 129 /* extern void vpanic(const char *, va_list); */ 130 131 #define fm_panic panic 132 133 #if !defined(_LIBZFS_H) && !defined(_ZFS_CONTEXT_NO_VERIFY) 134 #define verify(EX) (void)((EX) || \ 135 (__assert13(__FILE__, __LINE__, __func__, #EX), 0)) 136 #define VERIFY verify 137 #endif 138 139 #define ASSERT assert 140 141 #ifdef lint 142 #define VERIFY3_IMPL(x, y, z, t) if (x == z) ((void)0) 143 #else 144 /* BEGIN CSTYLED */ 145 #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \ 146 const TYPE __left = (TYPE)(LEFT); \ 147 const TYPE __right = (TYPE)(RIGHT); \ 148 if (!(__left OP __right)) { \ 149 char __buf[256]; \ 150 (void) snprintf(__buf, 256, "%s %s %s (0x%llx %s 0x%llx)", \ 151 #LEFT, #OP, #RIGHT, \ 152 (u_longlong_t)__left, #OP, (u_longlong_t)__right); \ 153 __assert13(__FILE__, __LINE__, __func__,__buf); \ 154 } \ 155 _NOTE(CONSTCOND) } while (0) 156 /* END CSTYLED */ 157 #endif /* lint */ 158 159 #define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t) 160 #define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t) 161 #define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t) 162 163 #ifdef NDEBUG 164 #define ASSERT3S(x, y, z) ((void)0) 165 #define ASSERT3U(x, y, z) ((void)0) 166 #define ASSERT3P(x, y, z) ((void)0) 167 #else 168 #define ASSERT3S(x, y, z) VERIFY3S(x, y, z) 169 #define ASSERT3U(x, y, z) VERIFY3U(x, y, z) 170 #define ASSERT3P(x, y, z) VERIFY3P(x, y, z) 171 #endif 172 173 /* 174 * Dtrace SDT probes have different signatures in userland than they do in 175 * kernel. If they're being used in kernel code, re-define them out of 176 * existence for their counterparts in libzpool. 177 */ 178 179 #ifdef DTRACE_PROBE1 180 #undef DTRACE_PROBE1 181 #define DTRACE_PROBE1(a, b, c) ((void)0) 182 #endif /* DTRACE_PROBE1 */ 183 184 #ifdef DTRACE_PROBE2 185 #undef DTRACE_PROBE2 186 #define DTRACE_PROBE2(a, b, c, d, e) ((void)0) 187 #endif /* DTRACE_PROBE2 */ 188 189 #ifdef DTRACE_PROBE3 190 #undef DTRACE_PROBE3 191 #define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void)0) 192 #endif /* DTRACE_PROBE3 */ 193 194 #ifdef DTRACE_PROBE4 195 #undef DTRACE_PROBE4 196 #define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void)0) 197 #endif /* DTRACE_PROBE4 */ 198 199 /* 200 * Threads 201 */ 202 #define curthread ((void *)(uintptr_t)thr_self()) 203 204 typedef pthread_t kthread_t; 205 206 #define thread_create(stk, stksize, func, arg, len, pp, state, pri) \ 207 zk_thread_create(func, arg) 208 #define thread_exit() thr_exit(NULL) 209 #define thread_join(t) panic("libzpool cannot join threads") 210 211 #define newproc(f, a, cid, pri, ctp, pid) (ENOSYS) 212 213 extern kthread_t *zk_thread_create(void (*func)(), void *arg); 214 215 /* In NetBSD struct proc may be visible in userspace therefore we use it's original 216 definition. */ 217 #if !defined(p_startzero) 218 struct proc { 219 uintptr_t this_is_never_used_dont_dereference_it; 220 }; 221 #endif 222 223 extern struct proc p0; 224 225 #define issig(why) (FALSE) 226 #define ISSIG(thr, why) (FALSE) 227 #define makedevice(min, maj) makedev((min), (maj)) 228 229 /* 230 * Mutexes 231 */ 232 233 #define MUTEX_DEFAULT USYNC_THREAD 234 #define MUTEX_HELD(m) (mutex_owned(m)) 235 236 extern void mutex_init(kmutex_t *mp, void *, kmutex_type_t, void *); 237 extern void mutex_destroy(kmutex_t *mp); 238 extern void mutex_enter(kmutex_t *mp); 239 extern void mutex_exit(kmutex_t *mp); 240 extern int mutex_tryenter(kmutex_t *mp); 241 extern void *mutex_owner(kmutex_t *mp); 242 extern int mutex_owned(kmutex_t *mp); 243 244 /* 245 * RW locks 246 */ 247 #define RW_DEFAULT USYNC_THREAD 248 249 #define RW_LOCK_HELD(x) rw_lock_held(x) 250 #define RW_WRITE_HELD(x) rw_write_held(x) 251 #define RW_READ_HELD(x) rw_read_held(x) 252 253 extern void rw_init(krwlock_t *rwlp, char *name, int type, void *arg); 254 extern void rw_destroy(krwlock_t *rwlp); 255 extern void rw_enter(krwlock_t *rwlp, krw_t rw); 256 extern int rw_tryenter(krwlock_t *rwlp, krw_t rw); 257 extern int rw_tryupgrade(krwlock_t *rwlp); 258 extern void rw_exit(krwlock_t *rwlp); 259 extern int rw_lock_held(krwlock_t *rwlp); 260 extern int rw_write_held(krwlock_t *rwlp); 261 extern int rw_read_held(krwlock_t *rwlp); 262 #define rw_downgrade(rwlp) do { } while (0) 263 264 extern uid_t crgetuid(cred_t *cr); 265 extern gid_t crgetgid(cred_t *cr); 266 extern int crgetngroups(cred_t *cr); 267 extern gid_t *crgetgroups(cred_t *cr); 268 269 /* 270 * Condition variables 271 */ 272 #define CV_DEFAULT USYNC_THREAD 273 274 extern void cv_init(kcondvar_t *cv, char *name, int type, void *arg); 275 extern void cv_destroy(kcondvar_t *cv); 276 extern void cv_wait(kcondvar_t *cv, kmutex_t *mp); 277 extern clock_t cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime); 278 extern void cv_signal(kcondvar_t *cv); 279 extern void cv_broadcast(kcondvar_t *cv); 280 281 /* 282 * Kernel memory 283 */ 284 #define KM_SLEEP UMEM_NOFAIL 285 #define KM_NOSLEEP UMEM_DEFAULT 286 #define KM_PUSHPAGE UMEM_NOFAIL 287 #define KMC_NODEBUG UMC_NODEBUG 288 #define kmem_alloc(_s, _f) umem_alloc(_s, _f) 289 #define kmem_zalloc(_s, _f) umem_zalloc(_s, _f) 290 #define kmem_free(_b, _s) umem_free(_b, _s) 291 #define kmem_size() (physmem * PAGESIZE) 292 #define kmem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) \ 293 umem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) 294 #define kmem_cache_destroy(_c) umem_cache_destroy(_c) 295 #define kmem_cache_alloc(_c, _f) umem_cache_alloc(_c, _f) 296 #define kmem_cache_free(_c, _b) umem_cache_free(_c, _b) 297 #define kmem_debugging() 0 298 #define kmem_cache_reap_now(c) 299 300 typedef umem_cache_t kmem_cache_t; 301 typedef struct vmem vmem_t; 302 303 #define ZFS_EXPORTS_PATH "/etc/zfs/exports" 304 305 /* 306 * Task queues 307 */ 308 typedef struct taskq taskq_t; 309 typedef uintptr_t taskqid_t; 310 typedef void (task_func_t)(void *); 311 312 #define TASKQ_PREPOPULATE 0x0001 313 #define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */ 314 #define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */ 315 #define TASKQ_THREADS_CPU_PCT 0x0008 /* Scale # threads by # cpus */ 316 #define TASKQ_DC_BATCH 0x0010 /* Mark threads as batch */ 317 318 #define TQ_SLEEP KM_SLEEP /* Can block for memory */ 319 #define TQ_NOSLEEP KM_NOSLEEP /* cannot block for memory; may fail */ 320 #define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */ 321 #define TQ_FRONT 0x08 /* Queue in front */ 322 323 extern taskq_t *system_taskq; 324 325 extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t); 326 #define taskq_create_proc(a, b, c, d, e, p, f) \ 327 (taskq_create(a, b, c, d, e, f)) 328 #define taskq_create_sysdc(a, b, d, e, p, dc, f) \ 329 (taskq_create(a, b, maxclsyspri, d, e, f)) 330 extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t); 331 extern void taskq_destroy(taskq_t *); 332 extern void taskq_wait(taskq_t *); 333 extern int taskq_member(taskq_t *, void *); 334 extern void system_taskq_init(void); 335 extern void system_taskq_fini(void); 336 337 #define XVA_MAPSIZE 3 338 #define XVA_MAGIC 0x78766174 339 340 /* 341 * vnodes 342 */ 343 typedef struct vnode { 344 uint64_t v_size; 345 int v_fd; 346 char *v_path; 347 } vnode_t; 348 349 typedef struct vattr { 350 uint_t va_mask; /* bit-mask of attributes */ 351 u_offset_t va_size; /* file size in bytes */ 352 } vattr_t; 353 354 #define AT_TYPE 0x0001 355 #define AT_MODE 0x0002 356 #define AT_UID 0x0004 357 #define AT_GID 0x0008 358 #define AT_FSID 0x0010 359 #define AT_NODEID 0x0020 360 #define AT_NLINK 0x0040 361 #define AT_SIZE 0x0080 362 #define AT_ATIME 0x0100 363 #define AT_MTIME 0x0200 364 #define AT_CTIME 0x0400 365 #define AT_RDEV 0x0800 366 #define AT_BLKSIZE 0x1000 367 #define AT_NBLOCKS 0x2000 368 #define AT_SEQ 0x8000 369 370 #define CRCREAT 0 371 372 #define VOP_CLOSE(vp, f, c, o, cr, unk) 0 373 #define VOP_PUTPAGE(vp, of, sz, fl, cr, unk) 0 374 #define VOP_GETATTR(vp, vap, fl, cr, unk) vn_getattr(vp, vap) 375 #define VOP_FSYNC(vp, f, cr, unk) fsync((vp)->v_fd) 376 377 #define VN_RELE(vp) vn_close(vp) 378 379 extern int vn_open(char *path, int x1, int oflags, int mode, vnode_t **vpp, 380 int x2, int x3); 381 extern int vn_openat(char *path, int x1, int oflags, int mode, vnode_t **vpp, 382 int x2, int x3, vnode_t *vp, int unk); 383 extern int vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, 384 offset_t offset, int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp); 385 extern void vn_close(vnode_t *vp); 386 extern int vn_getattr(vnode_t *vp, vattr_t *va); 387 388 #define vn_remove(path, x1, x2) remove(path) 389 #define vn_rename(from, to, seg) rename((from), (to)) 390 #define vn_is_readonly(vp) B_FALSE 391 392 extern vnode_t *rootdir; 393 394 #include <sys/file.h> /* for FREAD, FWRITE, etc */ 395 #define FTRUNC O_TRUNC 396 #define openat64 openat 397 398 399 /* 400 * Random stuff 401 */ 402 #define lbolt (gethrtime() >> 23) 403 #define lbolt64 (gethrtime() >> 23) 404 #define hz 119 /* frequency when using gethrtime() >> 23 for lbolt */ 405 406 extern void xdelay(clock_t ticks); 407 408 #define gethrestime_sec() time(NULL) 409 #define gethrestime(t) \ 410 do {\ 411 (t)->tv_sec = gethrestime_sec();\ 412 (t)->tv_nsec = 0;\ 413 } while (0); 414 415 #define max_ncpus 64 416 417 #define minclsyspri 60 418 #define maxclsyspri 99 419 420 #define CPU_SEQID (thr_self() & (max_ncpus - 1)) 421 422 #define kcred NULL 423 #define CRED() NULL 424 425 extern uint64_t physmem; 426 427 extern int random_get_bytes(uint8_t *ptr, size_t len); 428 extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len); 429 430 extern void kernel_init(int); 431 extern void kernel_fini(void); 432 433 struct spa; 434 extern void nicenum(uint64_t, char *, size_t); 435 extern void show_pool_stats(struct spa *); 436 437 typedef struct callb_cpr { 438 kmutex_t *cc_lockp; 439 } callb_cpr_t; 440 441 #define CALLB_CPR_INIT(cp, lockp, func, name) { \ 442 (cp)->cc_lockp = lockp; \ 443 } 444 445 #define CALLB_CPR_SAFE_BEGIN(cp) { \ 446 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \ 447 } 448 449 #define CALLB_CPR_SAFE_END(cp, lockp) { \ 450 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \ 451 } 452 453 #define CALLB_CPR_EXIT(cp) { \ 454 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \ 455 mutex_exit((cp)->cc_lockp); \ 456 } 457 458 #define zone_dataset_visible(x, y) (1) 459 #define INGLOBALZONE(z) (1) 460 461 #define open64 open 462 int mkdirp(const char *, mode_t); 463 464 /* 465 * Hostname information 466 */ 467 extern struct utsname utsname; 468 extern char hw_serial[]; 469 extern int ddi_strtoul(const char *str, char **nptr, int base, 470 unsigned long *result); 471 #define ddi_get_lbolt() (gethrtime() >> 23) 472 #define ddi_get_lbolt64() (gethrtime() >> 23) 473 474 /* ZFS Boot Related stuff. */ 475 476 struct _buf { 477 intptr_t _fd; 478 }; 479 480 struct bootstat { 481 uint64_t st_size; 482 }; 483 484 extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); 485 extern int zfs_secpolicy_rename_perms(const char *from, const char *to, 486 cred_t *cr); 487 extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); 488 489 extern struct _buf *kobj_open_file(char *name); 490 extern int kobj_read_file(struct _buf *file, char *buf, unsigned size, 491 unsigned off); 492 extern void kobj_close_file(struct _buf *file); 493 extern int kobj_get_filesize(struct _buf *file, uint64_t *size); 494 /* Random compatibility stuff. */ 495 #define lbolt (gethrtime() >> 23) 496 #define lbolt64 (gethrtime() >> 23) 497 498 /* extern int hz; */ 499 extern uint64_t physmem; 500 501 #define gethrestime_sec() time(NULL) 502 503 #define pwrite64(d, p, n, o) pwrite(d, p, n, o) 504 #define readdir64(d) readdir(d) 505 #define sigispending(td, sig) (0) 506 #define root_mount_wait() do { } while (0) 507 #define root_mounted() (1) 508 509 struct file { 510 void *dummy; 511 }; 512 513 #define FCREAT O_CREAT 514 #define FOFFMAX 0x0 515 516 #define SYSCTL_DECL(...) 517 #define SYSCTL_NODE(...) 518 #define SYSCTL_INT(...) 519 #define SYSCTL_ULONG(...) 520 #ifdef TUNABLE_INT 521 #undef TUNABLE_INT 522 #undef TUNABLE_ULONG 523 #endif 524 #define TUNABLE_INT(...) 525 #define TUNABLE_ULONG(...) 526 527 /* Errors */ 528 529 #ifndef ERESTART 530 #define ERESTART (-1) 531 #endif 532 533 #ifdef ptob 534 #undef ptob 535 #endif 536 537 size_t ptob(size_t); 538 539 540 typedef struct ksiddomain { 541 uint_t kd_ref; 542 uint_t kd_len; 543 char *kd_name; 544 } ksiddomain_t; 545 546 ksiddomain_t *ksid_lookupdomain(const char *); 547 void ksiddomain_rele(ksiddomain_t *); 548 549 typedef struct ace_object { 550 uid_t a_who; 551 uint32_t a_access_mask; 552 uint16_t a_flags; 553 uint16_t a_type; 554 uint8_t a_obj_type[16]; 555 uint8_t a_inherit_obj_type[16]; 556 } ace_object_t; 557 558 #define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05 559 #define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06 560 #define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07 561 #define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08 562 563 /* libzfs_dataset.c */ 564 #define priv_allocset() (NULL) 565 #define getppriv(a, b) (0) 566 #define priv_isfullset(a) (B_FALSE) 567 #define priv_freeset(a) (0) 568 569 #define di_devlink_init(a, b) (NULL) 570 #define di_devlink_fini(a) (0) 571 typedef void *di_devlink_handle_t; 572 573 extern char *kmem_asprintf(const char *fmt, ...); 574 #define strfree(str) kmem_free((str), strlen(str)+1) 575 576 #define DEV_PHYS_PATH "phys_path" 577 578 #define DDI_SLEEP KM_SLEEP 579 #define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) 0 580 581 #else /* _KERNEL */ 582 583 #include <sys/systm.h> 584 #include <sys/kcondvar.h> 585 #include <sys/limits.h> 586 #include <sys/kmem.h> 587 #include <sys/param.h> 588 #include <sys/stdint.h> 589 #include <sys/note.h> 590 #include <sys/kernel.h> 591 #include <sys/kstat.h> 592 #include <sys/debug.h> 593 #include <sys/proc.h> 594 #include <sys/sysmacros.h> 595 #include <sys/bitmap.h> 596 #include <sys/cmn_err.h> 597 #include <sys/taskq.h> 598 #include <sys/conf.h> 599 #include <sys/mutex.h> 600 #include <sys/rwlock.h> 601 #include <sys/list.h> 602 #include <sys/uio.h> 603 #include <sys/dirent.h> 604 #include <sys/time.h> 605 #include <sys/uio.h> 606 #include <sys/fcntl.h> 607 #include <sys/string.h> 608 #include <sys/buf.h> 609 #include <sys/cred.h> 610 #include <sys/sdt.h> 611 #include <sys/file.h> 612 #include <sys/vfs.h> 613 #include <sys/lockf.h> 614 #include <sys/zone.h> 615 #include <sys/misc.h> 616 #include <sys/zfs_debug.h> 617 #include <sys/byteorder.h> 618 #include <sys/mman.h> 619 #include <sys/random.h> 620 #include <sys/pset.h> 621 #include <sys/u8_textprep.h> 622 #include <sys/sysevent.h> 623 #include <sys/sysevent/eventdefs.h> 624 625 #include <uvm/uvm_extern.h> 626 627 #define CPU_SEQID (curcpu()->ci_data.cpu_index) 628 #define lbolt hardclock_ticks 629 #define lbolt64 lbolt 630 631 clock_t ddi_get_lbolt(void); 632 int64_t ddi_get_lbolt64(void); 633 634 #ifdef __cplusplus 635 } 636 #endif 637 638 extern int zfs_debug_level; 639 extern kmutex_t zfs_debug_mtx; 640 #define ZFS_LOG(lvl, ...) do { \ 641 if (((lvl) & 0xff) <= zfs_debug_level) { \ 642 mutex_enter(&zfs_debug_mtx); \ 643 printf("%s:%u[%d]: ", __func__, __LINE__, (lvl)); \ 644 printf(__VA_ARGS__); \ 645 printf("\n"); \ 646 if ((lvl) & 0x100) \ 647 /* XXXNETBSD backtrace */ \ 648 mutex_exit(&zfs_debug_mtx); \ 649 } \ 650 } while (0) 651 652 extern struct utsname utsname; 653 654 #define makedevice(a, b) makedev(a, b) 655 #define getmajor(a) major(a) 656 #define getminor(a) minor(a) 657 #define issig(x) (sigispending(curlwp, 0)) 658 #define ISSIG(thr, why) (sigispending(thr, 0)) 659 #define fm_panic panic 660 661 #ifdef ptob 662 #undef ptob 663 #endif 664 #define ptob(x) ((x) * PAGE_SIZE) 665 666 #define strncat(a, b, c) strlcat(a, b, c) 667 #define tsd_get(x) lwp_getspecific(x) 668 #define tsd_set(x, y) (lwp_setspecific(x, y), 0) 669 #define kmem_debugging() 0 670 671 #define zone_get_hostid(a) 0 672 673 extern char *kmem_asprintf(const char *fmt, ...); 674 #define strfree(str) kmem_free((str), strlen(str)+1) 675 676 /* NetBSD doesn't need this routines in zfs code, yet */ 677 #define taskq_create_proc(a, b, c, d, e, p, f) \ 678 (taskq_create(a, b, c, d, e, f)) 679 #define taskq_create_sysdc(a, b, d, e, p, dc, f) \ 680 (taskq_create(a, b, maxclsyspri, d, e, f)) 681 682 #define MAXUID UID_MAX 683 #define FIGNORECASE 0 684 #define CREATE_XATTR_DIR 0 685 686 #define DEV_PHYS_PATH "phys_path" 687 688 #define DDI_SLEEP KM_SLEEP 689 #define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) 0 690 691 #define sys_shutdown 0 692 693 #endif /* _KERNEL */ 694 695 #endif /* _SYS_ZFS_CONTEXT_H */ 696