devfs.h revision 65132
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 65132 2000-08-27 14:46:36Z phk $
35 */
36
37#ifdef _KERNEL
38
39#ifdef DEVFS_INTERN
40
41#define NDEVINO 1024
42
43MALLOC_DECLARE(M_DEVFS);
44
45struct devfs_dirent {
46	int	de_inode;
47	int	de_flags;
48#define	DE_ORPHAN	0x1
49#define	DE_DOT		0x2
50#define	DE_DOTDOT	0x4
51	struct dirent *de_dirent;
52	TAILQ_ENTRY(devfs_dirent) de_list;
53	TAILQ_HEAD(, devfs_dirent) de_dlist;
54	struct devfs_dirent *de_dir;
55	int	de_links;
56	mode_t	de_mode;
57	uid_t	de_uid;
58	gid_t	de_gid;
59	struct timespec de_atime;
60	struct timespec de_mtime;
61	struct timespec de_ctime;
62	struct vnode *de_vnode;
63	char *	de_symlink;
64};
65
66struct devfs_node {
67	struct kern_target *kf_kt;
68};
69
70struct devfs_mount {
71	struct vnode	*dm_root;	/* Root node */
72	struct devfs_dirent *dm_rootdir;
73	struct devfs_dirent *dm_basedir;
74	unsigned	dm_generation;
75	struct devfs_dirent *dm_dirent[NDEVINO];
76#define DE_DELETED ((struct devfs_dirent *)&devfs_inot[0])
77	int	dm_inode;
78};
79
80
81extern dev_t devfs_inot[NDEVINO];
82extern int devfs_nino;
83extern unsigned devfs_generation;
84
85
86#define VFSTODEVFS(mp)	((struct devfs_mount *)((mp)->mnt_data))
87
88extern vop_t **devfs_vnodeop_p;
89extern vop_t **devfs_specop_p;
90
91int devfs_allocv __P((struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct proc *p));
92struct devfs_dirent * devfs_find __P((struct devfs_dirent *dd, const char *name, int namelen));
93int devfs_populate __P((struct devfs_mount *dm));
94struct devfs_dirent * devfs_newdirent __P((char *name, int namelen));
95void devfs_purge __P((struct devfs_dirent *dd));
96struct devfs_dirent * devfs_vmkdir __P((char *name, int namelen,
97    struct devfs_dirent *dotdot));
98#endif /* DEVFS_INTERN */
99
100typedef void (*devfs_clone_fn) __P((void *arg, char *name, int namelen, dev_t *result));
101
102int devfs_stdclone __P((char *name, char **namep, char *stem, int *unit));
103EVENTHANDLER_DECLARE(devfs_clone, devfs_clone_fn);
104#endif /* _KERNEL */
105