Is chflags' "nodump + sunlnk" = "uchg"
Dan Nelson
dnelson at allantgroup.com
Thu Nov 13 11:09:28 PST 2008
In the last episode (Nov 13), Charles Darwin said:
> On 12-Nov-08, at 6:43 PM, Dan Nelson wrote:
> > In the last episode (Nov 12), Charles Darwin said:
> >> Hi all,
> >>
> >> Title is the question actually: Is chflags' "nodump + sunlnk" =
> >> "uchg"
> >
> > No; why would it be?
>
> I mean as far as their effect on a directory; doesn't "Don't change"
> for a directory mean "Don't add + Don't remove"?
Ok, that's sort of a different question. "nodump" is only checked by
/sbin/dump, so we'll skip that. "sunlnk" is a root-only flag, while
"uchg" can be set or reset by the file's owner as well. So let's look
at "uunlnk" and "uchg":
$ mkdir lnk chg
$ touch lnk/file1 chg/file1
$ chflags uunlnk lnk ; chflags uchg chg
$ ls -lo
total 8
drwxr-xr-x 4 dan wheel - 512 Nov 13 12:59 ./
drwxrwxrwt 24 root wheel - 1024 Nov 13 12:59 ../
drwxr-xr-x 2 dan wheel uchg 512 Nov 13 12:59 chg/
drwxr-xr-x 2 dan wheel uunlnk 512 Nov 13 12:59 lnk/
$ rm chg/file1
rm: chg/file1: Operation not permitted
$ rm lnk/file1
$ touch chg/file2
touch: chg/file2: Operation not permitted
$ touch lnk/file2
$ rm lnk/file2
$ mv chg chg1
mv: rename chg to chg1: Operation not permitted
$ mv lnk lnk1
mv: rename lnk to lnk1: Operation not permitted
$ rmdir chg
rmdir: chg: Operation not permitted
$ rmdir lnk
rmdir: lnk: Operation not permitted
So as far as directories are concerned, the only difference between
uchg and uunlnk is that uchg prohibits creation and deletion of files
inside it, and uunlnk allows it.
You can also look at /sys/ufs/ufs/ufs_vnops.c and see what code looks
at which flags.
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-hackers
mailing list