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