sys/mount.h MNT_DETACH and MNT_EXPIRE

Kevin Day thekevinday at gmail.com
Thu May 15 19:34:04 PDT 2008


I was writing an initrd pivot_root program and found out I had to use
umout2(some_path, MNT_DETACH); in order to properly get the system to
umount some_dir after a chroot.


Thats when I noticed that uClibc-0.9.28.3/include/sys/mount.h did not
define MNT_DETACH nor did it define MNT_EXPIRE.
According to the manpage, it MNT_DETACH and MNT_EXPIRE should exist in
sys/mount.h

I added MNT_DETACH =2 and MNT_EXPIRE = 4 to my build, but I am not
certain if hey

I then looked at glibc to see if they implemented this so that I could
get the correct numbers and they also did not define these.

When I used MNT_DETACH (set to 2), the detach functionality worked properly.

So, what is going on here?
An example manpage of mount(2) can be found here:
http://linux.die.net/man/2/mount

Here is their explanation:
MNT_FORCE (since Linux 2.1.116)
    Force unmount even if busy. (Only for NFS mounts.)
MNT_DETACH (since Linux 2.4.11)
    Perform a lazy unmount: make the mount point unavailable for new
accesses, and actually perform the unmount when the mount point ceases
to be busy.
MNT_EXPIRE (since Linux 2.6.8)
    Mark the mount point as expired. If a mount point is not currently
in use, then an initial call to umount2() with this flag fails with
the error EAGAIN, but marks the mount point as expired. The mount
point remains expired as long as it isn't accessed by any process. A
second umount2() call specifying MNT_EXPIRE unmounts an expired mount
point. This flag cannot be specified with either MNT_FORCE or
MNT_DETACH.



-- 
Kevin Day



More information about the hlfs-dev mailing list