1*39018Smckusick /* 2*39018Smckusick * Copyright (c) 1989 The Regents of the University of California. 3*39018Smckusick * All rights reserved. 4*39018Smckusick * 5*39018Smckusick * Redistribution and use in source and binary forms are permitted 6*39018Smckusick * provided that the above copyright notice and this paragraph are 7*39018Smckusick * duplicated in all such forms and that any documentation, 8*39018Smckusick * advertising materials, and other materials related to such 9*39018Smckusick * distribution and use acknowledge that the software was developed 10*39018Smckusick * by the University of California, Berkeley. The name of the 11*39018Smckusick * University may not be used to endorse or promote products derived 12*39018Smckusick * from this software without specific prior written permission. 13*39018Smckusick * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*39018Smckusick * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*39018Smckusick * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16*39018Smckusick * 17*39018Smckusick * @(#)mfs_vfsops.c 7.1 (Berkeley) 09/05/89 18*39018Smckusick */ 19*39018Smckusick 20*39018Smckusick #include "param.h" 21*39018Smckusick #include "buf.h" 22*39018Smckusick #include "mount.h" 23*39018Smckusick #include "time.h" 24*39018Smckusick #include "vnode.h" 25*39018Smckusick #include "../ufs/ufsmount.h" 26*39018Smckusick #include "../ufs/inode.h" 27*39018Smckusick #include "../ufs/fs.h" 28*39018Smckusick 29*39018Smckusick extern int mfs_running; /* 1 => daemon has started running */ 30*39018Smckusick extern struct vnodeops mfs_vnodeops; 31*39018Smckusick 32*39018Smckusick /* 33*39018Smckusick * mfs vfs operations. 34*39018Smckusick */ 35*39018Smckusick int mfs_mount(); 36*39018Smckusick int mfs_start(); 37*39018Smckusick int ufs_unmount(); 38*39018Smckusick int ufs_root(); 39*39018Smckusick int ufs_statfs(); 40*39018Smckusick int ufs_sync(); 41*39018Smckusick int ufs_fhtovp(); 42*39018Smckusick int ufs_vptofh(); 43*39018Smckusick 44*39018Smckusick struct vfsops mfs_vfsops = { 45*39018Smckusick mfs_mount, 46*39018Smckusick mfs_start, 47*39018Smckusick ufs_unmount, 48*39018Smckusick ufs_root, 49*39018Smckusick ufs_statfs, 50*39018Smckusick ufs_sync, 51*39018Smckusick ufs_fhtovp, 52*39018Smckusick ufs_vptofh, 53*39018Smckusick }; 54*39018Smckusick 55*39018Smckusick /* 56*39018Smckusick * VFS Operations. 57*39018Smckusick * 58*39018Smckusick * mount system call 59*39018Smckusick */ 60*39018Smckusick mfs_mount(mp, path, data, ndp) 61*39018Smckusick struct mount *mp; 62*39018Smckusick char *path; 63*39018Smckusick caddr_t data; 64*39018Smckusick struct nameidata *ndp; 65*39018Smckusick { 66*39018Smckusick struct vnode *devvp; 67*39018Smckusick struct mfs_args args; 68*39018Smckusick struct ufsmount *ump; 69*39018Smckusick register struct fs *fs; 70*39018Smckusick static int mfs_minor; 71*39018Smckusick u_int size; 72*39018Smckusick int error; 73*39018Smckusick 74*39018Smckusick if (error = copyin(data, (caddr_t)&args, sizeof (struct mfs_args))) 75*39018Smckusick return (error); 76*39018Smckusick if ((error = bdevvp(NODEV, &devvp)) != 0) 77*39018Smckusick return (error); 78*39018Smckusick devvp->v_op = &mfs_vnodeops; 79*39018Smckusick devvp->v_rdev = makedev(255, mfs_minor++); 80*39018Smckusick VTOI(devvp)->i_diroff = (long)args.base; 81*39018Smckusick VTOI(devvp)->i_endoff = args.size; 82*39018Smckusick error = mountfs(devvp, mp); 83*39018Smckusick if (error) { 84*39018Smckusick vrele(devvp); 85*39018Smckusick return (error); 86*39018Smckusick } 87*39018Smckusick ump = VFSTOUFS(mp); 88*39018Smckusick fs = ump->um_fs; 89*39018Smckusick (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size); 90*39018Smckusick bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size); 91*39018Smckusick (void) copyinstr(args.name, ump->um_mntname, MNAMELEN - 1, &size); 92*39018Smckusick bzero(ump->um_mntname + size, MNAMELEN - size); 93*39018Smckusick return (0); 94*39018Smckusick } 95*39018Smckusick 96*39018Smckusick /* 97*39018Smckusick * Used to grab the process and keep it in the kernel to service 98*39018Smckusick * memory filesystem I/O requests. 99*39018Smckusick * 100*39018Smckusick * Loop servicing I/O requests. 101*39018Smckusick * Copy the requested data into or out of the memory filesystem 102*39018Smckusick * address space. 103*39018Smckusick */ 104*39018Smckusick /* ARGSUSED */ 105*39018Smckusick mfs_start(mp, flags) 106*39018Smckusick struct mount *mp; 107*39018Smckusick int flags; 108*39018Smckusick { 109*39018Smckusick register struct vnode *vp = VFSTOUFS(mp)->um_devvp; 110*39018Smckusick register struct inode *ip = VTOI(vp); 111*39018Smckusick register struct buf *bp; 112*39018Smckusick register caddr_t base; 113*39018Smckusick 114*39018Smckusick mfs_running++; 115*39018Smckusick sleep((caddr_t)vp, PRIBIO); 116*39018Smckusick base = (caddr_t)ip->i_diroff; 117*39018Smckusick while (bp = (struct buf *)ip->i_spare[0]) { 118*39018Smckusick mfs_doio(bp, base); 119*39018Smckusick wakeup((caddr_t)bp); 120*39018Smckusick sleep((caddr_t)vp, PRIBIO); 121*39018Smckusick } 122*39018Smckusick return (0); 123*39018Smckusick } 124