Date: Mon, 20 Nov 2017 12:51:09 -0800 From: Conrad Meyer <cem@freebsd.org> To: Karl Denninger <karl@denninger.net> Cc: "freebsd-fs@freebsd.org" <freebsd-fs@freebsd.org> Subject: Re: MSDOS Filesystem question related to "read-only" files Message-ID: <CAG6CVpXQz_E=jtKK3g%2BcPRQ=m9hKz7sBazbRNhUJqKaStzrhCQ@mail.gmail.com> In-Reply-To: <e6a682a1-322e-a677-3d5e-0a7a503ebd40@denninger.net> References: <f4ccb904-63fd-4641-89c8-09357fbb5a1c@denninger.net> <CAG6CVpUZumZaU9xVcri1Ry8=C6j6JrjX5F6qd3oKatYZXFu6Kg@mail.gmail.com> <e6a682a1-322e-a677-3d5e-0a7a503ebd40@denninger.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Nov 20, 2017 at 12:02 PM, Karl Denninger <karl@denninger.net> wrote: > root@Test-MCP:/mnt # ls -al > ... > -rwxr-xr-x 1 hdmcp wheel 127979 Nov 19 22:54 > cam2-2017-11-19-22-54-47.jpg > ... > root@Test-MCP:/mnt # chmod u-w * > root@Test-MCP:/mnt # ls -al > ... > -rwxr-xr-x 1 hdmcp wheel 127979 Nov 19 22:54 > cam2-2017-11-19-22-54-47.jpg > ... > Nope. The "w" is still there. > > No error returned from the "chmod" command (or if I call it from a C > program) but the file mode is NOT changed whether I'm doing it as the > superuser or as the owner of the file (and directory) Indeed, msdosfs does not reflect the READONLY attribute back to userspace in the form of the mode. That's a bug that could be fixed pretty easily: --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -287,6 +287,8 @@ msdosfs_getattr(struct vop_getattr_args *ap) vap->va_fileid = fileid; mode = S_IRWXU|S_IRWXG|S_IRWXO; + if ((dep->de_Attributes & ATTR_READONLY) != 0) + mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); vap->va_mode = mode & (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask); vap->va_uid = pmp->pm_uid; However, despite 'ls' showing 'w', it *does* set the READONLY attribute on the file. Try invoking ls(1) with '-o' and looking for the "rdonly" or "readonly" flag. Best, Conrad
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpXQz_E=jtKK3g%2BcPRQ=m9hKz7sBazbRNhUJqKaStzrhCQ>