devfs.h revision 95212
195212Sbde/*-
264880Sphk * Copyright (c) 1992, 1993
364880Sphk *	The Regents of the University of California.  All rights reserved.
464880Sphk * Copyright (c) 2000
564880Sphk *	Poul-Henning Kamp.  All rights reserved.
664880Sphk *
764880Sphk * This code is derived from software donated to Berkeley by
864880Sphk * Jan-Simon Pendry.
964880Sphk *
1064880Sphk * Redistribution and use in source and binary forms, with or without
1164880Sphk * modification, are permitted provided that the following conditions
1264880Sphk * are met:
1364880Sphk * 1. Redistributions of source code must retain the above copyright
1464880Sphk *    notice, this list of conditions and the following disclaimer.
1564880Sphk * 2. Neither the name of the University nor the names of its contributors
1664880Sphk *    may be used to endorse or promote products derived from this software
1764880Sphk *    without specific prior written permission.
1864880Sphk *
1964880Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2064880Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2164880Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2264880Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2364880Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2464880Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2564880Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2664880Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2764880Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2864880Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2964880Sphk * SUCH DAMAGE.
3064880Sphk *
3164880Sphk *	@(#)kernfs.h	8.6 (Berkeley) 3/29/95
3264880Sphk * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14
3364880Sphk *
3464880Sphk * $FreeBSD: head/sys/fs/devfs/devfs.h 95212 2002-04-21 15:47:03Z bde $
3564880Sphk */
3664880Sphk
3765515Sphk#ifndef _FS_DEVFS_DEVFS_H_
3895212Sbde#define	_FS_DEVFS_DEVFS_H_
3964880Sphk
4065515Sphk#ifdef _KERNEL	/* No userland stuff in here... */
4164880Sphk
4265515Sphk/*
4365515Sphk * These are default sizes for the DEVFS inode table and the overflow
4465515Sphk * table.  If the default table overflows we allocate the overflow
4565515Sphk * table, the size of which can also be set with a sysctl.  If the
4665515Sphk * overflow table fills you're toast.
4765515Sphk */
4865515Sphk#ifndef NDEVFSINO
4965515Sphk#define NDEVFSINO 1024
5065515Sphk#endif
5164880Sphk
5265515Sphk#ifndef NDEVFSOVERFLOW
5365515Sphk#define NDEVFSOVERFLOW 32768
5465515Sphk#endif
5565515Sphk
5665515Sphk/*
5765515Sphk * This is the first "per mount" inode, these are used for directories
5865515Sphk * and symlinks and the like.  Must be larger than the number of "true"
5965515Sphk * device nodes and symlinks.  It is.
6065515Sphk */
6165515Sphk#define DEVFSINOMOUNT	0x2000000
6265515Sphk
6395212Sbde#ifdef MALLOC_DECLARE
6464880SphkMALLOC_DECLARE(M_DEVFS);
6595212Sbde#endif
6664880Sphk
6764880Sphkstruct devfs_dirent {
6864880Sphk	int	de_inode;
6965051Sphk	int	de_flags;
7077050Sphk#define	DE_WHITEOUT	0x1
7165051Sphk#define	DE_DOT		0x2
7265051Sphk#define	DE_DOTDOT	0x4
7364880Sphk	struct dirent *de_dirent;
7464880Sphk	TAILQ_ENTRY(devfs_dirent) de_list;
7565051Sphk	TAILQ_HEAD(, devfs_dirent) de_dlist;
7665051Sphk	struct devfs_dirent *de_dir;
7765051Sphk	int	de_links;
7864880Sphk	mode_t	de_mode;
7964880Sphk	uid_t	de_uid;
8064880Sphk	gid_t	de_gid;
8164880Sphk	struct timespec de_atime;
8264880Sphk	struct timespec de_mtime;
8364880Sphk	struct timespec de_ctime;
8464880Sphk	struct vnode *de_vnode;
8564880Sphk	char *	de_symlink;
8664880Sphk};
8764880Sphk
8864880Sphkstruct devfs_mount {
8964880Sphk	struct vnode	*dm_root;	/* Root node */
9065051Sphk	struct devfs_dirent *dm_rootdir;
9165051Sphk	struct devfs_dirent *dm_basedir;
9264880Sphk	unsigned	dm_generation;
9365515Sphk	struct devfs_dirent *dm_dirent[NDEVFSINO];
9465515Sphk	struct devfs_dirent **dm_overflow;
9564880Sphk	int	dm_inode;
9665515Sphk	struct lock dm_lock;
9764880Sphk};
9864880Sphk
9965515Sphk/*
10065515Sphk * This is what we fill in dm_dirent[N] for a deleted entry.
10165515Sphk */
10265515Sphk#define DE_DELETED ((struct devfs_dirent *)sizeof(struct devfs_dirent))
10364880Sphk
10464880Sphk#define VFSTODEVFS(mp)	((struct devfs_mount *)((mp)->mnt_data))
10564880Sphk
10664880Sphkextern vop_t **devfs_vnodeop_p;
10764880Sphkextern vop_t **devfs_specop_p;
10865051Sphk
10983366Sjulianint devfs_allocv (struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, struct thread *td);
11065515Sphkdev_t *devfs_itod (int inode);
11165515Sphkstruct devfs_dirent **devfs_itode (struct devfs_mount *dm, int inode);
11265515Sphkint devfs_populate (struct devfs_mount *dm);
11365515Sphkstruct devfs_dirent *devfs_newdirent (char *name, int namelen);
11465515Sphkvoid devfs_purge (struct devfs_dirent *dd);
11565515Sphkstruct devfs_dirent *devfs_vmkdir (char *name, int namelen, struct devfs_dirent *dotdot);
11665515Sphk
11764880Sphk#endif /* _KERNEL */
11895212Sbde
11995212Sbde#endif /* !_FS_DEVFS_DEVFS_H_ */
120