From c2333909d4119b0b11bb182ddf4c177bc903d19e Mon Sep 17 00:00:00 2001 From: bde Date: Tue, 7 Aug 2007 05:42:10 +0000 Subject: Fix and update the comments about the effect of the read-only flag on writing. They are still too verbose. Remove nearby unreachable code for handling symlinks. Approved by: re (kensmith) (blanket) --- sys/fs/msdosfs/msdosfs_vnops.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'sys') diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 349e51a..0879915 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -265,14 +265,12 @@ msdosfs_access(ap) file_mode &= (vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask); /* - * Disallow write attempts on read-only filesystems; - * unless the file is a socket, fifo, or a block or - * character device resident on the filesystem. + * Disallow writing to directories and regular files if the + * filesystem is read-only. */ if (mode & VWRITE) { switch (vp->v_type) { case VDIR: - case VLNK: case VREG: if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); @@ -459,20 +457,28 @@ msdosfs_setattr(ap) } if (vap->va_size != VNOVAL) { - /* - * Disallow write attempts on read-only filesystems; - * unless the file is a socket, fifo, or a block or - * character device resident on the filesystem. - */ switch (vp->v_type) { case VDIR: return (EISDIR); - case VLNK: case VREG: + /* + * Truncation is only supported for regular files, + * Disallow it if the filesystem is read-only. + */ if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); break; default: + /* + * According to POSIX, the result is unspecified + * for file types other than regular files, + * directories and shared memory objects. We + * don't support any file types except regular + * files and directories in this file system, so + * this (default) case is unreachable and can do + * anything. Keep falling through to detrunc() + * for now. + */ break; } error = detrunc(dep, vap->va_size, 0, cred, ap->a_td); -- cgit v1.1