diff options
author | des <des@FreeBSD.org> | 2000-12-28 12:17:35 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2000-12-28 12:17:35 +0000 |
commit | cff7c7e7189924b0099e5d77cf42b5c208fcfa3e (patch) | |
tree | 615bab6fdc680e83466134b3188b4a53627590d3 | |
parent | 81027b8ec1e26f01ddf898f1683f94cc211ade80 (diff) | |
download | FreeBSD-src-cff7c7e7189924b0099e5d77cf42b5c208fcfa3e.zip FreeBSD-src-cff7c7e7189924b0099e5d77cf42b5c208fcfa3e.tar.gz |
Retire kernfs (kernel part).
-rw-r--r-- | sys/boot/forth/loader.conf | 1 | ||||
-rw-r--r-- | sys/conf/NOTES | 1 | ||||
-rw-r--r-- | sys/conf/files | 2 | ||||
-rw-r--r-- | sys/conf/options | 1 | ||||
-rw-r--r-- | sys/i386/conf/NOTES | 1 | ||||
-rw-r--r-- | sys/kern/Make.tags.inc | 2 | ||||
-rw-r--r-- | sys/kern/Makefile | 2 | ||||
-rw-r--r-- | sys/miscfs/kernfs/kernfs.h | 55 | ||||
-rw-r--r-- | sys/miscfs/kernfs/kernfs_vfsops.c | 237 | ||||
-rw-r--r-- | sys/miscfs/kernfs/kernfs_vnops.c | 610 | ||||
-rw-r--r-- | sys/modules/Makefile | 2 | ||||
-rw-r--r-- | sys/modules/kernfs/Makefile | 9 |
12 files changed, 2 insertions, 921 deletions
diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf index a6cddb9..faeefcd 100644 --- a/sys/boot/forth/loader.conf +++ b/sys/boot/forth/loader.conf @@ -85,7 +85,6 @@ module_path="/boot/kernel;/boot/modules;/modules" # Set the module search path cd9660_load="NO" # ISO 9660 filesystem coda_load="NO" # CODA filesystem fdesc_load="NO" # Filedescriptors filesystem -kernfs_load="NO" # Kernel filesystem mfs_load="NO" # Memory filesystem msdos_load="NO" # FAT-12/16/32 nfs_load="NO" # NFS diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 773d6da..5034885 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -667,7 +667,6 @@ options NFS #Network File System #options NFS_NOSERVER #Disable the NFS-server code. options CD9660 #ISO 9660 filesystem options FDESC #File descriptor filesystem -options KERNFS #Kernel filesystem options MSDOSFS #MS DOS File System (FAT, FAT32) options NTFS #NT File System options NULLFS #NULL filesystem diff --git a/sys/conf/files b/sys/conf/files index e53a564..fd1f413 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -737,8 +737,6 @@ miscfs/deadfs/dead_vnops.c standard miscfs/fdesc/fdesc_vfsops.c optional fdesc miscfs/fdesc/fdesc_vnops.c optional fdesc miscfs/fifofs/fifo_vnops.c standard -miscfs/kernfs/kernfs_vfsops.c optional kernfs -miscfs/kernfs/kernfs_vnops.c optional kernfs miscfs/nullfs/null_subr.c optional nullfs miscfs/nullfs/null_vfsops.c optional nullfs miscfs/nullfs/null_vnops.c optional nullfs diff --git a/sys/conf/options b/sys/conf/options index 098289e..5db79d1 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -107,7 +107,6 @@ INCLUDE_CONFIG_FILE opt_config.h # options in a never-included header. EXT2FS opt_dontuse.h FDESC opt_dontuse.h -KERNFS opt_dontuse.h MFS opt_dontuse.h MSDOSFS opt_dontuse.h NULLFS opt_dontuse.h diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 773d6da..5034885 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -667,7 +667,6 @@ options NFS #Network File System #options NFS_NOSERVER #Disable the NFS-server code. options CD9660 #ISO 9660 filesystem options FDESC #File descriptor filesystem -options KERNFS #Kernel filesystem options MSDOSFS #MS DOS File System (FAT, FAT32) options NTFS #NT File System options NULLFS #NULL filesystem diff --git a/sys/kern/Make.tags.inc b/sys/kern/Make.tags.inc index a6e6f5c..8c3855a 100644 --- a/sys/kern/Make.tags.inc +++ b/sys/kern/Make.tags.inc @@ -34,7 +34,6 @@ COMM= ${SYS}/conf/*.[ch] \ ${SYS}/miscfs/devfs/*.[ch] \ ${SYS}/miscfs/fdesc/*.[ch] \ ${SYS}/miscfs/fifofs/*.[ch] \ - ${SYS}/miscfs/kernfs/*.[ch] \ ${SYS}/miscfs/nullfs/*.[ch] \ ${SYS}/miscfs/portal/*.[ch] \ ${SYS}/miscfs/procfs/*.[ch] \ @@ -98,7 +97,6 @@ COMMDIR2= ${SYS}/dev/advansys \ ${SYS}/miscfs/devfs \ ${SYS}/miscfs/fdesc \ ${SYS}/miscfs/fifofs \ - ${SYS}/miscfs/kernfs \ ${SYS}/miscfs/nullfs \ ${SYS}/miscfs/portal \ ${SYS}/miscfs/procfs \ diff --git a/sys/kern/Makefile b/sys/kern/Makefile index ba453b2..37f03ab 100644 --- a/sys/kern/Makefile +++ b/sys/kern/Makefile @@ -35,7 +35,7 @@ DGEN= conf \ dev dev/scsi \ hp hp/dev hp/hpux \ kern libkern \ - miscfs miscfs/deadfs miscfs/fdesc miscfs/fifofs miscfs/kernfs \ + miscfs miscfs/deadfs miscfs/fdesc miscfs/fifofs \ miscfs/lofs miscfs/nullfs miscfs/portal miscfs/procfs \ miscfs/specfs miscfs/umapfs miscfs/union \ net netccitt netinet netiso netns nfs scripts sys \ diff --git a/sys/miscfs/kernfs/kernfs.h b/sys/miscfs/kernfs/kernfs.h deleted file mode 100644 index 2f0bb26..0000000 --- a/sys/miscfs/kernfs/kernfs.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)kernfs.h 8.6 (Berkeley) 3/29/95 - * $FreeBSD$ - */ - -#define _PATH_KERNFS "/kern" /* Default mountpoint */ - -#ifdef _KERNEL -struct kernfs_mount { - struct vnode *kf_root; /* Root node */ -}; - -struct kernfs_node { - struct kern_target *kf_kt; -}; - -#define VFSTOKERNFS(mp) ((struct kernfs_mount *)((mp)->mnt_data)) -#define VTOKERN(vp) ((struct kernfs_node *)(vp)->v_data) - -extern vop_t **kernfs_vnodeop_p; -#endif /* _KERNEL */ diff --git a/sys/miscfs/kernfs/kernfs_vfsops.c b/sys/miscfs/kernfs/kernfs_vfsops.c deleted file mode 100644 index dc8d43c..0000000 --- a/sys/miscfs/kernfs/kernfs_vfsops.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 1992, 1993, 1995 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)kernfs_vfsops.c 8.10 (Berkeley) 5/14/95 - * $FreeBSD$ - */ - -/* - * Kernel params Filesystem - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/conf.h> -#include <sys/vnode.h> -#include <sys/mount.h> -#include <sys/malloc.h> - -#include <miscfs/kernfs/kernfs.h> - -static MALLOC_DEFINE(M_KERNFSMNT, "KERNFS mount", "KERNFS mount structure"); - -static int kernfs_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); -static int kernfs_unmount __P((struct mount *mp, int mntflags, - struct proc *p)); -static int kernfs_root __P((struct mount *mp, struct vnode **vpp)); -static int kernfs_statfs __P((struct mount *mp, struct statfs *sbp, - struct proc *p)); - -/* - * Mount the Kernel params filesystem - */ -static int -kernfs_mount(mp, path, data, ndp, p) - struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; -{ - int error = 0; - size_t size; - struct kernfs_mount *fmp; - struct vnode *rvp; - -#ifdef DEBUG - printf("kernfs_mount(mp = %p)\n", (void *)mp); -#endif - - /* - * Update is a no-op - */ - if (mp->mnt_flag & MNT_UPDATE) - return (EOPNOTSUPP); - - MALLOC(fmp, struct kernfs_mount *, sizeof(struct kernfs_mount), - M_KERNFSMNT, M_WAITOK); /* XXX */ - - error = getnewvnode(VT_KERNFS, mp, kernfs_vnodeop_p, &rvp); /* XXX */ - if (error) { - FREE(fmp, M_KERNFSMNT); - return (error); - } - - rvp->v_type = VDIR; - rvp->v_flag |= VROOT; -#ifdef DEBUG - printf("kernfs_mount: root vp = %p\n", (void *)rvp); -#endif - fmp->kf_root = rvp; - mp->mnt_flag |= MNT_LOCAL; - mp->mnt_data = (qaddr_t) fmp; - vfs_getnewfsid(mp); - - (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); - bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); - bzero(mp->mnt_stat.f_mntfromname, MNAMELEN); - bcopy("kernfs", mp->mnt_stat.f_mntfromname, sizeof("kernfs")); - (void)kernfs_statfs(mp, &mp->mnt_stat, p); -#ifdef DEBUG - printf("kernfs_mount: at %s\n", mp->mnt_stat.f_mntonname); -#endif - - return (0); -} - -static int -kernfs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; -{ - int error; - int flags = 0; - struct vnode *rootvp = VFSTOKERNFS(mp)->kf_root; - -#ifdef DEBUG - printf("kernfs_unmount(mp = %p)\n", (void *)mp); -#endif - - if (mntflags & MNT_FORCE) - flags |= FORCECLOSE; - - /* - * Clear out buffer cache. I don't think we - * ever get anything cached at this level at the - * moment, but who knows... - */ - if (rootvp->v_usecount > 1) - return (EBUSY); -#ifdef DEBUG - printf("kernfs_unmount: calling vflush\n"); -#endif - error = vflush(mp, rootvp, flags); - if (error) - return (error); - -#ifdef DEBUG - vprint("kernfs root", rootvp); -#endif - /* - * Release reference on underlying root vnode - */ - vrele(rootvp); - /* - * And blow it away for future re-use - */ - vgone(rootvp); - /* - * Finally, throw away the kernfs_mount structure - */ - free(mp->mnt_data, M_KERNFSMNT); /* XXX */ - mp->mnt_data = 0; - return 0; -} - -static int -kernfs_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; -{ - struct proc *p = curproc; /* XXX */ - struct vnode *vp; - -#ifdef DEBUG - printf("kernfs_root(mp = %p)\n", (void *)mp); -#endif - - /* - * Return locked reference to root. - */ - vp = VFSTOKERNFS(mp)->kf_root; - VREF(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - *vpp = vp; - return (0); -} - -static int -kernfs_statfs(mp, sbp, p) - struct mount *mp; - struct statfs *sbp; - struct proc *p; -{ -#ifdef DEBUG - printf("kernfs_statfs(mp = %p)\n", (void *)mp); -#endif - - sbp->f_flags = 0; - sbp->f_bsize = DEV_BSIZE; - sbp->f_iosize = DEV_BSIZE; - sbp->f_blocks = 2; /* 1K to keep df happy */ - sbp->f_bfree = 0; - sbp->f_bavail = 0; - sbp->f_files = 0; - sbp->f_ffree = 0; - if (sbp != &mp->mnt_stat) { - sbp->f_type = mp->mnt_vfc->vfc_typenum; - bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid)); - bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); - bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); - } - return (0); -} - -static struct vfsops kernfs_vfsops = { - kernfs_mount, - vfs_stdstart, - kernfs_unmount, - kernfs_root, - vfs_stdquotactl, - kernfs_statfs, - vfs_stdsync, - vfs_stdvget, - vfs_stdfhtovp, - vfs_stdcheckexp, - vfs_stdvptofh, - vfs_stdinit, - vfs_stduninit, - vfs_stdextattrctl, -}; - -VFS_SET(kernfs_vfsops, kernfs, VFCF_SYNTHETIC); diff --git a/sys/miscfs/kernfs/kernfs_vnops.c b/sys/miscfs/kernfs/kernfs_vnops.c deleted file mode 100644 index 72b8e78..0000000 --- a/sys/miscfs/kernfs/kernfs_vnops.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)kernfs_vnops.c 8.15 (Berkeley) 5/21/95 - * $FreeBSD$ - */ - -/* - * Kernel parameter filesystem (/kern) - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/vmmeter.h> -#include <sys/time.h> -#include <sys/vnode.h> -#include <sys/malloc.h> -#include <sys/stat.h> -#include <sys/mount.h> -#include <sys/namei.h> -#include <sys/dirent.h> -#include <sys/resource.h> - -#include <miscfs/kernfs/kernfs.h> - -#define KSTRING 256 /* Largest I/O available via this filesystem */ -#define UIO_MX 32 - -#define READ_MODE (S_IRUSR|S_IRGRP|S_IROTH) -#define WRITE_MODE (S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH) -#define DIR_MODE (S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) - -static struct kern_target { - u_char kt_type; - u_char kt_namlen; - char *kt_name; - void *kt_data; -#define KTT_NULL 1 -#define KTT_TIME 5 -#define KTT_INT 17 -#define KTT_STRING 31 -#define KTT_HOSTNAME 47 -#define KTT_BOOTFILE 49 -#define KTT_AVENRUN 53 - u_char kt_tag; - u_char kt_vtype; - mode_t kt_mode; -} kern_targets[] = { -/* NOTE: The name must be less than UIO_MX-16 chars in length */ -#define N(s) sizeof(s)-1, s - /* name data tag type ro/rw */ - { DT_DIR, N("."), 0, KTT_NULL, VDIR, DIR_MODE }, - { DT_DIR, N(".."), 0, KTT_NULL, VDIR, DIR_MODE }, - { DT_REG, N("boottime"), &boottime.tv_sec, KTT_INT, VREG, READ_MODE }, - { DT_REG, N("copyright"), copyright, KTT_STRING, VREG, READ_MODE }, - { DT_REG, N("hostname"), 0, KTT_HOSTNAME, VREG, WRITE_MODE }, - { DT_REG, N("bootfile"), 0, KTT_BOOTFILE, VREG, READ_MODE }, - { DT_REG, N("hz"), &hz, KTT_INT, VREG, READ_MODE }, - { DT_REG, N("loadavg"), 0, KTT_AVENRUN, VREG, READ_MODE }, - { DT_REG, N("pagesize"), &cnt.v_page_size, KTT_INT, VREG, READ_MODE }, - { DT_REG, N("physmem"), &physmem, KTT_INT, VREG, READ_MODE }, - { DT_REG, N("time"), 0, KTT_TIME, VREG, READ_MODE }, - { DT_REG, N("version"), version, KTT_STRING, VREG, READ_MODE }, -#undef N -}; -static int nkern_targets = sizeof(kern_targets) / sizeof(kern_targets[0]); - -static int kernfs_access __P((struct vop_access_args *ap)); -static int kernfs_badop __P((void)); -static int kernfs_getattr __P((struct vop_getattr_args *ap)); -static int kernfs_inactive __P((struct vop_inactive_args *ap)); -static int kernfs_lookup __P((struct vop_lookup_args *ap)); -static int kernfs_print __P((struct vop_print_args *ap)); -static int kernfs_read __P((struct vop_read_args *ap)); -static int kernfs_readdir __P((struct vop_readdir_args *ap)); -static int kernfs_reclaim __P((struct vop_reclaim_args *ap)); -static int kernfs_setattr __P((struct vop_setattr_args *ap)); -static int kernfs_write __P((struct vop_write_args *ap)); -static int kernfs_xread __P((struct kern_target *kt, char *buf, int len, - int *lenp)); -static int kernfs_xwrite __P((struct kern_target *kt, char *buf, int len)); - -static int -kernfs_xread(kt, buf, len, lenp) - struct kern_target *kt; - char *buf; - int len; - int *lenp; -{ - - switch (kt->kt_tag) { - case KTT_TIME: { - struct timeval tv; - microtime(&tv); - snprintf(buf, len, "%ld %ld\n", tv.tv_sec, tv.tv_usec); - break; - } - - case KTT_INT: { - int *ip = kt->kt_data; - snprintf(buf, len, "%d\n", *ip); - break; - } - - case KTT_STRING: { - char *cp = kt->kt_data; - int xlen = strlen(cp) + 1; - - if (xlen >= len) - return (EINVAL); - - bcopy(cp, buf, xlen); - break; - } - - case KTT_HOSTNAME: { - char *cp = hostname; - int xlen = strlen(hostname); - - if (xlen >= (len-2)) - return (EINVAL); - - bcopy(cp, buf, xlen); - buf[xlen] = '\n'; - buf[xlen+1] = '\0'; - break; - } - - case KTT_BOOTFILE: { - char *cp = kernelname; - int xlen = strlen(cp) + 1; - - if (xlen >= (len-2)) - return (EINVAL); - - bcopy(cp, buf, xlen); - buf[xlen] = '\n'; - buf[xlen+1] = '\0'; - break; - } - - case KTT_AVENRUN: - snprintf(buf, len, "%lu %lu %lu %ld\n", - (u_long)averunnable.ldavg[0], (u_long)averunnable.ldavg[1], - (u_long)averunnable.ldavg[2], averunnable.fscale); - break; - - default: - return (EIO); - } - - *lenp = strlen(buf); - return (0); -} - -static int -kernfs_xwrite(kt, buf, len) - struct kern_target *kt; - char *buf; - int len; -{ - - switch (kt->kt_tag) { - case KTT_HOSTNAME: - /* XXX BOGUS !!! no check for the length */ - if (buf[len-1] == '\n') - --len; - bcopy(buf, hostname, len); - hostname[len] = '\0'; - return (0); - - default: - return (EIO); - } -} - - -/* - * vp is the current namei directory - * ndp is the name to locate in that directory... - */ -static int -kernfs_lookup(ap) - struct vop_lookup_args /* { - struct vnode * a_dvp; - struct vnode ** a_vpp; - struct componentname * a_cnp; - } */ *ap; -{ - struct componentname *cnp = ap->a_cnp; - struct vnode **vpp = ap->a_vpp; - struct vnode *dvp = ap->a_dvp; - char *pname = cnp->cn_nameptr; - struct proc *p = cnp->cn_proc; - struct kern_target *kt; - struct vnode *fvp; - int error, i; - -#ifdef DEBUG - printf("kernfs_lookup(%p)\n", (void *)ap); - printf("kernfs_lookup(dp = %p, vpp = %p, cnp = %p)\n", - (void *)dvp, (void *)vpp, (void *)ap->a_cnp); - printf("kernfs_lookup(%s)\n", pname); -#endif - - *vpp = NULLVP; - - if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) - return (EROFS); - - VOP_UNLOCK(dvp, 0, p); - if (cnp->cn_namelen == 1 && *pname == '.') { - *vpp = dvp; - VREF(dvp); - vn_lock(dvp, LK_SHARED | LK_RETRY, p); - return (0); - } - -#if 0 - if (cnp->cn_namelen == 4 && bcmp(pname, "root", 4) == 0) { - *vpp = rootdir; - VREF(rootdir); - vn_lock(rootdir, LK_SHARED | LK_RETRY, p) - return (0); - } -#endif - - for (kt = kern_targets, i = 0; i < nkern_targets; kt++, i++) { - if (cnp->cn_namelen == kt->kt_namlen && - bcmp(kt->kt_name, pname, cnp->cn_namelen) == 0) - goto found; - } - -#ifdef DEBUG - printf("kernfs_lookup: i = %d, failed", i); -#endif - - vn_lock(dvp, LK_SHARED | LK_RETRY, p); - return (cnp->cn_nameiop == LOOKUP ? ENOENT : EROFS); - -found: - -#ifdef DEBUG - printf("kernfs_lookup: allocate new vnode\n"); -#endif - if ((error = getnewvnode(VT_KERNFS, dvp->v_mount, kernfs_vnodeop_p, - &fvp)) != 0) { - vn_lock(dvp, LK_SHARED | LK_RETRY, p); - return (error); - } - - MALLOC(fvp->v_data, void *, sizeof(struct kernfs_node), M_TEMP, - M_WAITOK); - VTOKERN(fvp)->kf_kt = kt; - fvp->v_type = kt->kt_vtype; - vn_lock(fvp, LK_SHARED | LK_RETRY, p); - *vpp = fvp; - -#ifdef DEBUG - printf("kernfs_lookup: newvp = %p\n", (void *)fvp); -#endif - return (0); -} - -static int -kernfs_access(ap) - struct vop_access_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; -{ - register struct vnode *vp = ap->a_vp; - mode_t amode = ap->a_mode; - mode_t fmode = - (vp->v_flag & VROOT) ? DIR_MODE : VTOKERN(vp)->kf_kt->kt_mode; - - /* Some files are simply not modifiable. */ - if ((amode & VWRITE) && (fmode & (S_IWUSR|S_IWGRP|S_IWOTH)) == 0) - return (EPERM); - - return (vaccess(vp->v_tag, fmode, 0, 0, ap->a_mode, ap->a_cred, NULL)); -} - -static int -kernfs_getattr(ap) - struct vop_getattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - struct vattr *vap = ap->a_vap; - int error = 0; - char strbuf[KSTRING]; - - bzero((caddr_t) vap, sizeof(*vap)); - vattr_null(vap); - vap->va_uid = 0; - vap->va_gid = 0; - vap->va_size = 0; - vap->va_blocksize = DEV_BSIZE; - nanotime(&vap->va_atime); - vap->va_mtime = vap->va_atime; - vap->va_ctime = vap->va_mtime; - vap->va_gen = 0; - vap->va_flags = 0; - vap->va_rdev = 0; - vap->va_bytes = 0; - - if (vp->v_flag & VROOT) { -#ifdef DEBUG - printf("kernfs_getattr: stat rootdir\n"); -#endif - vap->va_type = VDIR; - vap->va_mode = DIR_MODE; - vap->va_nlink = 2; - vap->va_fileid = 2; - vap->va_size = DEV_BSIZE; - } else { - struct kern_target *kt = VTOKERN(vp)->kf_kt; - int nbytes; -#ifdef DEBUG - printf("kernfs_getattr: stat target %s\n", kt->kt_name); -#endif - vap->va_type = kt->kt_vtype; - vap->va_mode = kt->kt_mode; - vap->va_nlink = 1; - vap->va_fileid = 1 + (kt - kern_targets) / sizeof(*kt); - error = kernfs_xread(kt, strbuf, sizeof(strbuf), &nbytes); - vap->va_size = nbytes; - } - -#ifdef DEBUG - printf("kernfs_getattr: return error %d\n", error); -#endif - return (error); -} - -static int -kernfs_setattr(ap) - struct vop_setattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; -{ - - if (ap->a_vap->va_flags != VNOVAL) - return (EOPNOTSUPP); - - /* - * Silently ignore attribute changes. - * This allows for open with truncate to have no - * effect until some data is written. I want to - * do it this way because all writes are atomic. - */ - return (0); -} - -static int -kernfs_read(ap) - struct vop_read_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - struct kern_target *kt; - char strbuf[KSTRING]; - int off = uio->uio_offset; - int error, len; - - if (vp->v_type == VDIR) - return (EOPNOTSUPP); - - kt = VTOKERN(vp)->kf_kt; - -#ifdef DEBUG - printf("kern_read %s\n", kt->kt_name); -#endif - - len = 0; - if ((error = kernfs_xread(kt, strbuf, sizeof(strbuf), &len)) != 0) - return (error); - if (len <= off) - return (0); - return (uiomove(&strbuf[off], len - off, uio)); -} - -static int -kernfs_write(ap) - struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - struct kern_target *kt; - int error, xlen; - char strbuf[KSTRING]; - - if (vp->v_type == VDIR) - return (EOPNOTSUPP); - - kt = VTOKERN(vp)->kf_kt; - - if (uio->uio_offset != 0) - return (EINVAL); - - xlen = min(uio->uio_resid, KSTRING-1); - if ((error = uiomove(strbuf, xlen, uio)) != 0) - return (error); - - if (uio->uio_resid != 0) - return (EIO); - - strbuf[xlen] = '\0'; - xlen = strlen(strbuf); - return (kernfs_xwrite(kt, strbuf, xlen)); -} - -static int -kernfs_readdir(ap) - struct vop_readdir_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - int *a_ncookies; - u_long **a_cookies; - } */ *ap; -{ - int error, i, off; - struct uio *uio = ap->a_uio; - struct kern_target *kt; - struct dirent d; - - if (ap->a_vp->v_type != VDIR) - return (ENOTDIR); - - off = (int)uio->uio_offset; - if (off != uio->uio_offset || off < 0 || (u_int)off % UIO_MX != 0 || - uio->uio_resid < UIO_MX) - return (EINVAL); - - i = (u_int)off / UIO_MX; - error = 0; - for (kt = &kern_targets[i]; - uio->uio_resid >= UIO_MX && i < nkern_targets; kt++, i++) { - struct dirent *dp = &d; -#ifdef DEBUG - printf("kernfs_readdir: i = %d\n", i); -#endif - - bzero((caddr_t)dp, UIO_MX); - dp->d_namlen = kt->kt_namlen; - bcopy(kt->kt_name, dp->d_name, kt->kt_namlen+1); - -#ifdef DEBUG - printf("kernfs_readdir: name = %s, len = %d\n", - dp->d_name, dp->d_namlen); -#endif - /* - * Fill in the remaining fields - */ - dp->d_reclen = UIO_MX; - dp->d_fileno = i + 3; - dp->d_type = kt->kt_type; - /* - * And ship to userland - */ - if ((error = uiomove((caddr_t)dp, UIO_MX, uio)) != 0) - break; - } - - uio->uio_offset = i * UIO_MX; - - return (error); -} - -static int -kernfs_inactive(ap) - struct vop_inactive_args /* { - struct vnode *a_vp; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - -#ifdef DEBUG - printf("kernfs_inactive(%p)\n", (void *)vp); -#endif - /* - * Clear out the v_type field to avoid - * nasty things happening in vgone(). - */ - VOP_UNLOCK(vp, 0, ap->a_p); - vp->v_type = VNON; - return (0); -} - -static int -kernfs_reclaim(ap) - struct vop_reclaim_args /* { - struct vnode *a_vp; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - -#ifdef DEBUG - printf("kernfs_reclaim(%p)\n", (void *)vp); -#endif - if (vp->v_data) { - FREE(vp->v_data, M_TEMP); - vp->v_data = 0; - } - return (0); -} - - -/* - * Print out the contents of a kernfs vnode. - */ -/* ARGSUSED */ -static int -kernfs_print(ap) - struct vop_print_args /* { - struct vnode *a_vp; - } */ *ap; -{ - - printf("tag VT_KERNFS, kernfs vnode\n"); - return (0); -} - -/* - * Kernfs "should never get here" operation - */ -static int -kernfs_badop() -{ - return (EIO); -} - - -vop_t **kernfs_vnodeop_p; -static struct vnodeopv_entry_desc kernfs_vnodeop_entries[] = { - { &vop_default_desc, (vop_t *) vop_defaultop }, - { &vop_access_desc, (vop_t *) kernfs_access }, - { &vop_bmap_desc, (vop_t *) kernfs_badop }, - { &vop_getattr_desc, (vop_t *) kernfs_getattr }, - { &vop_inactive_desc, (vop_t *) kernfs_inactive }, - { &vop_lookup_desc, (vop_t *) kernfs_lookup }, - { &vop_pathconf_desc, (vop_t *) vop_stdpathconf }, - { &vop_print_desc, (vop_t *) kernfs_print }, - { &vop_read_desc, (vop_t *) kernfs_read }, - { &vop_readdir_desc, (vop_t *) kernfs_readdir }, - { &vop_reclaim_desc, (vop_t *) kernfs_reclaim }, - { &vop_setattr_desc, (vop_t *) kernfs_setattr }, - { &vop_write_desc, (vop_t *) kernfs_write }, - { NULL, NULL } -}; -static struct vnodeopv_desc kernfs_vnodeop_opv_desc = - { &kernfs_vnodeop_p, kernfs_vnodeop_entries }; - -VNODEOP_SET(kernfs_vnodeop_opv_desc); diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 04f59f4..e4986ca 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -8,7 +8,7 @@ _random= random SUBDIR= 3dfx accf_data accf_http agp aha amr an aue \ cam ccd cd9660 coda cue dc de ed fdesc fxp if_disc if_ef \ - if_ppp if_sl if_tap if_tun ip6fw ipfilter ipfw ispfw joy kernfs kue \ + if_ppp if_sl if_tap if_tun ip6fw ipfilter ipfw ispfw joy kue \ linux lnc md mfs mii mlx msdos ncp netgraph nfs ntfs nullfs \ nwfs pcn portal procfs ${_random} \ rl rp sf sis sk sn sound ste sym syscons sysvipc ti tl twe tx \ diff --git a/sys/modules/kernfs/Makefile b/sys/modules/kernfs/Makefile deleted file mode 100644 index cf28e6c..0000000 --- a/sys/modules/kernfs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../../miscfs/kernfs -KMOD= kernfs -SRCS= vnode_if.h \ - kernfs_vfsops.c kernfs_vnops.c -NOMAN= - -.include <bsd.kmod.mk> |