xref: /freebsd/sys/fs/devfs/devfs.h (revision 4cc62415576e6b06d9c5fac78b0a5e5a186b4e55)
14cc62415SBruce Evans /*-
23f54a085SPoul-Henning Kamp  * Copyright (c) 1992, 1993
33f54a085SPoul-Henning Kamp  *	The Regents of the University of California.  All rights reserved.
43f54a085SPoul-Henning Kamp  * Copyright (c) 2000
53f54a085SPoul-Henning Kamp  *	Poul-Henning Kamp.  All rights reserved.
63f54a085SPoul-Henning Kamp  *
73f54a085SPoul-Henning Kamp  * This code is derived from software donated to Berkeley by
83f54a085SPoul-Henning Kamp  * Jan-Simon Pendry.
93f54a085SPoul-Henning Kamp  *
103f54a085SPoul-Henning Kamp  * Redistribution and use in source and binary forms, with or without
113f54a085SPoul-Henning Kamp  * modification, are permitted provided that the following conditions
123f54a085SPoul-Henning Kamp  * are met:
133f54a085SPoul-Henning Kamp  * 1. Redistributions of source code must retain the above copyright
143f54a085SPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer.
153f54a085SPoul-Henning Kamp  * 2. Neither the name of the University nor the names of its contributors
163f54a085SPoul-Henning Kamp  *    may be used to endorse or promote products derived from this software
173f54a085SPoul-Henning Kamp  *    without specific prior written permission.
183f54a085SPoul-Henning Kamp  *
193f54a085SPoul-Henning Kamp  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
203f54a085SPoul-Henning Kamp  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
213f54a085SPoul-Henning Kamp  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
223f54a085SPoul-Henning Kamp  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
233f54a085SPoul-Henning Kamp  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
243f54a085SPoul-Henning Kamp  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
253f54a085SPoul-Henning Kamp  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
263f54a085SPoul-Henning Kamp  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
273f54a085SPoul-Henning Kamp  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
283f54a085SPoul-Henning Kamp  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
293f54a085SPoul-Henning Kamp  * SUCH DAMAGE.
303f54a085SPoul-Henning Kamp  *
313f54a085SPoul-Henning Kamp  *	@(#)kernfs.h	8.6 (Berkeley) 3/29/95
323f54a085SPoul-Henning Kamp  * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14
333f54a085SPoul-Henning Kamp  *
343f54a085SPoul-Henning Kamp  * $FreeBSD$
353f54a085SPoul-Henning Kamp  */
363f54a085SPoul-Henning Kamp 
3793bcdfe2SPoul-Henning Kamp #ifndef _FS_DEVFS_DEVFS_H_
3893bcdfe2SPoul-Henning Kamp #define	_FS_DEVFS_DEVFS_H_
393f54a085SPoul-Henning Kamp 
4093bcdfe2SPoul-Henning Kamp #ifdef _KERNEL	/* No userland stuff in here... */
413f54a085SPoul-Henning Kamp 
4293bcdfe2SPoul-Henning Kamp /*
4393bcdfe2SPoul-Henning Kamp  * These are default sizes for the DEVFS inode table and the overflow
4493bcdfe2SPoul-Henning Kamp  * table.  If the default table overflows we allocate the overflow
4593bcdfe2SPoul-Henning Kamp  * table, the size of which can also be set with a sysctl.  If the
4693bcdfe2SPoul-Henning Kamp  * overflow table fills you're toast.
4793bcdfe2SPoul-Henning Kamp  */
4893bcdfe2SPoul-Henning Kamp #ifndef NDEVFSINO
4993bcdfe2SPoul-Henning Kamp #define NDEVFSINO 1024
5093bcdfe2SPoul-Henning Kamp #endif
5193bcdfe2SPoul-Henning Kamp 
5293bcdfe2SPoul-Henning Kamp #ifndef NDEVFSOVERFLOW
5393bcdfe2SPoul-Henning Kamp #define NDEVFSOVERFLOW 32768
5493bcdfe2SPoul-Henning Kamp #endif
5593bcdfe2SPoul-Henning Kamp 
5693bcdfe2SPoul-Henning Kamp /*
5793bcdfe2SPoul-Henning Kamp  * This is the first "per mount" inode, these are used for directories
5893bcdfe2SPoul-Henning Kamp  * and symlinks and the like.  Must be larger than the number of "true"
5993bcdfe2SPoul-Henning Kamp  * device nodes and symlinks.  It is.
6093bcdfe2SPoul-Henning Kamp  */
6193bcdfe2SPoul-Henning Kamp #define DEVFSINOMOUNT	0x2000000
623f54a085SPoul-Henning Kamp 
634cc62415SBruce Evans #ifdef MALLOC_DECLARE
643f54a085SPoul-Henning Kamp MALLOC_DECLARE(M_DEVFS);
654cc62415SBruce Evans #endif
663f54a085SPoul-Henning Kamp 
673f54a085SPoul-Henning Kamp struct devfs_dirent {
683f54a085SPoul-Henning Kamp 	int	de_inode;
69a481b90bSPoul-Henning Kamp 	int	de_flags;
705a9300c4SPoul-Henning Kamp #define	DE_WHITEOUT	0x1
71a481b90bSPoul-Henning Kamp #define	DE_DOT		0x2
72a481b90bSPoul-Henning Kamp #define	DE_DOTDOT	0x4
733f54a085SPoul-Henning Kamp 	struct dirent *de_dirent;
743f54a085SPoul-Henning Kamp 	TAILQ_ENTRY(devfs_dirent) de_list;
75a481b90bSPoul-Henning Kamp 	TAILQ_HEAD(, devfs_dirent) de_dlist;
76a481b90bSPoul-Henning Kamp 	struct devfs_dirent *de_dir;
77a481b90bSPoul-Henning Kamp 	int	de_links;
783f54a085SPoul-Henning Kamp 	mode_t	de_mode;
793f54a085SPoul-Henning Kamp 	uid_t	de_uid;
803f54a085SPoul-Henning Kamp 	gid_t	de_gid;
813f54a085SPoul-Henning Kamp 	struct timespec de_atime;
823f54a085SPoul-Henning Kamp 	struct timespec de_mtime;
833f54a085SPoul-Henning Kamp 	struct timespec de_ctime;
843f54a085SPoul-Henning Kamp 	struct vnode *de_vnode;
853f54a085SPoul-Henning Kamp 	char *	de_symlink;
863f54a085SPoul-Henning Kamp };
873f54a085SPoul-Henning Kamp 
883f54a085SPoul-Henning Kamp struct devfs_mount {
893f54a085SPoul-Henning Kamp 	struct vnode	*dm_root;	/* Root node */
90a481b90bSPoul-Henning Kamp 	struct devfs_dirent *dm_rootdir;
91a481b90bSPoul-Henning Kamp 	struct devfs_dirent *dm_basedir;
923f54a085SPoul-Henning Kamp 	unsigned	dm_generation;
9393bcdfe2SPoul-Henning Kamp 	struct devfs_dirent *dm_dirent[NDEVFSINO];
9493bcdfe2SPoul-Henning Kamp 	struct devfs_dirent **dm_overflow;
953f54a085SPoul-Henning Kamp 	int	dm_inode;
9693bcdfe2SPoul-Henning Kamp 	struct lock dm_lock;
973f54a085SPoul-Henning Kamp };
983f54a085SPoul-Henning Kamp 
9993bcdfe2SPoul-Henning Kamp /*
10093bcdfe2SPoul-Henning Kamp  * This is what we fill in dm_dirent[N] for a deleted entry.
10193bcdfe2SPoul-Henning Kamp  */
10293bcdfe2SPoul-Henning Kamp #define DE_DELETED ((struct devfs_dirent *)sizeof(struct devfs_dirent))
103a481b90bSPoul-Henning Kamp 
1043f54a085SPoul-Henning Kamp #define VFSTODEVFS(mp)	((struct devfs_mount *)((mp)->mnt_data))
1053f54a085SPoul-Henning Kamp 
1063f54a085SPoul-Henning Kamp extern vop_t **devfs_vnodeop_p;
1073f54a085SPoul-Henning Kamp extern vop_t **devfs_specop_p;
108a481b90bSPoul-Henning Kamp 
109b40ce416SJulian Elischer int devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td);
11093bcdfe2SPoul-Henning Kamp dev_t *devfs_itod (int inode);
11193bcdfe2SPoul-Henning Kamp struct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode);
11293bcdfe2SPoul-Henning Kamp int devfs_populate (struct devfs_mount *dm);
11393bcdfe2SPoul-Henning Kamp struct devfs_dirent *devfs_newdirent (char *name, int namelen);
11493bcdfe2SPoul-Henning Kamp void devfs_purge (struct devfs_dirent *dd);
11593bcdfe2SPoul-Henning Kamp struct devfs_dirent *devfs_vmkdir (char *name, int namelen, struct devfs_dirent *dotdot);
11693bcdfe2SPoul-Henning Kamp 
1173f54a085SPoul-Henning Kamp #endif /* _KERNEL */
1184cc62415SBruce Evans 
1194cc62415SBruce Evans #endif /* !_FS_DEVFS_DEVFS_H_ */
120