|Main index||Section 8||日本語||Options|
The options are as follows:
Options are specified with the
|below||Inverts the default position, so that directory becomes the lower layer and uniondir becomes the upper layer. However, uniondir remains the mount point.|
|copymode = traditional | transparent | masquerade|
|Specifies the way to create a file or a directory in the upper layer automatically when needed. The traditional mode uses the same way as the old unionfs for backward compatibility, and transparent duplicates the file and directory mode bits and the ownership in the lower layer to the created file in the upper layer. For behavior of the masquerade mode, see MASQUERADE MODE below.|
|whiteout = always | whenneeded|
|Specifies whether whiteouts should always be made in the upper layer when removing a file or directory or only when it already exists in the lower layer.|
|Specifies directory mode bits in octal for masquerade mode.|
|Specifies file mode bits in octal for masquerade mode.|
|Specifies group for masquerade mode.|
|Specifies user for masquerade mode.|
To enforce file system security, the user mounting a file system must be superuser or else have write permission on the mounted-on directory. In addition, the vfs.usermount sysctl(8) variable must be set to 1 to permit file system mounting by ordinary users. However, note that transparent and masquerade modes require vfs.usermount to be set to 0 because this functionality can only be used by superusers.
Filenames are looked up in the upper layer and then in the lower layer. If a directory is found in the lower layer, and there is no entry in the upper layer, then a shadow directory will be created in the upper layer. The ownership and the mode bits are set depending on the copymode option. In traditional mode, it will be owned by the user who originally did the union mount, with mode 0777 ("rwxrwxrwx") modified by the umask in effect at that time.
If a file exists in the upper layer then there is no way to access a file with the same name in the lower layer. If necessary, a combination of loopback and union mounts can be made which will still allow the lower files to be accessed by a different pathname.
Except in the case of a directory, access to an object is granted via the normal file system access checks. For directories, the current user must have access to both the upper and lower directories (should they both exist).
Requests to create or modify objects in uniondir are passed to the upper layer with the exception of a few special cases. An attempt to open for writing a file which exists in the lower layer causes a copy of the entire file to be made to the upper layer, and then for the upper layer copy to be opened. Similarly, an attempt to truncate a lower layer file to zero length causes an empty file to be created in the upper layer. Any other operation which would ultimately require modification to the lower layer fails with EROFS.
The union file system manipulates the namespace, rather than individual file systems. The union operation applies recursively down the directory tree now rooted at uniondir. Thus any file systems which are mounted under uniondir will take part in the union operation. This differs from the union option to mount(8) which only applies the union operation to the mount point itself, and then only for lookups.
The default values for ufile, udir, uid, and gid are as follow:
mount -t cd9660 -o ro /dev/cd0 /usr/src mount -t unionfs -o noatime /var/obj /usr/src
mount the CD-ROM drive
and then attaches
For most purposes the effect of this is to make the
source tree appear writable
even though it is stored on a CD-ROM.
mount -t cd9660 -o ro /dev/cd0 /usr/src chown 2020 /usr/src mount -t unionfs -o noatime -o copymode=masquerade -o uid=builder \ -o udir=755 -o ufile=644 /var/obj /usr/src
also mount the CD-ROM drive /dev/cd0 on /usr/src and then attaches /var/obj on top. Furthermore, the owner of all files and directories in /usr/src is a regular user with UID 2020 when seen from the upper layer. Note that for the access mode bits, ones in the lower layer (on the CD-ROM, in this example) are still used without change. Thus, write privilege to the upper layer can be controlled independently from access mode bits and ownership in the lower layer. If a user does not have read privilege from the lower layer, one cannot still read even when the upper layer is mounted by using masquerade mode.
mount -t unionfs -o noatime -o below /sys $HOME/sys
attaches the system source tree below the sys directory in the user's home directory. This allows individual users to make private changes to the source, and build new kernels, without those changes becoming visible to other users. Note that the files in the lower layer remain accessible via /sys.
This code also needs an owner in order to be less dangerous - serious hackers can apply by sending mail to <Mt freebsd-fs@FreeBSD.org> and announcing their intent to take it over.
Without whiteout support from the file system backing the upper layer, there is no way that delete and rename operations on lower layer objects can be done. EOPNOTSUPP is returned for this kind of operations as generated by VOP_WHITEOUT() along with any others which would make modifications to the lower layer, such as chmod(1).
Running find(1) over a union tree has the side-effect of creating a tree of shadow directories in the upper layer.
A shadow directory, which is one automatically created in the upper layer when it exists in the lower layer and does not exist in the upper layer, is always created with the superuser privilege. However, a file copied from the lower layer in the same way is created by the user who accessed it. Because of this, if the user is not the superuser, even in transparent mode the access mode bits in the copied file in the upper layer will not always be the same as ones in the lower layer. This behavior should be fixed.
|MOUNT_UNIONFS (8)||October 3, 2016|
|Main index||Section 8||日本語||Options|
|“||One of the advantages of using UNIX to teach an operating systems course is the sources and documentation will easily fit into a student's briefcase.||”|
|— John Lions|