Annotation of 43BSDReno/sys/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 is only permitted until one year after the first shipment
                      6:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
                      7:  * binary forms are permitted provided that: (1) source distributions retain
                      8:  * this entire copyright notice and comment, and (2) distributions including
                      9:  * binaries display the following acknowledgement:  This product includes
                     10:  * software developed by the University of California, Berkeley and its
                     11:  * contributors'' in the documentation or other materials provided with the
                     12:  * distribution and in all advertising materials mentioning features or use
                     13:  * of this software.  Neither the name of the University nor the names of
                     14:  * its contributors may be used to endorse or promote products derived from
                     15:  * this software without specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  *
                     20:  *     @(#)mfs_vfsops.c        7.17 (Berkeley) 6/28/90
                     21:  */
                     22: 
                     23: #include "param.h"
                     24: #include "time.h"
                     25: #include "kernel.h"
                     26: #include "user.h"
                     27: #include "proc.h"
                     28: #include "buf.h"
                     29: #include "mount.h"
                     30: #include "vnode.h"
                     31: #include "../ufs/quota.h"
                     32: #include "../ufs/inode.h"
                     33: #include "../ufs/ufsmount.h"
                     34: #include "../ufs/mfsnode.h"
                     35: #include "../ufs/fs.h"
                     36: 
                     37: extern struct vnodeops mfs_vnodeops;
                     38: 
                     39: /*
                     40:  * mfs vfs operations.
                     41:  */
                     42: int mfs_mount();
                     43: int mfs_start();
                     44: int ufs_unmount();
                     45: int ufs_root();
                     46: int ufs_quotactl();
                     47: int mfs_statfs();
                     48: int ufs_sync();
                     49: int ufs_fhtovp();
                     50: int ufs_vptofh();
                     51: int mfs_init();
                     52: 
                     53: struct vfsops mfs_vfsops = {
                     54:        mfs_mount,
                     55:        mfs_start,
                     56:        ufs_unmount,
                     57:        ufs_root,
                     58:        ufs_quotactl,
                     59:        mfs_statfs,
                     60:        ufs_sync,
                     61:        ufs_fhtovp,
                     62:        ufs_vptofh,
                     63:        mfs_init,
                     64: };
                     65: 
                     66: /*
                     67:  * VFS Operations.
                     68:  *
                     69:  * mount system call
                     70:  */
                     71: /* ARGSUSED */
                     72: mfs_mount(mp, path, data, ndp)
                     73:        register struct mount *mp;
                     74:        char *path;
                     75:        caddr_t data;
                     76:        struct nameidata *ndp;
                     77: {
                     78:        struct vnode *devvp;
                     79:        struct mfs_args args;
                     80:        struct ufsmount *ump;
                     81:        register struct fs *fs;
                     82:        register struct mfsnode *mfsp;
                     83:        static int mfs_minor;
                     84:        u_int size;
                     85:        int error;
                     86: 
                     87:        if (mp->mnt_flag & MNT_UPDATE) {
                     88:                ump = VFSTOUFS(mp);
                     89:                fs = ump->um_fs;
                     90:                if (fs->fs_ronly && (mp->mnt_flag & MNT_RDONLY) == 0)
                     91:                        fs->fs_ronly = 0;
                     92:                return (0);
                     93:        }
                     94:        if (error = copyin(data, (caddr_t)&args, sizeof (struct mfs_args)))
                     95:                return (error);
                     96:        error = getnewvnode(VT_MFS, (struct mount *)0, &mfs_vnodeops, &devvp);
                     97:        if (error)
                     98:                return (error);
                     99:        devvp->v_type = VBLK;
                    100:        if (checkalias(devvp, makedev(255, mfs_minor++), (struct mount *)0))
                    101:                panic("mfs_mount: dup dev");
                    102:        mfsp = VTOMFS(devvp);
                    103:        mfsp->mfs_baseoff = args.base;
                    104:        mfsp->mfs_size = args.size;
                    105:        mfsp->mfs_vnode = devvp;
                    106:        mfsp->mfs_pid = u.u_procp->p_pid;
                    107:        mfsp->mfs_buflist = (struct buf *)0;
                    108:        if (error = mountfs(devvp, mp)) {
                    109:                mfsp->mfs_buflist = (struct buf *)-1;
                    110:                vrele(devvp);
                    111:                return (error);
                    112:        }
                    113:        ump = VFSTOUFS(mp);
                    114:        fs = ump->um_fs;
                    115:        (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size);
                    116:        bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size);
                    117:        bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname,
                    118:                MNAMELEN);
                    119:        (void) copyinstr(args.name, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
                    120:                &size);
                    121:        bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
                    122:        (void) mfs_statfs(mp, &mp->mnt_stat);
                    123:        return (0);
                    124: }
                    125: 
                    126: int    mfs_pri = PWAIT | PCATCH;               /* XXX prob. temp */
                    127: 
                    128: /*
                    129:  * Used to grab the process and keep it in the kernel to service
                    130:  * memory filesystem I/O requests.
                    131:  *
                    132:  * Loop servicing I/O requests.
                    133:  * Copy the requested data into or out of the memory filesystem
                    134:  * address space.
                    135:  */
                    136: /* ARGSUSED */
                    137: mfs_start(mp, flags)
                    138:        struct mount *mp;
                    139:        int flags;
                    140: {
                    141:        register struct vnode *vp = VFSTOUFS(mp)->um_devvp;
                    142:        register struct mfsnode *mfsp = VTOMFS(vp);
                    143:        register struct buf *bp;
                    144:        register caddr_t base;
                    145:        struct proc *p = u.u_procp;
                    146:        int error = 0;
                    147: 
                    148:        base = mfsp->mfs_baseoff;
                    149:        while (mfsp->mfs_buflist != (struct buf *)(-1)) {
                    150:                while (bp = mfsp->mfs_buflist) {
                    151:                        mfsp->mfs_buflist = bp->av_forw;
                    152:                        mfs_doio(bp, base);
                    153:                        wakeup((caddr_t)bp);
                    154:                }
                    155:                /*
                    156:                 * If a non-ignored signal is received, try to unmount.
                    157:                 * If that fails, clear the signal (it has been "processed"),
                    158:                 * otherwise we will loop here, as tsleep will always return
                    159:                 * EINTR/ERESTART.
                    160:                 */
                    161:                if (error = tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0))
                    162:                        if (dounmount(mp, MNT_NOFORCE) != 0)
                    163:                                CLRSIG(p, CURSIG(p));
                    164:        }
                    165:        return (error);
                    166: }
                    167: 
                    168: /*
                    169:  * Get file system statistics.
                    170:  */
                    171: mfs_statfs(mp, sbp)
                    172:        struct mount *mp;
                    173:        struct statfs *sbp;
                    174: {
                    175:        int error;
                    176: 
                    177:        error = ufs_statfs(mp, sbp);
                    178:        sbp->f_type = MOUNT_MFS;
                    179:        return (error);
                    180: }

unix.superglobalmegacorp.com

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