Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Jun 2002 12:22:43 +0200
From:      "Patrick Bihan-Faou" <patrick-fbsdfs@mindstep.com>
To:        <freebsd-fs@freebsd.org>
Subject:   Strange behavior of 'union' mounted filesystems
Message-ID:  <DBEFLLCPEGLPEAGOPLIHOENCDKAA.patrick-fbsdfs@mindstep.com>
In-Reply-To: <1577698468.20020623150139@e-complex.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

While playing with FS options, I came accross something that looks
suspicious to me while using the 'union' mount option (not the UNIONFS):

Here is what I have in my /etc/fstab:

/dev/ad0s1a /         ufs    rw,suiddir,groupquota         0 1
/dev/ad0s1b none      swap   sw                            0 0
/dev/ad0s1e /var      ufs    rw                            0 2
/dev/ad0s1f /data     ufs    rq,suiddir,groupquota         0 3
/dev/ad0s1b /tmp_mfs  mfs    rw,-s65536,union,noauto       0 3
proc        /proc     procfs rw                            0 0

Now initially, after booting, I have:

bash-2.04# mount
/dev/ad0s1a on / (ufs, local, with quotas, suiddir)
/dev/ad0s1e on /var (ufs, local)
/dev/ad0s1f on /data (ufs, local, with quotas, suiddir, soft-updates)
procfs on /proc (procfs, local)

If I put a file in /tmp_mfs at this stage everything is OK, and when I mount
the /tmp_mfs filesystem, everything works as expected: I can see the
existing file(s), etc.

My problem is when I put a flag on the files in /tmp_mfs *BEFORE* mounting
the /tmp_mfs FS:

bash-2.04# ls /tmp_mfs/
bash-2.04# echo "test" > /tmp_mfs/test
bash-2.04# chflags schg /tmp_mfs/test
bash-2.04# ls -lio /tmp_mfs/
total 1
10678 -rw-r--r--  1 root  wheel  schg 5 Jun 23 11:53 test
bash-2.04#


And then I mount the filesystem:

bash-2.04# cat /tmp_mfs/test
test

bash-2.04# mount /tmp_mfs
Warning: Block size restricts cylinders per group to 23.

bash-2.04# mount
/dev/ad0s1a on / (ufs, local, with quotas, suiddir)
/dev/ad0s1e on /var (ufs, local)
/dev/ad0s1f on /data (ufs, local, with quotas, suiddir, soft-updates)
procfs on /proc (procfs, local)
mfs:38280 on /tmp_mfs (mfs, asynchronous, local, union)

bash-2.04# ls -lio /tmp_mfs
total 1
10678 -rw-r--r--  1 root  wheel  schg 5 Jun 23 11:53 test

bash-2.04# cat /tmp_mfs/test
test

bash-2.04# echo "bad" > /tmp_mfs/test

bash-2.04# cat /tmp_mfs/test
bad

bash-2.04# ls -lio /tmp_mfs
total 1
3 -rw-r--r--  1 root  wheel  - 4 Jun 23 11:56 test


As you can see the 'schg' flag on the underlying flag is not checked if the
file is open for writing. It is however checked in case I try to delete the
file:

bash-2.04# rm /tmp_mfs/test       # get rid of the overriding file
bash-2.04# rm /tmp_mfs/test       # get rid of the underlying file
override rw-r--r--  root/wheel schg for /tmp_mfs/test? y
rm: /tmp_mfs/test: Operation not permitted



Now, this to me seems like a bug, but it could very well be due to my lack
of understanding of how union mounted filesystems work. If the file exists
in the underlying FS, shouldn't the permissions and flags be honored before
a 'create' is attempted in the 'upper' FS ? This clearly does not look like
it is the case currently.


These tests were done on a FreeBSD-stable system:
FreeBSD kawa.local.mindstep.com 4.4-STABLE FreeBSD 4.4-STABLE #0: Fri Jan 25
02:59:41 CET 2002
root@kawa.local.mindstep.com:/data/users/patrick/build/25.4/tmpobj/data/user
s/patrick/build/25.4/freebsd-src/sys/ZUNOBOX_DEV  i386



If somebody can enlighten me, it would really be appreciated.


Patrick.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-fs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DBEFLLCPEGLPEAGOPLIHOENCDKAA.patrick-fbsdfs>