devfs.h revision 64880
1/*
2 * Copyright (c) 1992, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 * Copyright (c) 2000
5 *	Poul-Henning Kamp.  All rights reserved.
6 *
7 * This code is derived from software donated to Berkeley by
8 * Jan-Simon Pendry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Neither the name of the University nor the names of its contributors
16 *    may be used to endorse or promote products derived from this software
17 *    without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 *	@(#)kernfs.h	8.6 (Berkeley) 3/29/95
32 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14
33 *
34 * $FreeBSD: head/sys/fs/devfs/devfs.h 64880 2000-08-20 21:34:39Z phk $
35 */
36
37#ifdef _KERNEL
38
39#ifdef DEVFS_INTERN
40
41#define NDEVINO 1024
42
43MALLOC_DECLARE(M_DEVFS);
44
45struct devfs_dir {
46	TAILQ_HEAD(, devfs_dirent) dd_list;
47};
48
49struct devfs_dirent {
50	int	de_inode;
51	struct dirent *de_dirent;
52	TAILQ_ENTRY(devfs_dirent) de_list;
53	struct devfs_dir *de_dir;
54	mode_t	de_mode;
55	uid_t	de_uid;
56	gid_t	de_gid;
57	struct timespec de_atime;
58	struct timespec de_mtime;
59	struct timespec de_ctime;
60	struct vnode *de_vnode;
61	char *	de_symlink;
62};
63
64struct devfs_node {
65	struct kern_target *kf_kt;
66};
67
68struct devfs_mount {
69	struct vnode	*dm_root;	/* Root node */
70	struct devfs_dir *dm_rootdir;
71	struct devfs_dir *dm_basedir;
72	unsigned	dm_generation;
73	struct devfs_dirent *dm_dirent[NDEVINO];
74	int	dm_inode;
75};
76
77
78extern dev_t devfs_inot[NDEVINO];
79extern int devfs_nino;
80extern unsigned devfs_generation;
81
82#define VFSTODEVFS(mp)	((struct devfs_mount *)((mp)->mnt_data))
83
84extern vop_t **devfs_vnodeop_p;
85extern vop_t **devfs_specop_p;
86int devfs_populate __P((struct devfs_mount *dm));
87struct devfs_dir * devfs_vmkdir __P((void));
88struct devfs_dirent * devfs_newdirent __P((char *name, int namelen));
89void devfs_purge __P((struct devfs_dir *dd));
90void devfs_delete __P((struct devfs_dir *dd, struct devfs_dirent *de));
91#endif /* DEVFS_INTERN */
92
93typedef void (*devfs_clone_fn) __P((void *arg, char *name, int namelen, dev_t *result));
94
95int devfs_stdclone __P((char *name, char **namep, char *stem, int *unit));
96EVENTHANDLER_DECLARE(devfs_clone, devfs_clone_fn);
97#endif /* _KERNEL */
98