summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2007-08-07 05:42:10 +0000
committerbde <bde@FreeBSD.org>2007-08-07 05:42:10 +0000
commitc2333909d4119b0b11bb182ddf4c177bc903d19e (patch)
tree5497b1c0dff6cf2fc7f0370060d47224828d95f6 /sys
parent52bd1282cd2a3838c1533a3d8db458470c53cde0 (diff)
downloadFreeBSD-src-c2333909d4119b0b11bb182ddf4c177bc903d19e.zip
FreeBSD-src-c2333909d4119b0b11bb182ddf4c177bc903d19e.tar.gz
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)
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c26
1 files changed, 16 insertions, 10 deletions
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);
OpenPOWER on IntegriCloud