What does "mount -o union" and MNT_UNION really do?

Tobias Roth ports at fsck.ch
Fri Feb 23 07:21:48 UTC 2007


[resend, as I forgot to cc the lists and only replied to Craig]

On Thu, February 22, 2007 11:23 pm, Craig Rodrigues wrote:
> Hi,
>
> As part of recent cleanups and stability fixes in vfs_syscalls.c,
> Kostik Belousov removed the union_dircheckp() callback
> which the old unionfs implementation used, but the new one does not.
>
> Now I am looking at the mount code in vfs_mount.c, and
> am trying to figure out what the MNT_UNION flag
> is used for, which is set by doing "mount -o union".
> The following code in vfs_mount.c sets it:
>
>                else if (strcmp(opt->name, "union") == 0)
>                         fsflags |= MNT_UNION;
>
>
> However, the mount_unionfs binary never passes down "-o union",
> so the  MNT_UNION flag is never set if you do: "mount -t unionfs"
> or "mount_unionfs".
>
> The mount(8) man page documents it as:
>              union   Causes the namespace at the mount point to appear as
> the
>                      union of the mounted file system root and the
> existing
>                      directory.  Lookups will be done in the mounted file
> sys-
>                      tem first.  If those operations fail due to a
> non-exis-
>                      tent file the underlying directory is then accessed.
> All
>                      creates are done in the mounted file system.
>
>
> Is there a legitimate case where you would
> want to do "mount -o union", and have it behave differently
> from "mount_unionfs / mount -t unionfs"?  Or is this a leftover from
> a long time ago that we can now whack (it would simplify some code
> in the VFS layer if we whack it)?
>
> The MNT_UNION flag seemed to appear a long time ago:
>
> revision 1.120
> date: 1999/03/03 02:35:51;  author: julian;  state: Exp;  lines: +35 -33
> Slight cleanup of code resurected for union mounts..
> Submitted by: Tony Finch <dot at dotat.at>
> ----------------------------
> revision 1.119
> date: 1999/02/27 07:06:05;  author: julian;  state: Exp;  lines: +23 -1
> Fix code for union mounts
> Accidentally deleted by peter when he extracted the unionfs stuff in 1.109
>
> Submitted by: Tony Finch <dot at dotat.at>
> ----------------------------
> revision 1.109
> date: 1998/11/03 08:01:47;  author: peter;  state: Exp;  lines: +15 -114
> Change the #ifdef UNION code into a callable hook.  Arrange to have this
> set up when unionfs is present, either statically or as a kld module.
>
>
> --
> Craig Rodrigues
> rodrigc at crodrigues.org
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
>




More information about the freebsd-fs mailing list