ext2_vfsops.c (96881) | ext2_vfsops.c (97255) |
---|---|
1/* 2 * modified for EXT2FS support in Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 */ 7/* 8 * Copyright (c) 1989, 1991, 1993, 1994 --- 23 unchanged lines hidden (view full) --- 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94 | 1/* 2 * modified for EXT2FS support in Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 */ 7/* 8 * Copyright (c) 1989, 1991, 1993, 1994 --- 23 unchanged lines hidden (view full) --- 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94 |
40 * $FreeBSD: head/sys/gnu/fs/ext2fs/ext2_vfsops.c 96881 2002-05-18 22:18:17Z iedowse $ | 40 * $FreeBSD: head/sys/gnu/fs/ext2fs/ext2_vfsops.c 97255 2002-05-24 17:38:01Z mux $ |
41 */ 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/namei.h> 46#include <sys/proc.h> 47#include <sys/kernel.h> 48#include <sys/vnode.h> --- 12 unchanged lines hidden (view full) --- 61#include <gnu/ext2fs/fs.h> 62#include <gnu/ext2fs/ext2_extern.h> 63#include <gnu/ext2fs/ext2_fs.h> 64#include <gnu/ext2fs/ext2_fs_sb.h> 65 66static int ext2_fhtovp(struct mount *, struct fid *, struct vnode **); 67static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td); 68static int ext2_init(struct vfsconf *); | 41 */ 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/namei.h> 46#include <sys/proc.h> 47#include <sys/kernel.h> 48#include <sys/vnode.h> --- 12 unchanged lines hidden (view full) --- 61#include <gnu/ext2fs/fs.h> 62#include <gnu/ext2fs/ext2_extern.h> 63#include <gnu/ext2fs/ext2_fs.h> 64#include <gnu/ext2fs/ext2_fs_sb.h> 65 66static int ext2_fhtovp(struct mount *, struct fid *, struct vnode **); 67static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td); 68static int ext2_init(struct vfsconf *); |
69static int ext2_mount(struct mount *, 70 char *, caddr_t, struct nameidata *, struct thread *); | 69static int ext2_mount(struct mount *, struct nameidata *, struct thread *); |
71static int ext2_mountfs(struct vnode *, struct mount *, struct thread *); 72static int ext2_reload(struct mount *mountp, struct ucred *cred, 73 struct thread *td); 74static int ext2_root(struct mount *, struct vnode **vpp); 75static int ext2_sbupdate(struct ext2mount *, int); 76static int ext2_statfs(struct mount *, struct statfs *, struct thread *); 77static int ext2_sync(struct mount *, int, struct ucred *, struct thread *); 78static int ext2_uninit(struct vfsconf *); 79static int ext2_unmount(struct mount *, int, struct thread *); 80static int ext2_vget(struct mount *, ino_t, int, struct vnode **); 81static int ext2_vptofh(struct vnode *, struct fid *); 82 83MALLOC_DEFINE(M_EXT2NODE, "EXT2 node", "EXT2 vnode private part"); 84static MALLOC_DEFINE(M_EXT2MNT, "EXT2 mount", "EXT2 mount structure"); 85 86static struct vfsops ext2fs_vfsops = { | 70static int ext2_mountfs(struct vnode *, struct mount *, struct thread *); 71static int ext2_reload(struct mount *mountp, struct ucred *cred, 72 struct thread *td); 73static int ext2_root(struct mount *, struct vnode **vpp); 74static int ext2_sbupdate(struct ext2mount *, int); 75static int ext2_statfs(struct mount *, struct statfs *, struct thread *); 76static int ext2_sync(struct mount *, int, struct ucred *, struct thread *); 77static int ext2_uninit(struct vfsconf *); 78static int ext2_unmount(struct mount *, int, struct thread *); 79static int ext2_vget(struct mount *, ino_t, int, struct vnode **); 80static int ext2_vptofh(struct vnode *, struct fid *); 81 82MALLOC_DEFINE(M_EXT2NODE, "EXT2 node", "EXT2 vnode private part"); 83static MALLOC_DEFINE(M_EXT2MNT, "EXT2 mount", "EXT2 mount structure"); 84 85static struct vfsops ext2fs_vfsops = { |
87 ext2_mount, | 86 NULL, |
88 vfs_stdstart, 89 ext2_unmount, 90 ext2_root, /* root inode via vget */ 91 vfs_stdquotactl, 92 ext2_statfs, 93 ext2_sync, 94 ext2_vget, 95 ext2_fhtovp, 96 vfs_stdcheckexp, 97 ext2_vptofh, 98 ext2_init, 99 ext2_uninit, 100 vfs_stdextattrctl, | 87 vfs_stdstart, 88 ext2_unmount, 89 ext2_root, /* root inode via vget */ 90 vfs_stdquotactl, 91 ext2_statfs, 92 ext2_sync, 93 ext2_vget, 94 ext2_fhtovp, 95 vfs_stdcheckexp, 96 ext2_vptofh, 97 ext2_init, 98 ext2_uninit, 99 vfs_stdextattrctl, |
100 ext2_mount, |
|
101}; 102 103VFS_SET(ext2fs_vfsops, ext2fs, 0); 104#define bsd_malloc malloc 105#define bsd_free free 106 107static int ext2fs_inode_hash_lock; 108 --- 61 unchanged lines hidden (view full) --- 170#endif 171 172/* 173 * VFS Operations. 174 * 175 * mount system call 176 */ 177static int | 101}; 102 103VFS_SET(ext2fs_vfsops, ext2fs, 0); 104#define bsd_malloc malloc 105#define bsd_free free 106 107static int ext2fs_inode_hash_lock; 108 --- 61 unchanged lines hidden (view full) --- 170#endif 171 172/* 173 * VFS Operations. 174 * 175 * mount system call 176 */ 177static int |
178ext2_mount(mp, path, data, ndp, td) | 178ext2_mount(mp, ndp, td) |
179 struct mount *mp; | 179 struct mount *mp; |
180 char *path; 181 caddr_t data; /* this is actually a (struct ext2_args *) */ | |
182 struct nameidata *ndp; 183 struct thread *td; 184{ | 180 struct nameidata *ndp; 181 struct thread *td; 182{ |
183 struct export_args *export; 184 struct vfsoptlist *opts; |
|
185 struct vnode *devvp; | 185 struct vnode *devvp; |
186 struct ext2_args args; | |
187 struct ext2mount *ump = 0; 188 struct ext2_sb_info *fs; | 186 struct ext2mount *ump = 0; 187 struct ext2_sb_info *fs; |
188 char *path, *fspec; |
|
189 size_t size; | 189 size_t size; |
190 int error, flags; | 190 int error, flags, len; |
191 mode_t accessmode; 192 | 191 mode_t accessmode; 192 |
193 opts = mp->mnt_optnew; 194 195 vfs_getopt(opts, "fspath", (void **)&path, NULL); |
|
193 /* Double-check the length of path.. */ 194 if (strlen(path) >= MAXMNTLEN - 1) 195 return (ENAMETOOLONG); | 196 /* Double-check the length of path.. */ 197 if (strlen(path) >= MAXMNTLEN - 1) 198 return (ENAMETOOLONG); |
196 error = copyin(data, (caddr_t)&args, sizeof (struct ext2_args)); 197 if (error != 0) 198 return (error); | 199 200 fspec = NULL; 201 error = vfs_getopt(opts, "from", (void **)&fspec, &len); 202 if (!error && fspec[len - 1] != '\0') 203 return (EINVAL); 204 |
199 /* 200 * If updating, check whether changing from read-only to 201 * read/write; if there is no device name, that's all we do. 202 */ 203 if (mp->mnt_flag & MNT_UPDATE) { 204 ump = VFSTOEXT2(mp); 205 fs = ump->um_e2fs; 206 error = 0; --- 46 unchanged lines hidden (view full) --- 253 fs->fs_fsmnt); 254 return (EPERM); 255 } 256 } 257 fs->s_es->s_state &= ~EXT2_VALID_FS; 258 ext2_sbupdate(ump, MNT_WAIT); 259 fs->s_rd_only = 0; 260 } | 205 /* 206 * If updating, check whether changing from read-only to 207 * read/write; if there is no device name, that's all we do. 208 */ 209 if (mp->mnt_flag & MNT_UPDATE) { 210 ump = VFSTOEXT2(mp); 211 fs = ump->um_e2fs; 212 error = 0; --- 46 unchanged lines hidden (view full) --- 259 fs->fs_fsmnt); 260 return (EPERM); 261 } 262 } 263 fs->s_es->s_state &= ~EXT2_VALID_FS; 264 ext2_sbupdate(ump, MNT_WAIT); 265 fs->s_rd_only = 0; 266 } |
261 if (args.fspec == 0) { 262 /* 263 * Process export requests. 264 */ 265 return (vfs_export(mp, &args.export)); | 267 if (fspec == NULL) { 268 error = vfs_getopt(opts, "export", (void **)&export, 269 &len); 270 if (error || len != sizeof(struct export_args)) 271 return (EINVAL); 272 /* Process export requests. */ 273 return (vfs_export(mp, export)); |
266 } 267 } 268 /* 269 * Not an update, or updating the name: look up the name 270 * and verify that it refers to a sensible block device. 271 */ | 274 } 275 } 276 /* 277 * Not an update, or updating the name: look up the name 278 * and verify that it refers to a sensible block device. 279 */ |
272 NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td); | 280 if (fspec == NULL) 281 return (EINVAL); 282 NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, td); |
273 if ((error = namei(ndp)) != 0) 274 return (error); 275 NDFREE(ndp, NDF_ONLY_PNBUF); 276 devvp = ndp->ni_vp; 277 278 if (!vn_isdisk(devvp, &error)) { 279 vrele(devvp); 280 return (error); --- 30 unchanged lines hidden (view full) --- 311 ump = VFSTOEXT2(mp); 312 fs = ump->um_e2fs; 313 /* 314 * Note that this strncpy() is ok because of a check at the start 315 * of ext2_mount(). 316 */ 317 strncpy(fs->fs_fsmnt, path, MAXMNTLEN); 318 fs->fs_fsmnt[MAXMNTLEN - 1] = '\0'; | 283 if ((error = namei(ndp)) != 0) 284 return (error); 285 NDFREE(ndp, NDF_ONLY_PNBUF); 286 devvp = ndp->ni_vp; 287 288 if (!vn_isdisk(devvp, &error)) { 289 vrele(devvp); 290 return (error); --- 30 unchanged lines hidden (view full) --- 321 ump = VFSTOEXT2(mp); 322 fs = ump->um_e2fs; 323 /* 324 * Note that this strncpy() is ok because of a check at the start 325 * of ext2_mount(). 326 */ 327 strncpy(fs->fs_fsmnt, path, MAXMNTLEN); 328 fs->fs_fsmnt[MAXMNTLEN - 1] = '\0'; |
319 (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 320 &size); | 329 (void)copystr(fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size); |
321 bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 322 (void)ext2_statfs(mp, &mp->mnt_stat, td); 323 return (0); 324} 325 326/* 327 * checks that the data in the descriptor blocks make sense 328 * this is taken from ext2/super.c --- 894 unchanged lines hidden --- | 330 bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 331 (void)ext2_statfs(mp, &mp->mnt_stat, td); 332 return (0); 333} 334 335/* 336 * checks that the data in the descriptor blocks make sense 337 * this is taken from ext2/super.c --- 894 unchanged lines hidden --- |