Annotation of Net2/ufs/mfs_vfsops.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1989, 1990 The Regents of the University of California.
                      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 the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
                     33:  *     @(#)mfs_vfsops.c        7.19 (Berkeley) 4/16/91
                     34:  */
                     35: 
                     36: #include "param.h"
                     37: #include "time.h"
                     38: #include "kernel.h"
                     39: #include "proc.h"
                     40: #include "buf.h"
                     41: #include "mount.h"
                     42: #include "signalvar.h"
                     43: #include "vnode.h"
                     44: 
                     45: #include "quota.h"
                     46: #include "inode.h"
                     47: #include "ufsmount.h"
                     48: #include "mfsnode.h"
                     49: #include "fs.h"
                     50: 
                     51: extern struct vnodeops mfs_vnodeops;
                     52: 
                     53: /*
                     54:  * mfs vfs operations.
                     55:  */
                     56: int mfs_mount();
                     57: int mfs_start();
                     58: int ufs_unmount();
                     59: int ufs_root();
                     60: int ufs_quotactl();
                     61: int mfs_statfs();
                     62: int ufs_sync();
                     63: int ufs_fhtovp();
                     64: int ufs_vptofh();
                     65: int mfs_init();
                     66: 
                     67: struct vfsops mfs_vfsops = {
                     68:        mfs_mount,
                     69:        mfs_start,
                     70:        ufs_unmount,
                     71:        ufs_root,
                     72:        ufs_quotactl,
                     73:        mfs_statfs,
                     74:        ufs_sync,
                     75:        ufs_fhtovp,
                     76:        ufs_vptofh,
                     77:        mfs_init,
                     78: };
                     79: 
                     80: /*
                     81:  * VFS Operations.
                     82:  *
                     83:  * mount system call
                     84:  */
                     85: /* ARGSUSED */
                     86: mfs_mount(mp, path, data, ndp, p)
                     87:        register struct mount *mp;
                     88:        char *path;
                     89:        caddr_t data;
                     90:        struct nameidata *ndp;
                     91:        struct proc *p;
                     92: {
                     93:        struct vnode *devvp;
                     94:        struct mfs_args args;
                     95:        struct ufsmount *ump;
                     96:        register struct fs *fs;
                     97:        register struct mfsnode *mfsp;
                     98:        static int mfs_minor;
                     99:        u_int size;
                    100:        int error;
                    101: 
                    102:        if (mp->mnt_flag & MNT_UPDATE) {
                    103:                ump = VFSTOUFS(mp);
                    104:                fs = ump->um_fs;
                    105:                if (fs->fs_ronly && (mp->mnt_flag & MNT_RDONLY) == 0)
                    106:                        fs->fs_ronly = 0;
                    107:                return (0);
                    108:        }
                    109:        if (error = copyin(data, (caddr_t)&args, sizeof (struct mfs_args)))
                    110:                return (error);
                    111:        error = getnewvnode(VT_MFS, (struct mount *)0, &mfs_vnodeops, &devvp);
                    112:        if (error)
                    113:                return (error);
                    114:        devvp->v_type = VBLK;
                    115:        if (checkalias(devvp, makedev(255, mfs_minor++), (struct mount *)0))
                    116:                panic("mfs_mount: dup dev");
                    117:        mfsp = VTOMFS(devvp);
                    118:        mfsp->mfs_baseoff = args.base;
                    119:        mfsp->mfs_size = args.size;
                    120:        mfsp->mfs_vnode = devvp;
                    121:        mfsp->mfs_pid = p->p_pid;
                    122:        mfsp->mfs_buflist = (struct buf *)0;
                    123:        if (error = mountfs(devvp, mp)) {
                    124:                mfsp->mfs_buflist = (struct buf *)-1;
                    125:                vrele(devvp);
                    126:                return (error);
                    127:        }
                    128:        ump = VFSTOUFS(mp);
                    129:        fs = ump->um_fs;
                    130:        (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size);
                    131:        bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size);
                    132:        bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname,
                    133:                MNAMELEN);
                    134:        (void) copyinstr(args.name, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
                    135:                &size);
                    136:        bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
                    137:        (void) mfs_statfs(mp, &mp->mnt_stat);
                    138:        return (0);
                    139: }
                    140: 
                    141: int    mfs_pri = PWAIT | PCATCH;               /* XXX prob. temp */
                    142: 
                    143: /*
                    144:  * Used to grab the process and keep it in the kernel to service
                    145:  * memory filesystem I/O requests.
                    146:  *
                    147:  * Loop servicing I/O requests.
                    148:  * Copy the requested data into or out of the memory filesystem
                    149:  * address space.
                    150:  */
                    151: /* ARGSUSED */
                    152: mfs_start(mp, flags, p)
                    153:        struct mount *mp;
                    154:        int flags;
                    155:        struct proc *p;
                    156: {
                    157:        register struct vnode *vp = VFSTOUFS(mp)->um_devvp;
                    158:        register struct mfsnode *mfsp = VTOMFS(vp);
                    159:        register struct buf *bp;
                    160:        register caddr_t base;
                    161:        int error = 0;
                    162: 
                    163:        base = mfsp->mfs_baseoff;
                    164:        while (mfsp->mfs_buflist != (struct buf *)(-1)) {
                    165:                while (bp = mfsp->mfs_buflist) {
                    166:                        mfsp->mfs_buflist = bp->av_forw;
                    167:                        mfs_doio(bp, base);
                    168:                        wakeup((caddr_t)bp);
                    169:                }
                    170:                /*
                    171:                 * If a non-ignored signal is received, try to unmount.
                    172:                 * If that fails, clear the signal (it has been "processed"),
                    173:                 * otherwise we will loop here, as tsleep will always return
                    174:                 * EINTR/ERESTART.
                    175:                 */
                    176:                if (error = tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0))
                    177:                        if (dounmount(mp, MNT_NOFORCE, p) != 0)
                    178:                                CLRSIG(p, CURSIG(p));
                    179:        }
                    180:        return (error);
                    181: }
                    182: 
                    183: /*
                    184:  * Get file system statistics.
                    185:  */
                    186: mfs_statfs(mp, sbp, p)
                    187:        struct mount *mp;
                    188:        struct statfs *sbp;
                    189:        struct proc *p;
                    190: {
                    191:        int error;
                    192: 
                    193:        error = ufs_statfs(mp, sbp, p);
                    194:        sbp->f_type = MOUNT_MFS;
                    195:        return (error);
                    196: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.