From 7c0b7f1f33989974bd139577a87ae029a6f46aa9 Mon Sep 17 00:00:00 2001 From: tjr Date: Sat, 24 Jan 2004 08:43:06 +0000 Subject: Copy workaround from FFS: open device for write access even if the user requests a read-only mount. This is necessary because we don't do the VOP_OPEN again if they upgrade a read-only mount to read-write. Noticed by: bde --- sys/gnu/ext2fs/ext2_vfsops.c | 19 +++++++++++++++++++ sys/gnu/fs/ext2fs/ext2_vfsops.c | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'sys/gnu') diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 1fa812c..b3b327d 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -655,7 +655,16 @@ ext2_mountfs(devvp, mp, td) ronly = (mp->mnt_flag & MNT_RDONLY) != 0; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + /* + * XXX Open the device with write access even if the filesystem + * is read-only: someone may remount it read-write later, and + * we don't VOP_OPEN the device again in that case. + */ +#ifdef notyet error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td, -1); +#else + error = VOP_OPEN(devvp, FREAD|FWRITE, FSCRED, td, -1); +#endif VOP_UNLOCK(devvp, 0, td); if (error) return (error); @@ -735,7 +744,12 @@ ext2_mountfs(devvp, mp, td) out: if (bp) brelse(bp); + /* XXX See comment at VOP_OPEN call */ +#ifdef notyet (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); +#else + (void)VOP_CLOSE(devvp, FREAD|FWRITE, NOCRED, td); +#endif if (ump) { bsd_free(ump->um_e2fs->s_es, M_EXT2MNT); bsd_free(ump->um_e2fs, M_EXT2MNT); @@ -790,8 +804,13 @@ ext2_unmount(mp, mntflags, td) ULCK_BUF(fs->s_block_bitmap[i]) ump->um_devvp->v_rdev->si_mountpoint = NULL; + /* XXX See comment at VOP_OPEN call */ +#ifdef notyet error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); +#else + error = VOP_CLOSE(ump->um_devvp, FREAD|FWRITE, NOCRED, td); +#endif vrele(ump->um_devvp); bsd_free(fs->s_es, M_EXT2MNT); bsd_free(fs, M_EXT2MNT); diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 1fa812c..b3b327d 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -655,7 +655,16 @@ ext2_mountfs(devvp, mp, td) ronly = (mp->mnt_flag & MNT_RDONLY) != 0; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); + /* + * XXX Open the device with write access even if the filesystem + * is read-only: someone may remount it read-write later, and + * we don't VOP_OPEN the device again in that case. + */ +#ifdef notyet error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td, -1); +#else + error = VOP_OPEN(devvp, FREAD|FWRITE, FSCRED, td, -1); +#endif VOP_UNLOCK(devvp, 0, td); if (error) return (error); @@ -735,7 +744,12 @@ ext2_mountfs(devvp, mp, td) out: if (bp) brelse(bp); + /* XXX See comment at VOP_OPEN call */ +#ifdef notyet (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); +#else + (void)VOP_CLOSE(devvp, FREAD|FWRITE, NOCRED, td); +#endif if (ump) { bsd_free(ump->um_e2fs->s_es, M_EXT2MNT); bsd_free(ump->um_e2fs, M_EXT2MNT); @@ -790,8 +804,13 @@ ext2_unmount(mp, mntflags, td) ULCK_BUF(fs->s_block_bitmap[i]) ump->um_devvp->v_rdev->si_mountpoint = NULL; + /* XXX See comment at VOP_OPEN call */ +#ifdef notyet error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td); +#else + error = VOP_CLOSE(ump->um_devvp, FREAD|FWRITE, NOCRED, td); +#endif vrele(ump->um_devvp); bsd_free(fs->s_es, M_EXT2MNT); bsd_free(fs, M_EXT2MNT); -- cgit v1.1