Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Feb 2007 17:23:01 -0500
From:      Craig Rodrigues <rodrigc@crodrigues.org>
To:        freebsd-current@freebsd.org
Cc:        freebsd-fs@freebsd.org
Subject:   What does "mount -o union" and MNT_UNION really do?
Message-ID:  <20070222222301.GA13464@crodrigues.org>

next in thread | raw e-mail | index | archive | help
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@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@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@crodrigues.org



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