devfs.h revision 83366
171867Smsmith/*
271867Smsmith * Copyright (c) 1992, 1993
371867Smsmith *	The Regents of the University of California.  All rights reserved.
471867Smsmith * Copyright (c) 2000
571867Smsmith *	Poul-Henning Kamp.  All rights reserved.
671867Smsmith *
771867Smsmith * This code is derived from software donated to Berkeley by
871867Smsmith * Jan-Simon Pendry.
971867Smsmith *
1071867Smsmith * Redistribution and use in source and binary forms, with or without
1171867Smsmith * modification, are permitted provided that the following conditions
12193267Sjkim * are met:
1371867Smsmith * 1. Redistributions of source code must retain the above copyright
1471867Smsmith *    notice, this list of conditions and the following disclaimer.
1571867Smsmith * 2. Neither the name of the University nor the names of its contributors
1671867Smsmith *    may be used to endorse or promote products derived from this software
1771867Smsmith *    without specific prior written permission.
1871867Smsmith *
1971867Smsmith * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2071867Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2171867Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2271867Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2371867Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2471867Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2571867Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2671867Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2771867Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2871867Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2971867Smsmith * SUCH DAMAGE.
3071867Smsmith *
3171867Smsmith *	@(#)kernfs.h	8.6 (Berkeley) 3/29/95
3271867Smsmith * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14
3371867Smsmith *
3471867Smsmith * $FreeBSD: head/sys/fs/devfs/devfs.h 83366 2001-09-12 08:38:13Z julian $
3571867Smsmith */
3671867Smsmith
3771867Smsmith#ifndef _FS_DEVFS_DEVFS_H_
3871867Smsmith#define _FS_DEVFS_DEVFS_H_
3971867Smsmith
4071867Smsmith#ifdef _KERNEL	/* No userland stuff in here... */
4171867Smsmith
4271867Smsmith/*
4371867Smsmith * These are default sizes for the DEVFS inode table and the overflow
4471867Smsmith * table.  If the default table overflows we allocate the overflow
4571867Smsmith * table, the size of which can also be set with a sysctl.  If the
4671867Smsmith * overflow table fills you're toast.
4771867Smsmith */
4871867Smsmith#ifndef NDEVFSINO
4971867Smsmith#define NDEVFSINO 1024
5071867Smsmith#endif
5171867Smsmith
5271867Smsmith#ifndef NDEVFSOVERFLOW
5371867Smsmith#define NDEVFSOVERFLOW 32768
5471867Smsmith#endif
5571867Smsmith
5671867Smsmith/*
5771867Smsmith * This is the first "per mount" inode, these are used for directories
5871867Smsmith * and symlinks and the like.  Must be larger than the number of "true"
5971867Smsmith * device nodes and symlinks.  It is.
6071867Smsmith */
6171867Smsmith#define DEVFSINOMOUNT	0x2000000
6271867Smsmith
6371867SmsmithMALLOC_DECLARE(M_DEVFS);
6471867Smsmith
6571867Smsmithstruct devfs_dirent {
6671867Smsmith	int	de_inode;
6771867Smsmith	int	de_flags;
6871867Smsmith#define	DE_WHITEOUT	0x1
6971867Smsmith#define	DE_DOT		0x2
7071867Smsmith#define	DE_DOTDOT	0x4
7171867Smsmith	struct dirent *de_dirent;
7271867Smsmith	TAILQ_ENTRY(devfs_dirent) de_list;
7371867Smsmith	TAILQ_HEAD(, devfs_dirent) de_dlist;
7471867Smsmith	struct devfs_dirent *de_dir;
7571867Smsmith	int	de_links;
7671867Smsmith	mode_t	de_mode;
7771867Smsmith	uid_t	de_uid;
7871867Smsmith	gid_t	de_gid;
7971867Smsmith	struct timespec de_atime;
8071867Smsmith	struct timespec de_mtime;
8171867Smsmith	struct timespec de_ctime;
8271867Smsmith	struct vnode *de_vnode;
8371867Smsmith	char *	de_symlink;
8471867Smsmith};
8571867Smsmith
8671867Smsmithstruct devfs_mount {
8771867Smsmith	struct vnode	*dm_root;	/* Root node */
8871867Smsmith	struct devfs_dirent *dm_rootdir;
8971867Smsmith	struct devfs_dirent *dm_basedir;
9071867Smsmith	unsigned	dm_generation;
9171867Smsmith	struct devfs_dirent *dm_dirent[NDEVFSINO];
9271867Smsmith	struct devfs_dirent **dm_overflow;
9371867Smsmith	int	dm_inode;
9471867Smsmith	struct lock dm_lock;
9571867Smsmith};
9671867Smsmith
9771867Smsmith/*
9871867Smsmith * This is what we fill in dm_dirent[N] for a deleted entry.
9971867Smsmith */
10071867Smsmith#define DE_DELETED ((struct devfs_dirent *)sizeof(struct devfs_dirent))
10171867Smsmith
10271867Smsmith#define VFSTODEVFS(mp)	((struct devfs_mount *)((mp)->mnt_data))
10371867Smsmith
10471867Smsmithextern vop_t **devfs_vnodeop_p;
10571867Smsmithextern vop_t **devfs_specop_p;
10671867Smsmith
10771867Smsmithint devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td);
10871867Smsmithdev_t *devfs_itod (int inode);
10971867Smsmithstruct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode);
11071867Smsmithint devfs_populate (struct devfs_mount *dm);
11171867Smsmithstruct devfs_dirent *devfs_newdirent (char *name, int namelen);
11271867Smsmithvoid devfs_purge (struct devfs_dirent *dd);
11371867Smsmithstruct devfs_dirent *devfs_vmkdir (char *name, int namelen, struct devfs_dirent *dotdot);
11471867Smsmith
11571867Smsmith#endif /* _KERNEL */
11671867Smsmith#endif /* _FS_DEVFS_DEVFS_H_ */
117193341Sjkim