1UMOUNT(2)                  Linux Programmer's Manual                 UMOUNT(2)
2
3
4

NAME

6       umount, umount2 - unmount file system
7

SYNOPSIS

9       #include <sys/mount.h>
10
11       int umount(const char *target);
12
13       int umount2(const char *target, int flags);
14

DESCRIPTION

16       umount() and umount2() remove the attachment of the (topmost) file sys‐
17       tem mounted on target.
18
19       Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required
20       to unmount file systems.
21
22       Linux  2.1.116  added  the umount2() system call, which, like umount(),
23       unmounts a target, but allows additional flags controlling the behavior
24       of the operation:
25
26       MNT_FORCE (since Linux 2.1.116)
27              Force  unmount  even  if busy.  This can cause data loss.  (Only
28              for NFS mounts.)
29
30       MNT_DETACH (since Linux 2.4.11)
31              Perform a lazy unmount: make the mount point unavailable for new
32              accesses,  and actually perform the unmount when the mount point
33              ceases to be busy.
34
35       MNT_EXPIRE (since Linux 2.6.8)
36              Mark the mount point as expired.  If a mount point is  not  cur‐
37              rently  in use, then an initial call to umount2() with this flag
38              fails with the error  EAGAIN,  but  marks  the  mount  point  as
39              expired.   The  mount  point remains expired as long as it isn't
40              accessed by any process.  A  second  umount2()  call  specifying
41              MNT_EXPIRE unmounts an expired mount point.  This flag cannot be
42              specified with either MNT_FORCE or MNT_DETACH.
43
44       UMOUNT_NOFOLLOW (since Linux 2.6.34)
45              Don't dereference target if it is a symbolic  link.   This  flag
46              allows  security  problems  to be avoided in in set-user-ID-root
47              programs that allow unprivileged users to unmount file systems.
48

RETURN VALUE

50       On success, zero is returned.  On error, -1 is returned, and  errno  is
51       set appropriately.
52

ERRORS

54       The  error  values given below result from file-system type independent
55       errors.  Each file system type may have its own special errors and  its
56       own special behavior.  See the kernel source code for details.
57
58       EAGAIN A call to umount2() specifying MNT_EXPIRE successfully marked an
59              unbusy file system as expired.
60
61       EBUSY  target could not be unmounted because it is busy.
62
63       EFAULT target points outside the user address space.
64
65       EINVAL target is not a mount point.   Or,  umount2()  was  called  with
66              MNT_EXPIRE and either MNT_DETACH or MNT_FORCE.
67
68       ENAMETOOLONG
69              A pathname was longer than MAXPATHLEN.
70
71       ENOENT A pathname was empty or had a nonexistent component.
72
73       ENOMEM The  kernel  could not allocate a free page to copy filenames or
74              data into.
75
76       EPERM  The caller does not have the required privileges.
77

VERSIONS

79       MNT_DETACH and MNT_EXPIRE are only available  in  glibc  since  version
80       2.11.
81

CONFORMING TO

83       These  functions  are Linux-specific and should not be used in programs
84       intended to be portable.
85

NOTES

87       The original umount() function was called as umount(device)  and  would
88       return  ENOTBLK  when  called with something other than a block device.
89       In Linux 0.98p4 a call umount(dir)  was  added,  in  order  to  support
90       anonymous  devices.   In  Linux 2.3.99-pre7 the call umount(device) was
91       removed, leaving only umount(dir) (since now devices can be mounted  in
92       more than one place, so specifying the device does not suffice).
93

SEE ALSO

95       mount(2), path_resolution(7), mount(8), umount(8)
96

COLOPHON

98       This  page  is  part of release 3.25 of the Linux man-pages project.  A
99       description of the project, and information about reporting  bugs,  can
100       be found at http://www.kernel.org/doc/man-pages/.
101
102
103
104Linux                             2010-06-19                         UMOUNT(2)
Impressum