Home | History | Annotate | Line # | Download | only in procfs
procfs_vfsops.c revision 1.6
      1 /*
      2  * Copyright (c) 1993 Paul Kranenburg
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *      This product includes software developed by Paul Kranenburg.
     16  * 4. The name of the author may not be used to endorse or promote products
     17  *    derived from this software withough specific prior written permission
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  *
     30  *	$Id: procfs_vfsops.c,v 1.6 1993/08/25 14:41:19 mycroft Exp $
     31  */
     32 
     33 /*
     34  * PROCFS VFS interface routines
     35  */
     36 
     37 #include "param.h"
     38 #include "time.h"
     39 #include "kernel.h"
     40 #include "proc.h"
     41 #include "buf.h"
     42 #include "mount.h"
     43 #include "signalvar.h"
     44 #include "vnode.h"
     45 
     46 #include "pfsnode.h"
     47 
     48 extern struct vnodeops pfs_vnodeops;
     49 
     50 /*
     51  * mfs vfs operations.
     52  */
     53 int pfs_mount();
     54 int pfs_start();
     55 int pfs_unmount();
     56 int pfs_root();
     57 int pfs_quotactl();
     58 int pfs_statfs();
     59 int pfs_sync();
     60 int pfs_fhtovp();
     61 int pfs_vptofh();
     62 int pfs_init();
     63 
     64 struct vfsops procfs_vfsops = {
     65 	pfs_mount,
     66 	pfs_start,
     67 	pfs_unmount,
     68 	pfs_root,
     69 	pfs_quotactl,
     70 	pfs_statfs,
     71 	pfs_sync,
     72 	pfs_fhtovp,
     73 	pfs_vptofh,
     74 	pfs_init,
     75 };
     76 
     77 /*
     78  * VFS Operations.
     79  *
     80  * mount system call
     81  */
     82 /* ARGSUSED */
     83 pfs_mount(mp, path, data, ndp, p)
     84 	register struct mount *mp;
     85 	char *path;
     86 	caddr_t data;
     87 	struct nameidata *ndp;
     88 	struct proc *p;
     89 {
     90 #if 0
     91 	struct pfs_args args;
     92 #endif
     93 	struct vnode *pvp;
     94 	u_int size;
     95 	int error;
     96 
     97 	if (mp->mnt_flag & MNT_UPDATE) {
     98 		return (0);
     99 	}
    100 
    101 #if 0
    102 	if (error = copyin(data, (caddr_t)&args, sizeof (struct pfs_args)))
    103 		return (error);
    104 #endif
    105 	(void) copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN, &size);
    106 	bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
    107 
    108 	size = sizeof("proc") - 1;
    109 	bcopy("proc", mp->mnt_stat.f_mntfromname, size);
    110 	bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
    111 
    112 	(void) pfs_statfs(mp, &mp->mnt_stat, p);
    113 	return (0);
    114 }
    115 
    116 /*
    117  * unmount system call
    118  */
    119 pfs_unmount(mp, mntflags, p)
    120 	struct mount *mp;
    121 	int mntflags;
    122 	struct proc *p;
    123 {
    124 	return (0);
    125 }
    126 
    127 pfs_root(mp, vpp)
    128 	struct mount *mp;
    129 	struct vnode **vpp;
    130 {
    131 	struct vnode *vp;
    132 	struct pfsnode *pfsp;
    133 	int error;
    134 
    135 	error = getnewvnode(VT_PROCFS, mp, &pfs_vnodeops, &vp);
    136 	if (error)
    137 		return error;
    138 
    139 	vp->v_type = VDIR;
    140 	vp->v_flag = VROOT;
    141 	pfsp = VTOPFS(vp);
    142 	pfsp->pfs_vnode = vp;
    143 	pfsp->pfs_pid = 0;
    144 
    145 	*vpp = vp;
    146 	return 0;
    147 }
    148 
    149 /*
    150  */
    151 /* ARGSUSED */
    152 pfs_start(mp, flags, p)
    153 	struct mount *mp;
    154 	int flags;
    155 	struct proc *p;
    156 {
    157 	return 0;
    158 }
    159 
    160 /*
    161  * Get file system statistics.
    162  */
    163 pfs_statfs(mp, sbp, p)
    164 	struct mount *mp;
    165 	struct statfs *sbp;
    166 	struct proc *p;
    167 {
    168 	sbp->f_type = MOUNT_PROCFS;
    169 	sbp->f_fsize = 0;
    170 	sbp->f_bsize = 0;
    171 	sbp->f_blocks = 0;
    172 	sbp->f_bfree = 0;
    173 	sbp->f_bavail = 0;
    174 	sbp->f_files = maxproc + 3;
    175 	sbp->f_ffree = maxproc - nprocs;
    176 
    177 	return 0;
    178 }
    179 
    180 
    181 pfs_quotactl(mp, cmds, uid, arg, p)
    182 	struct mount *mp;
    183 	int cmds;
    184 	uid_t uid;
    185 	caddr_t arg;
    186 	struct proc *p;
    187 {
    188 	return EOPNOTSUPP;
    189 }
    190 
    191 pfs_sync(mp, waitfor)
    192 	struct mount *mp;
    193 	int waitfor;
    194 {
    195 	return 0;
    196 }
    197 
    198 pfs_fhtovp(mp, fhp, vpp)
    199 	register struct mount *mp;
    200 	struct fid *fhp;
    201 	struct vnode **vpp;
    202 {
    203 	return EINVAL;
    204 }
    205 
    206 pfs_vptofh(vp, fhp)
    207 	struct vnode *vp;
    208 	struct fid *fhp;
    209 {
    210 	return EINVAL;
    211 }
    212 
    213 pfs_init()
    214 {
    215 	return 0;
    216 }
    217