Subject: Union mount question
To: None <netbsd-users@netbsd.org>
From: Brendon Costa <bcosta@avdat.com.au>
List: netbsd-users
Date: 08/28/2007 15:37:36
Hi all,

I recently came across an issue using NetBSD where a union mount did
not behave as i expected. I looked into the man page and the behavior
is correct as documented, however I just wanted to see what reasons
there might be to behave like this.

Basically if i have a root file system mounted read-only with:
/home/bob

here the above directory as normal is owned by bob:users. I then
create a new mfs:
mount -t mfs -o -s=15m swap /mnt/mfs

and then as root user union mount that over the top of home:
mkdir -p /mnt/mfs/home
mount -t union /mnt/mfs/home /home

You will find that the folder automatically created in the "upper"
memory file system (shadow directory):
/mnt/mfs/home/bob

is owned by root:wheel, where i would have expected it to copy the
ownership and permissions of the lower layer so i would expect it to
be bob:users.

This means that bob cant login as he no-longer owns his own home
directory. I noticed however that i can do a chown bob:users
/mnt/mfs/bob (after it has been created) and the changes remain for
the session. But i figure doing that should be un-necessary.

This is just a demonstration, but practically it means that under a
union mount you cant easily have directories owned by different
people. I guess I wanted to ask why is this the desired behavior?

It was mentioned explicitly in the man page that shadow directories
that are created are owned by the user who originally did the union
mount with perms 0777 modified by umask.

Thanks,
Brendon.