devfs.h revision 95212
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 95212 2002-04-21 15:47:03Z bde $
35 */
36
37#ifndef _FS_DEVFS_DEVFS_H_
38#define	_FS_DEVFS_DEVFS_H_
39
40#ifdef _KERNEL	/* No userland stuff in here... */
41
42/*
43 * These are default sizes for the DEVFS inode table and the overflow
44 * table.  If the default table overflows we allocate the overflow
45 * table, the size of which can also be set with a sysctl.  If the
46 * overflow table fills you're toast.
47 */
48#ifndef NDEVFSINO
49#define NDEVFSINO 1024
50#endif
51
52#ifndef NDEVFSOVERFLOW
53#define NDEVFSOVERFLOW 32768
54#endif
55
56/*
57 * This is the first "per mount" inode, these are used for directories
58 * and symlinks and the like.  Must be larger than the number of "true"
59 * device nodes and symlinks.  It is.
60 */
61#define DEVFSINOMOUNT	0x2000000
62
63#ifdef MALLOC_DECLARE
64MALLOC_DECLARE(M_DEVFS);
65#endif
66
67struct devfs_dirent {
68	int	de_inode;
69	int	de_flags;
70#define	DE_WHITEOUT	0x1
71#define	DE_DOT		0x2
72#define	DE_DOTDOT	0x4
73	struct dirent *de_dirent;
74	TAILQ_ENTRY(devfs_dirent) de_list;
75	TAILQ_HEAD(, devfs_dirent) de_dlist;
76	struct devfs_dirent *de_dir;
77	int	de_links;
78	mode_t	de_mode;
79	uid_t	de_uid;
80	gid_t	de_gid;
81	struct timespec de_atime;
82	struct timespec de_mtime;
83	struct timespec de_ctime;
84	struct vnode *de_vnode;
85	char *	de_symlink;
86};
87
88struct devfs_mount {
89	struct vnode	*dm_root;	/* Root node */
90	struct devfs_dirent *dm_rootdir;
91	struct devfs_dirent *dm_basedir;
92	unsigned	dm_generation;
93	struct devfs_dirent *dm_dirent[NDEVFSINO];
94	struct devfs_dirent **dm_overflow;
95	int	dm_inode;
96	struct lock dm_lock;
97};
98
99/*
100 * This is what we fill in dm_dirent[N] for a deleted entry.
101 */
102#define DE_DELETED ((struct devfs_dirent *)sizeof(struct devfs_dirent))
103
104#define VFSTODEVFS(mp)	((struct devfs_mount *)((mp)->mnt_data))
105
106extern vop_t **devfs_vnodeop_p;
107extern vop_t **devfs_specop_p;
108
109int devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td);
110dev_t *devfs_itod (int inode);
111struct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode);
112int devfs_populate (struct devfs_mount *dm);
113struct devfs_dirent *devfs_newdirent (char *name, int namelen);
114void devfs_purge (struct devfs_dirent *dd);
115struct devfs_dirent *devfs_vmkdir (char *name, int namelen, struct devfs_dirent *dotdot);
116
117#endif /* _KERNEL */
118
119#endif /* !_FS_DEVFS_DEVFS_H_ */
120