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