MSDOS Filesystem question related to "read-only" files

Karl Denninger karl at denninger.net
Mon Nov 20 20:08:14 UTC 2017


Oh, my apologies -- I didn't include the version:

FreeBSD 11.0-STABLE #0 r313159M: Fri Feb  3 09:58:35 CST 2017

On an RPI2, but I doubt that matters.


On 11/20/2017 14:02, Karl Denninger wrote:
> root at Test-MCP:/home/karl/HD-MCP # cd /mnt
> root at Test-MCP:/mnt # mount
> /dev/ufs/rootfs on / (ufs, local, noatime, soft-updates, nfsv4acls)
> devfs on /dev (devfs, local)
> tmpfs on /tmp (tmpfs, local)
> /dev/da0s1 on /mnt (msdosfs, local)
> root at Test-MCP:/mnt # ls -al
> total 408
> drwxr-xr-x   1 hdmcp  wheel    4096 Jan  1  1980 .
> drwxr-xr-x  20 root   wheel     512 Nov 20 16:04 ..
> drwxr-xr-x   1 hdmcp  wheel    4096 Nov 19 11:20 System Volume Information
> -rwxr-xr-x   1 hdmcp  wheel  127979 Nov 19 22:54
> cam2-2017-11-19-22-54-47.jpg
> -rwxr-xr-x   1 hdmcp  wheel  271295 Nov 19 22:57
> cam2-2017-11-19-22-57-20.jpg
> root at Test-MCP:/mnt # chmod u-w *
> root at Test-MCP:/mnt # ls -al
> total 408
> drwxr-xr-x   1 hdmcp  wheel    4096 Jan  1  1980 .
> drwxr-xr-x  20 root   wheel     512 Nov 20 16:04 ..
> drwxr-xr-x   1 hdmcp  wheel    4096 Nov 19 11:20 System Volume Information
> -rwxr-xr-x   1 hdmcp  wheel  127979 Nov 19 22:54
> cam2-2017-11-19-22-54-47.jpg
> -rwxr-xr-x   1 hdmcp  wheel  271295 Nov 19 22:57
> cam2-2017-11-19-22-57-20.jpg
> root at Test-MCP:/mnt #
>
> 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)
>
> On 11/20/2017 12:30, Conrad Meyer wrote:
>> Hi Karl,
>>
>> In fact, msdosfs in FreeBSD should set the FAT READONLY attribute
>> under two conditions:
>>
>> 1. The owner chmod's the file non-writeable (chmod u-w) (what you've
>> described, I think).  Or,
>> 2. The super user or otherwise privileged user sets the "readonly"
>> flag on the file via chflags(1).
>>
>> How have you determined that chmod u-w does nothing?  What version of
>> FreeBSD are you using?
>>
>> Best,
>> Conrad
>>
>>
>> On Mon, Nov 20, 2017 at 7:36 AM, Karl Denninger <karl at denninger.net> wrote:
>>> I'm running into an interesting issue here and wondering if there's a
>>> way to do this under FreeBSD.
>>>
>>> MSDOS filesystems have a "primitive" permission capability;
>>> specifically, they can have a "Read-only" attribute on a file.  It looks
>>> like OpenBSD supports this from reading their man pages.
>>>
>>> FreeBSD doesn't appear to.  When you mount a msdos filesystem (e.g. a
>>> USB stick) whoever owns the parent directory where you mount it gives
>>> you the permissions and "ownership" of files on said filesystem.  All
>>> good so far.  But attempting to chmod a file to remove write permission
>>> "succeeds" (returns success) but does nothing.
>>>
>>> Is this capability simply not present on FreeBSD?  I'm interested in
>>> using it as a means of "flagging" files on a USB stick in an application
>>> that I do not want to remove if the stick fills (basically, to "protect"
>>> them from being aged off) and it appears there's no way to do it, other
>>> than to use something unique in the filename that I would then have to
>>> pay attention to.
>>>
>>> --
>>> Karl Denninger
>>> karl at denninger.net <mailto:karl at denninger.net>
>>> /The Market Ticker/
>>> /[S/MIME encrypted email preferred]/

-- 
Karl Denninger
karl at denninger.net <mailto:karl at denninger.net>
/The Market Ticker/
/[S/MIME encrypted email preferred]/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4897 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20171120/e57d7fee/attachment.bin>


More information about the freebsd-fs mailing list