|
|
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: *
1.1.1.2 ! root 33: * from: @(#)mfs_vfsops.c 7.19 (Berkeley) 4/16/91
! 34: * mfs_vfsops.c,v 1.2 1993/05/20 03:53:26 cgd Exp
1.1 root 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 "quota.h"
47: #include "inode.h"
48: #include "ufsmount.h"
49: #include "mfsnode.h"
50: #include "fs.h"
51:
52: extern struct vnodeops mfs_vnodeops;
53:
54: /*
55: * mfs vfs operations.
56: */
57: int mfs_mount();
58: int mfs_start();
59: int ufs_unmount();
60: int ufs_root();
61: int ufs_quotactl();
62: int mfs_statfs();
63: int ufs_sync();
64: int ufs_fhtovp();
65: int ufs_vptofh();
66: int mfs_init();
67:
68: struct vfsops mfs_vfsops = {
69: mfs_mount,
70: mfs_start,
71: ufs_unmount,
72: ufs_root,
73: ufs_quotactl,
74: mfs_statfs,
75: ufs_sync,
76: ufs_fhtovp,
77: ufs_vptofh,
78: mfs_init,
79: };
80:
81: /*
82: * VFS Operations.
83: *
84: * mount system call
85: */
86: /* ARGSUSED */
87: mfs_mount(mp, path, data, ndp, p)
88: register struct mount *mp;
89: char *path;
90: caddr_t data;
91: struct nameidata *ndp;
92: struct proc *p;
93: {
94: struct vnode *devvp;
95: struct mfs_args args;
96: struct ufsmount *ump;
97: register struct fs *fs;
98: register struct mfsnode *mfsp;
99: static int mfs_minor;
100: u_int size;
101: int error;
102:
103: if (mp->mnt_flag & MNT_UPDATE) {
104: ump = VFSTOUFS(mp);
105: fs = ump->um_fs;
106: if (fs->fs_ronly && (mp->mnt_flag & MNT_RDONLY) == 0)
107: fs->fs_ronly = 0;
108: return (0);
109: }
110: if (error = copyin(data, (caddr_t)&args, sizeof (struct mfs_args)))
111: return (error);
112: error = getnewvnode(VT_MFS, (struct mount *)0, &mfs_vnodeops, &devvp);
113: if (error)
114: return (error);
115: devvp->v_type = VBLK;
116: if (checkalias(devvp, makedev(255, mfs_minor++), (struct mount *)0))
117: panic("mfs_mount: dup dev");
118: mfsp = VTOMFS(devvp);
119: mfsp->mfs_baseoff = args.base;
120: mfsp->mfs_size = args.size;
121: mfsp->mfs_vnode = devvp;
122: mfsp->mfs_pid = p->p_pid;
123: mfsp->mfs_buflist = (struct buf *)0;
124: if (error = mountfs(devvp, mp)) {
125: mfsp->mfs_buflist = (struct buf *)-1;
126: vrele(devvp);
127: return (error);
128: }
129: ump = VFSTOUFS(mp);
130: fs = ump->um_fs;
131: (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size);
132: bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size);
133: bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname,
134: MNAMELEN);
135: (void) copyinstr(args.name, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
136: &size);
137: bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
138: (void) mfs_statfs(mp, &mp->mnt_stat);
139: return (0);
140: }
141:
142: int mfs_pri = PWAIT | PCATCH; /* XXX prob. temp */
143:
144: /*
145: * Used to grab the process and keep it in the kernel to service
146: * memory filesystem I/O requests.
147: *
148: * Loop servicing I/O requests.
149: * Copy the requested data into or out of the memory filesystem
150: * address space.
151: */
152: /* ARGSUSED */
153: mfs_start(mp, flags, p)
154: struct mount *mp;
155: int flags;
156: struct proc *p;
157: {
158: register struct vnode *vp = VFSTOUFS(mp)->um_devvp;
159: register struct mfsnode *mfsp = VTOMFS(vp);
160: register struct buf *bp;
161: register caddr_t base;
162: int error = 0;
163:
164: base = mfsp->mfs_baseoff;
165: while (mfsp->mfs_buflist != (struct buf *)(-1)) {
166: while (bp = mfsp->mfs_buflist) {
167: mfsp->mfs_buflist = bp->av_forw;
168: mfs_doio(bp, base);
169: wakeup((caddr_t)bp);
170: }
171: /*
172: * If a non-ignored signal is received, try to unmount.
173: * If that fails, clear the signal (it has been "processed"),
174: * otherwise we will loop here, as tsleep will always return
175: * EINTR/ERESTART.
176: */
177: if (error = tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0))
178: if (dounmount(mp, MNT_NOFORCE, p) != 0)
179: CLRSIG(p, CURSIG(p));
180: }
181: return (error);
182: }
183:
184: /*
185: * Get file system statistics.
186: */
187: mfs_statfs(mp, sbp, p)
188: struct mount *mp;
189: struct statfs *sbp;
190: struct proc *p;
191: {
192: int error;
193:
194: error = ufs_statfs(mp, sbp, p);
195: sbp->f_type = MOUNT_MFS;
196: return (error);
197: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.