1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright 2015, 2016 Joyent, Inc. All rights reserved. 24 * Copyright (c) 2014 by Delphix. All rights reserved. 25 */ 26 27 #ifndef _SYS_SDEV_IMPL_H 28 #define _SYS_SDEV_IMPL_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <rpc/rpc.h> 35 #include <sys/dirent.h> 36 #include <sys/vfs.h> 37 #include <sys/vfs_opreg.h> 38 #include <sys/list.h> 39 #include <sys/nvpair.h> 40 #include <sys/sunddi.h> 41 42 /* 43 * sdev_nodes are the file-system specific part of the 44 * vnodes for the device filesystem. 45 * 46 * The device filesystem exports two node types: 47 * 48 * VDIR nodes to represent directories 49 * VCHR & VBLK nodes to represent devices 50 */ 51 52 /* 53 * /dev mount arguments 54 */ 55 struct sdev_mountargs { 56 uint64_t sdev_attrdir; 57 }; 58 59 60 /* 61 * Nvpair names of profile information (list of device files available) of 62 * non-global /dev mounts. These strings must be unique among them. 63 */ 64 #define SDEV_NVNAME_MOUNTPT "prof_mountpt" 65 #define SDEV_NVNAME_INCLUDE "prof_include" 66 #define SDEV_NVNAME_EXCLUDE "prof_exclude" 67 #define SDEV_NVNAME_SYMLINK "prof_symlink" 68 #define SDEV_NVNAME_MAP "prof_map" 69 70 /* 71 * supported devfsadm_cmd 72 */ 73 #define DEVFSADMD_RUN_ALL 1 74 75 /* 76 * devfsadm_error codes 77 */ 78 #define DEVFSADM_RUN_INVALID 1 79 #define DEVFSADM_RUN_EPERM 2 80 #define DEVFSADM_RUN_NOTSUP 3 81 82 /* 83 * devfsadm/devname door data structures 84 */ 85 typedef struct sdev_door_arg { 86 uint8_t devfsadm_cmd; /* what to do for devfsadm[d] */ 87 } sdev_door_arg_t; 88 89 typedef struct sdev_door_res { 90 int32_t devfsadm_error; 91 } sdev_door_res_t; 92 93 #ifdef _KERNEL 94 95 struct sdev_dprof { 96 int has_glob; 97 nvlist_t *dev_name; 98 nvlist_t *dev_map; 99 nvlist_t *dev_symlink; 100 nvlist_t *dev_glob_incdir; 101 nvlist_t *dev_glob_excdir; 102 }; 103 104 /* 105 * devname_handle_t 106 */ 107 struct devname_handle { 108 struct sdev_node *dh_data; /* the sdev_node */ 109 void *dh_args; 110 }; 111 typedef struct devname_handle devname_handle_t; 112 113 /* 114 * Per-instance node data for the global zone instance 115 * Only one mount of /dev in the global zone 116 */ 117 typedef struct sdev_global_data { 118 struct devname_handle sdev_ghandle; 119 ulong_t sdev_dir_ggen; /* name space generation # */ 120 } sdev_global_data_t; 121 122 /* 123 * Per-instance node data - profile data per non-global zone mount instance 124 */ 125 typedef struct sdev_local_data { 126 ulong_t sdev_dir_lgen; /* cached generation # of /dev dir */ 127 ulong_t sdev_devtree_lgen; /* cached generation # of devtree */ 128 struct sdev_node *sdev_lorigin; /* corresponding global sdev_node */ 129 struct sdev_dprof sdev_lprof; /* profile for multi-inst */ 130 } sdev_local_data_t; 131 132 /* 133 * /dev filesystem sdev_node defines 134 */ 135 typedef struct sdev_node { 136 char *sdev_name; /* node name */ 137 size_t sdev_namelen; /* strlen(sdev_name) */ 138 char *sdev_path; /* absolute path */ 139 char *sdev_symlink; /* source for a symlink */ 140 struct vnode *sdev_vnode; /* vnode */ 141 142 krwlock_t sdev_contents; /* rw lock for this data structure */ 143 struct sdev_node *sdev_dotdot; /* parent */ 144 145 avl_tree_t sdev_entries; /* VDIR: contents as avl tree */ 146 avl_node_t sdev_avllink; /* avl node linkage */ 147 148 struct vnode *sdev_attrvp; /* backing store vnode if persisted */ 149 struct vattr *sdev_attr; /* memory copy of the vattr */ 150 151 ino64_t sdev_ino; /* inode */ 152 uint_t sdev_nlink; /* link count */ 153 int sdev_state; /* state of this node */ 154 int sdev_flags; /* flags bit */ 155 156 kmutex_t sdev_lookup_lock; /* node creation synch lock */ 157 kcondvar_t sdev_lookup_cv; /* node creation sync cv */ 158 int sdev_lookup_flags; /* node creation flags */ 159 160 /* per-instance data, either global or non-global zone */ 161 union { 162 struct sdev_global_data sdev_globaldata; 163 struct sdev_local_data sdev_localdata; 164 } sdev_instance_data; 165 166 void *sdev_private; 167 } sdev_node_t; 168 169 #define sdev_ldata sdev_instance_data.sdev_localdata 170 #define sdev_gdata sdev_instance_data.sdev_globaldata 171 172 #define sdev_handle sdev_gdata.sdev_ghandle 173 #define sdev_gdir_gen sdev_gdata.sdev_dir_ggen 174 175 #define sdev_ldir_gen sdev_ldata.sdev_dir_lgen 176 #define sdev_devtree_gen sdev_ldata.sdev_devtree_lgen 177 #define sdev_origin sdev_ldata.sdev_lorigin 178 #define sdev_prof sdev_ldata.sdev_lprof 179 180 /* 181 * Directory contents traversal 182 */ 183 #define SDEV_FIRST_ENTRY(ddv) avl_first(&(ddv)->sdev_entries) 184 #define SDEV_NEXT_ENTRY(ddv, dv) AVL_NEXT(&(ddv)->sdev_entries, (dv)) 185 186 /* 187 * See the big theory statement in sdev_vnops.c for an explanation of these 188 * states. 189 */ 190 typedef enum { 191 SDEV_ZOMBIE = -1, 192 SDEV_INIT = 0, 193 SDEV_READY 194 } sdev_node_state_t; 195 196 /* sdev_flags */ 197 #define SDEV_BUILD 0x0001 /* directory cache out-of-date */ 198 #define SDEV_GLOBAL 0x0002 /* global /dev nodes */ 199 #define SDEV_PERSIST 0x0004 /* backing store persisted node */ 200 #define SDEV_NO_NCACHE 0x0008 /* do not include in neg. cache */ 201 #define SDEV_DYNAMIC 0x0010 /* special-purpose vnode ops */ 202 /* (ex: pts) */ 203 #define SDEV_VTOR 0x0020 /* validate sdev_nodes during search */ 204 #define SDEV_ATTR_INVALID 0x0040 /* invalid node attributes, */ 205 /* need update */ 206 #define SDEV_SUBDIR 0x0080 /* match all subdirs under here */ 207 #define SDEV_ZONED 0x0100 /* zoned subdir */ 208 209 /* sdev_lookup_flags */ 210 #define SDEV_LOOKUP 0x0001 /* node creation in progress */ 211 #define SDEV_READDIR 0x0002 /* VDIR readdir in progress */ 212 #define SDEV_LGWAITING 0x0004 /* waiting for devfsadm completion */ 213 214 #define SDEV_VTOR_INVALID -1 215 #define SDEV_VTOR_SKIP 0 216 #define SDEV_VTOR_VALID 1 217 #define SDEV_VTOR_STALE 2 218 219 /* convenient macros */ 220 #define SDEV_IS_GLOBAL(dv) \ 221 (dv->sdev_flags & SDEV_GLOBAL) 222 #define SDEV_IS_PERSIST(dv) \ 223 (dv->sdev_flags & SDEV_PERSIST) 224 #define SDEV_IS_DYNAMIC(dv) \ 225 (dv->sdev_flags & SDEV_DYNAMIC) 226 #define SDEV_IS_NO_NCACHE(dv) \ 227 (dv->sdev_flags & SDEV_NO_NCACHE) 228 #define SDEV_IS_LOOKUP(dv) \ 229 (dv->sdev_lookup_flags & SDEV_LOOKUP) 230 #define SDEV_IS_READDIR(dv) \ 231 (dv->sdev_lookup_flags & SDEV_READDIR) 232 #define SDEV_IS_LGWAITING(dv) \ 233 (dv->sdev_lookup_flags & SDEV_LGWAITING) 234 235 #define SDEVTOV(n) ((struct vnode *)(n)->sdev_vnode) 236 #define VTOSDEV(vp) ((struct sdev_node *)(vp)->v_data) 237 #define VN_HELD(v) ((v)->v_count != 0) 238 #define SDEV_HELD(dv) (VN_HELD(SDEVTOV(dv))) 239 #define SDEV_HOLD(dv) VN_HOLD(SDEVTOV(dv)) 240 #define SDEV_RELE(dv) VN_RELE(SDEVTOV(dv)) 241 #define SDEV_SIMPLE_RELE(dv) { \ 242 mutex_enter(&SDEVTOV(dv)->v_lock); \ 243 SDEVTOV(dv)->v_count--; \ 244 mutex_exit(&SDEVTOV(dv)->v_lock); \ 245 } 246 247 #define SDEV_ACL_FLAVOR(vp) (VFSTOSDEVFS(vp->v_vfsp)->sdev_acl_flavor) 248 249 /* 250 * some defaults 251 */ 252 #define SDEV_ROOTINO ((ino_t)2) 253 #define SDEV_UID_DEFAULT (0) 254 #define SDEV_GID_DEFAULT (3) 255 #define SDEV_DIRMODE_DEFAULT (S_IFDIR |0755) 256 #define SDEV_DEVMODE_DEFAULT (0600) 257 #define SDEV_LNKMODE_DEFAULT (S_IFLNK | 0777) 258 259 extern struct vattr sdev_vattr_dir; 260 extern struct vattr sdev_vattr_lnk; 261 extern struct vattr sdev_vattr_blk; 262 extern struct vattr sdev_vattr_chr; 263 264 /* 265 * devname_lookup_func() 266 */ 267 extern int devname_lookup_func(struct sdev_node *, char *, struct vnode **, 268 struct cred *, int (*)(struct sdev_node *, char *, void **, struct cred *, 269 void *, char *), int); 270 271 /* 272 * flags used by devname_lookup_func callbacks 273 */ 274 #define SDEV_VATTR 0x4 /* callback returning node vattr */ 275 #define SDEV_VLINK 0x8 /* callback returning /dev link */ 276 277 /* 278 * devname_readdir_func() 279 */ 280 extern int devname_readdir_func(vnode_t *, uio_t *, cred_t *, int *, int); 281 282 /* 283 * flags for devname_readdir_func 284 */ 285 #define SDEV_BROWSE 0x1 /* fetch all entries from backing store */ 286 287 /* 288 * devname_setattr_func() 289 */ 290 extern int devname_setattr_func(struct vnode *, struct vattr *, int, 291 struct cred *, int (*)(struct sdev_node *, struct vattr *, int), int); 292 /* 293 * devname_inactive_func() 294 */ 295 extern void devname_inactive_func(struct vnode *, struct cred *, 296 void (*)(struct vnode *)); 297 298 /* 299 * /dev file system instance defines 300 */ 301 /* 302 * /dev version of vfs_data 303 */ 304 struct sdev_data { 305 struct sdev_data *sdev_prev; 306 struct sdev_data *sdev_next; 307 struct sdev_node *sdev_root; 308 struct vfs *sdev_vfsp; 309 struct sdev_mountargs *sdev_mountargs; 310 ulong_t sdev_acl_flavor; 311 }; 312 313 #define VFSTOSDEVFS(vfsp) ((struct sdev_data *)((vfsp)->vfs_data)) 314 315 /* 316 * sdev_fid overlays the fid structure (for VFS_VGET) 317 */ 318 struct sdev_fid { 319 uint16_t sdevfid_len; 320 ino32_t sdevfid_ino; 321 int32_t sdevfid_gen; 322 }; 323 324 /* 325 * devfsadm and devname communication defines 326 */ 327 typedef enum { 328 DEVNAME_DEVFSADM_STOPPED = 0, /* devfsadm has never run */ 329 DEVNAME_DEVFSADM_RUNNING, /* devfsadm is running */ 330 DEVNAME_DEVFSADM_RUN /* devfsadm ran once */ 331 } devname_devfsadm_state_t; 332 333 extern volatile uint_t devfsadm_state; /* atomic mask for devfsadm status */ 334 335 #define DEVNAME_DEVFSADM_SET_RUNNING(devfsadm_state) \ 336 (devfsadm_state = DEVNAME_DEVFSADM_RUNNING) 337 #define DEVNAME_DEVFSADM_SET_STOP(devfsadm_state) \ 338 (devfsadm_state = DEVNAME_DEVFSADM_STOPPED) 339 #define DEVNAME_DEVFSADM_SET_RUN(devfsadm_state) \ 340 (devfsadm_state = DEVNAME_DEVFSADM_RUN) 341 #define DEVNAME_DEVFSADM_IS_RUNNING(devfsadm_state) \ 342 (devfsadm_state == DEVNAME_DEVFSADM_RUNNING) 343 #define DEVNAME_DEVFSADM_HAS_RUN(devfsadm_state) \ 344 (devfsadm_state == DEVNAME_DEVFSADM_RUN) 345 346 #define SDEV_BLOCK_OTHERS(dv, cmd) { \ 347 ASSERT(MUTEX_HELD(&dv->sdev_lookup_lock)); \ 348 dv->sdev_lookup_flags |= cmd; \ 349 } 350 extern void sdev_unblock_others(struct sdev_node *, uint_t); 351 #define SDEV_UNBLOCK_OTHERS(dv, cmd) { \ 352 sdev_unblock_others(dv, cmd); \ 353 } 354 355 #define SDEV_CLEAR_LOOKUP_FLAGS(dv, cmd) { \ 356 dv->sdev_lookup_flags &= ~cmd; \ 357 } 358 359 extern int sdev_wait4lookup(struct sdev_node *, int); 360 extern int devname_filename_register(char *); 361 extern int devname_nsmaps_register(char *, size_t); 362 extern void sdev_devfsadm_lockinit(void); 363 extern void sdev_devfsadm_lockdestroy(void); 364 extern void devname_add_devfsadm_node(char *); 365 extern void sdev_devfsadmd_thread(struct sdev_node *, struct sdev_node *, 366 struct cred *); 367 extern int devname_profile_update(char *, size_t); 368 extern struct sdev_data *sdev_find_mntinfo(char *); 369 void sdev_mntinfo_rele(struct sdev_data *); 370 extern struct vnodeops *devpts_getvnodeops(void); 371 extern struct vnodeops *devvt_getvnodeops(void); 372 373 /* 374 * boot states - warning, the ordering here is significant 375 * 376 * the difference between "system available" and "boot complete" 377 * is a debounce timeout to catch some daemon issuing a readdir 378 * triggering a nuisance implict reconfig on each boot. 379 */ 380 #define SDEV_BOOT_STATE_INITIAL 0 381 #define SDEV_BOOT_STATE_RECONFIG 1 /* reconfig */ 382 #define SDEV_BOOT_STATE_SYSAVAIL 2 /* system available */ 383 #define SDEV_BOOT_STATE_COMPLETE 3 /* boot complete */ 384 385 /* 386 * Negative cache list and list element 387 * The mutex protects the flags against multiple accesses and 388 * must only be acquired when already holding the r/w lock. 389 */ 390 typedef struct sdev_nc_list { 391 list_t ncl_list; /* the list itself */ 392 kmutex_t ncl_mutex; /* protects ncl_flags */ 393 krwlock_t ncl_lock; /* protects ncl_list */ 394 int ncl_flags; 395 int ncl_nentries; 396 } sdev_nc_list_t; 397 398 typedef struct sdev_nc_node { 399 char *ncn_name; /* name of the node */ 400 int ncn_flags; /* state information */ 401 int ncn_expirecnt; /* remove once expired */ 402 list_node_t ncn_link; /* link to next in list */ 403 } sdev_nc_node_t; 404 405 /* ncl_flags */ 406 #define NCL_LIST_DIRTY 0x01 /* needs to be flushed */ 407 #define NCL_LIST_WRITING 0x02 /* write in progress */ 408 #define NCL_LIST_WENABLE 0x04 /* write-enabled post boot */ 409 410 /* ncn_flags */ 411 #define NCN_ACTIVE 0x01 /* a lookup has occurred */ 412 #define NCN_SRC_STORE 0x02 /* src: persistent store */ 413 #define NCN_SRC_CURRENT 0x04 /* src: current boot */ 414 415 /* sdev_lookup_failed flags */ 416 #define SLF_NO_NCACHE 0x01 /* node should not be added to ncache */ 417 #define SLF_REBUILT 0x02 /* reconfig performed during lookup attempt */ 418 419 /* 420 * The nvlist name and nvpair identifiers in the 421 * /etc/devices/devname_cache nvlist format 422 */ 423 #define DP_DEVNAME_ID "devname" 424 #define DP_DEVNAME_NCACHE_ID "ncache" 425 #define DP_DEVNAME_NC_EXPIRECNT_ID "expire-counts" 426 427 /* devname-cache list element */ 428 typedef struct nvp_devname { 429 char **nvp_paths; 430 int *nvp_expirecnts; 431 int nvp_npaths; 432 list_node_t nvp_link; 433 } nvp_devname_t; 434 435 /* 436 * name service globals and prototypes 437 */ 438 439 /* 440 * vnodeops and vfsops helpers 441 */ 442 443 typedef enum { 444 SDEV_CACHE_ADD = 0, 445 SDEV_CACHE_DELETE 446 } sdev_cache_ops_t; 447 448 extern struct sdev_node *sdev_cache_lookup(struct sdev_node *, char *); 449 extern void sdev_cache_update(struct sdev_node *, struct sdev_node **, char *, 450 sdev_cache_ops_t); 451 extern void sdev_node_cache_init(void); 452 extern void sdev_node_cache_fini(void); 453 extern struct sdev_node *sdev_mkroot(struct vfs *, dev_t, struct vnode *, 454 struct vnode *, struct cred *); 455 extern void sdev_filldir_dynamic(struct sdev_node *); 456 extern int sdev_mknode(struct sdev_node *, char *, struct sdev_node **, 457 struct vattr *, struct vnode *, void *, struct cred *, sdev_node_state_t); 458 extern int sdev_getlink(struct vnode *linkvp, char **link); 459 460 extern int sdev_nodeinit(struct sdev_node *, char *, struct sdev_node **, 461 vattr_t *); 462 extern int sdev_nodeready(struct sdev_node *, vattr_t *, vnode_t *, void *, 463 cred_t *); 464 extern int sdev_shadow_node(struct sdev_node *, struct cred *); 465 extern void sdev_nodedestroy(struct sdev_node *, uint_t); 466 extern void sdev_update_timestamps(struct vnode *, cred_t *, uint_t); 467 extern void sdev_vattr_merge(struct sdev_node *, struct vattr *); 468 extern void sdev_devstate_change(void); 469 extern int sdev_lookup_filter(sdev_node_t *, char *); 470 extern void sdev_lookup_failed(sdev_node_t *, char *, int); 471 extern int sdev_unlocked_access(void *, int, struct cred *); 472 473 #define SDEV_ENFORCE 0x1 474 extern void sdev_stale(struct sdev_node *); 475 extern int sdev_cleandir(struct sdev_node *, char *, uint_t); 476 extern int sdev_rnmnode(struct sdev_node *, struct sdev_node *, 477 struct sdev_node *, struct sdev_node **, char *, struct cred *); 478 extern size_t add_dir_entry(dirent64_t *, char *, size_t, ino_t, offset_t); 479 extern struct vattr *sdev_getdefault_attr(enum vtype type); 480 extern int sdev_to_vp(struct sdev_node *, struct vnode **); 481 extern ino_t sdev_mkino(struct sdev_node *); 482 extern int devname_backstore_lookup(struct sdev_node *, char *, 483 struct vnode **); 484 extern int sdev_is_devfs_node(char *); 485 extern int sdev_copyin_mountargs(struct mounta *, struct sdev_mountargs *); 486 extern int sdev_reserve_subdirs(struct sdev_node *); 487 extern int prof_lookup(); 488 extern void prof_filldir(struct sdev_node *); 489 extern int prof_name_matched(char *, struct sdev_node *); 490 extern int devpts_validate(struct sdev_node *dv); 491 extern int devnet_validate(struct sdev_node *dv); 492 extern int devipnet_validate(struct sdev_node *dv); 493 extern int devvt_validate(struct sdev_node *dv); 494 extern int devzvol_validate(struct sdev_node *dv); 495 extern void *sdev_get_vtor(struct sdev_node *dv); 496 497 /* 498 * devinfo helpers 499 */ 500 extern int sdev_modctl_readdir(const char *, char ***, int *, int *, int); 501 extern void sdev_modctl_readdir_free(char **, int, int); 502 extern int sdev_modctl_devexists(const char *); 503 504 /* 505 * ncache handlers 506 */ 507 508 extern void sdev_ncache_init(void); 509 extern void sdev_ncache_setup(void); 510 extern void sdev_ncache_teardown(void); 511 extern void sdev_nc_addname(sdev_nc_list_t *, sdev_node_t *, char *, int); 512 extern void sdev_nc_node_exists(sdev_node_t *); 513 extern void sdev_nc_path_exists(sdev_nc_list_t *, char *); 514 extern void sdev_modctl_dump_files(void); 515 516 /* 517 * globals 518 */ 519 extern kmutex_t sdev_lock; 520 extern int devtype; 521 extern kmem_cache_t *sdev_node_cache; 522 extern struct vnodeops *sdev_vnodeops; 523 extern struct vnodeops *devpts_vnodeops; 524 extern struct vnodeops *devnet_vnodeops; 525 extern struct vnodeops *devipnet_vnodeops; 526 extern struct vnodeops *devvt_vnodeops; 527 extern struct sdev_data *sdev_origins; /* mount info for global /dev instance */ 528 extern struct vnodeops *devzvol_vnodeops; 529 530 extern const fs_operation_def_t sdev_vnodeops_tbl[]; 531 extern const fs_operation_def_t devpts_vnodeops_tbl[]; 532 extern const fs_operation_def_t devnet_vnodeops_tbl[]; 533 extern const fs_operation_def_t devipnet_vnodeops_tbl[]; 534 extern const fs_operation_def_t devvt_vnodeops_tbl[]; 535 extern const fs_operation_def_t devsys_vnodeops_tbl[]; 536 extern const fs_operation_def_t devpseudo_vnodeops_tbl[]; 537 extern const fs_operation_def_t devzvol_vnodeops_tbl[]; 538 539 extern sdev_nc_list_t *sdev_ncache; 540 extern int sdev_reconfig_boot; 541 extern int sdev_boot_state; 542 extern int sdev_reconfig_verbose; 543 extern int sdev_reconfig_disable; 544 extern int sdev_nc_disable; 545 extern int sdev_nc_disable_reset; 546 extern int sdev_nc_verbose; 547 548 extern taskq_t *sdev_taskq; 549 550 /* 551 * misc. defines 552 */ 553 #ifdef DEBUG 554 extern int sdev_debug; 555 #define SDEV_DEBUG 0x01 /* error messages to console/log */ 556 #define SDEV_DEBUG_VOPS 0x02 /* vnode ops errors */ 557 #define SDEV_DEBUG_DLF 0x04 /* trace devname_lookup_func */ 558 #define SDEV_DEBUG_DRF 0x08 /* trace devname_readdir_func */ 559 #define SDEV_DEBUG_NCACHE 0x10 /* negative cache tracing */ 560 #define SDEV_DEBUG_DEVFSADMD 0x20 /* comm. of devnamefs & devfsadm */ 561 #define SDEV_DEBUG_PTS 0x40 /* /dev/pts tracing */ 562 #define SDEV_DEBUG_RECONFIG 0x80 /* events triggering reconfig */ 563 #define SDEV_DEBUG_SDEV_NODE 0x100 /* trace sdev_node activities */ 564 #define SDEV_DEBUG_PROFILE 0x200 /* trace sdev_profile */ 565 #define SDEV_DEBUG_MODCTL 0x400 /* trace modctl activity */ 566 #define SDEV_DEBUG_FLK 0x800 /* trace failed lookups */ 567 #define SDEV_DEBUG_NET 0x1000 /* /dev/net tracing */ 568 #define SDEV_DEBUG_ZVOL 0x2000 /* /dev/zvol/tracing */ 569 570 #define sdcmn_err(args) if (sdev_debug & SDEV_DEBUG) printf args 571 #define sdcmn_err2(args) if (sdev_debug & SDEV_DEBUG_VOPS) printf args 572 #define sdcmn_err3(args) if (sdev_debug & SDEV_DEBUG_DLF) printf args 573 #define sdcmn_err4(args) if (sdev_debug & SDEV_DEBUG_DRF) printf args 574 #define sdcmn_err5(args) if (sdev_debug & SDEV_DEBUG_NCACHE) printf args 575 #define sdcmn_err6(args) if (sdev_debug & SDEV_DEBUG_DEVFSADMD) printf args 576 #define sdcmn_err7(args) if (sdev_debug & SDEV_DEBUG_PTS) printf args 577 #define sdcmn_err8(args) if (sdev_debug & SDEV_DEBUG_RECONFIG) printf args 578 #define sdcmn_err9(args) if (sdev_debug & SDEV_DEBUG_SDEV_NODE) printf args 579 #define sdcmn_err10(args) if (sdev_debug & SDEV_DEBUG_PROFILE) printf args 580 #define sdcmn_err11(args) if (sdev_debug & SDEV_DEBUG_MODCTL) printf args 581 #define sdcmn_err12(args) if (sdev_debug & SDEV_DEBUG_NET) printf args 582 #define sdcmn_err13(args) if (sdev_debug & SDEV_DEBUG_ZVOL) printf args 583 #define impossible(args) printf args 584 #else 585 #define sdcmn_err(args) ((void)0) 586 #define sdcmn_err2(args) ((void)0) 587 #define sdcmn_err3(args) ((void)0) 588 #define sdcmn_err4(args) ((void)0) 589 #define sdcmn_err5(args) ((void)0) 590 #define sdcmn_err6(args) ((void)0) 591 #define sdcmn_err7(args) ((void)0) 592 #define sdcmn_err8(args) ((void)0) 593 #define sdcmn_err9(args) ((void)0) 594 #define sdcmn_err10(args) ((void)0) 595 #define sdcmn_err11(args) ((void)0) 596 #define sdcmn_err12(args) ((void)0) 597 #define sdcmn_err13(args) ((void)0) 598 #define impossible(args) ((void)0) 599 #endif 600 601 #ifdef DEBUG 602 #define SD_TRACE_FAILED_LOOKUP(ddv, nm, retried) \ 603 if ((sdev_debug & SDEV_DEBUG_FLK) || \ 604 ((retried) && (sdev_debug & SDEV_DEBUG_RECONFIG))) { \ 605 printf("lookup of %s/%s by %s failed, line %d\n", \ 606 (ddv)->sdev_name, (nm), curproc->p_user.u_comm, \ 607 __LINE__); \ 608 } 609 #else 610 #define SD_TRACE_FAILED_LOOKUP(ddv, nm, retried) ((void)0) 611 #endif 612 613 #endif /* _KERNEL */ 614 615 #ifdef __cplusplus 616 } 617 #endif 618 619 #endif /* _SYS_SDEV_IMPL_H */ 620