Home | History | Annotate | Line # | Download | only in procfs
procfs_vfsops.c revision 1.1
      1 /*
      2  *	%W% (Erasmus) %G%	- pk (at) cs.few.eur.nl
      3  */
      4 
      5 #include "param.h"
      6 #include "time.h"
      7 #include "kernel.h"
      8 #include "proc.h"
      9 #include "buf.h"
     10 #include "mount.h"
     11 #include "signalvar.h"
     12 #include "vnode.h"
     13 
     14 #include "pfsnode.h"
     15 
     16 extern struct vnodeops pfs_vnodeops;
     17 
     18 /*
     19  * mfs vfs operations.
     20  */
     21 int pfs_mount();
     22 int pfs_start();
     23 int pfs_unmount();
     24 int pfs_root();
     25 int pfs_quotactl();
     26 int pfs_statfs();
     27 int pfs_sync();
     28 int pfs_fhtovp();
     29 int pfs_vptofh();
     30 int pfs_init();
     31 
     32 struct vfsops procfs_vfsops = {
     33 	pfs_mount,
     34 	pfs_start,
     35 	pfs_unmount,
     36 	pfs_root,
     37 	pfs_quotactl,
     38 	pfs_statfs,
     39 	pfs_sync,
     40 	pfs_fhtovp,
     41 	pfs_vptofh,
     42 	pfs_init,
     43 };
     44 
     45 /*
     46  * VFS Operations.
     47  *
     48  * mount system call
     49  */
     50 /* ARGSUSED */
     51 pfs_mount(mp, path, data, ndp, p)
     52 	register struct mount *mp;
     53 	char *path;
     54 	caddr_t data;
     55 	struct nameidata *ndp;
     56 	struct proc *p;
     57 {
     58 #if 0
     59 	struct pfs_args args;
     60 #endif
     61 	struct vnode *pvp;
     62 	u_int size;
     63 	int error;
     64 
     65 	if (mp->mnt_flag & MNT_UPDATE) {
     66 		return (0);
     67 	}
     68 
     69 #if 0
     70 	if (error = copyin(data, (caddr_t)&args, sizeof (struct pfs_args)))
     71 		return (error);
     72 #endif
     73 	(void) copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN, &size);
     74 	bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
     75 
     76 	size = sizeof("proc") - 1;
     77 	bcopy("proc", mp->mnt_stat.f_mntfromname, size);
     78 	bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
     79 
     80 	(void) pfs_statfs(mp, &mp->mnt_stat, p);
     81 	return (0);
     82 }
     83 
     84 /*
     85  * unmount system call
     86  */
     87 pfs_unmount(mp, mntflags, p)
     88 	struct mount *mp;
     89 	int mntflags;
     90 	struct proc *p;
     91 {
     92 	return (0);
     93 }
     94 
     95 pfs_root(mp, vpp)
     96 	struct mount *mp;
     97 	struct vnode **vpp;
     98 {
     99 	struct vnode *vp;
    100 	struct pfsnode *pfsp;
    101 	int error;
    102 
    103 	error = getnewvnode(VT_PROCFS, mp, &pfs_vnodeops, &vp);
    104 	if (error)
    105 		return error;
    106 
    107 	vp->v_type = VDIR;
    108 	vp->v_flag = VROOT;
    109 	pfsp = VTOPFS(vp);
    110 	pfsp->pfs_vnode = vp;
    111 	pfsp->pfs_pid = 0;
    112 
    113 	*vpp = vp;
    114 	return 0;
    115 }
    116 
    117 /*
    118  */
    119 /* ARGSUSED */
    120 pfs_start(mp, flags, p)
    121 	struct mount *mp;
    122 	int flags;
    123 	struct proc *p;
    124 {
    125 	return 0;
    126 }
    127 
    128 /*
    129  * Get file system statistics.
    130  */
    131 pfs_statfs(mp, sbp, p)
    132 	struct mount *mp;
    133 	struct statfs *sbp;
    134 	struct proc *p;
    135 {
    136 	sbp->f_type = MOUNT_PROCFS;
    137 	sbp->f_fsize = nprocs;
    138 	sbp->f_bsize = 0;
    139 	sbp->f_blocks = 0;
    140 	sbp->f_bfree = maxproc - nprocs;
    141 	sbp->f_bavail = 0;
    142 	sbp->f_files =  0;
    143 	sbp->f_ffree = 0;
    144 
    145 	return 0;
    146 }
    147 
    148 
    149 pfs_quotactl(mp, cmds, uid, arg, p)
    150 	struct mount *mp;
    151 	int cmds;
    152 	uid_t uid;
    153 	caddr_t arg;
    154 	struct proc *p;
    155 {
    156 	return EOPNOTSUPP;
    157 }
    158 
    159 pfs_sync(mp, waitfor)
    160 	struct mount *mp;
    161 	int waitfor;
    162 {
    163 	return 0;
    164 }
    165 
    166 pfs_fhtovp(mp, fhp, vpp)
    167 	register struct mount *mp;
    168 	struct fid *fhp;
    169 	struct vnode **vpp;
    170 {
    171 	return EINVAL;
    172 }
    173 
    174 pfs_vptofh(vp, fhp)
    175 	struct vnode *vp;
    176 	struct fid *fhp;
    177 {
    178 	return EINVAL;
    179 }
    180 
    181 pfs_init()
    182 {
    183 	return 0;
    184 }
    185