OSDN Git Service

32100adbaa74ae069926c72a9982898103629b4b
[linuxjm/LDP_man-pages.git] / original / man2 / umount.2
1 .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
2 .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
3 .\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" 2008-10-06, mtk: Created this as a new page by splitting
28 .\"     umount/umount2 material out of mount.2
29 .\"
30 .TH UMOUNT 2 2014-02-26 "Linux" "Linux Programmer's Manual"
31 .SH NAME
32 umount, umount2 \- unmount filesystem
33 .SH SYNOPSIS
34 .nf
35 .B "#include <sys/mount.h>"
36 .sp
37 .BI "int umount(const char *" target );
38 .sp
39 .BI "int umount2(const char *" target ", int " flags );
40 .fi
41 .SH DESCRIPTION
42 .BR umount ()
43 and
44 .BR umount2 ()
45 remove the attachment of the (topmost) filesystem mounted on
46 .IR target .
47 .\" Note: the kernel naming differs from the glibc naming
48 .\" umount2 is the glibc name for what the kernel now calls umount
49 .\" and umount is the glibc name for oldumount
50
51 Appropriate privilege (Linux: the
52 .B CAP_SYS_ADMIN
53 capability) is required to unmount filesystems.
54
55 Linux 2.1.116 added the
56 .BR umount2 ()
57 system call, which, like
58 .BR umount (),
59 unmounts a target, but allows additional
60 .I flags
61 controlling the behavior of the operation:
62 .TP
63 .BR MNT_FORCE " (since Linux 2.1.116)"
64 Force unmount even if busy.
65 This can cause data loss.
66 (Only for NFS mounts.)
67 .TP
68 .BR MNT_DETACH " (since Linux 2.4.11)"
69 Perform a lazy unmount: make the mount point unavailable for
70 new accesses, and actually perform the unmount when the mount point
71 ceases to be busy.
72 .TP
73 .BR MNT_EXPIRE " (since Linux 2.6.8)"
74 Mark the mount point as expired.
75 If a mount point is not currently in use, then an initial call to
76 .BR umount2 ()
77 with this flag fails with the error
78 .BR EAGAIN ,
79 but marks the mount point as expired.
80 The mount point remains expired as long as it isn't accessed
81 by any process.
82 A second
83 .BR umount2 ()
84 call specifying
85 .B MNT_EXPIRE
86 unmounts an expired mount point.
87 This flag cannot be specified with either
88 .B MNT_FORCE
89 or
90 .BR MNT_DETACH .
91 .TP
92 .BR UMOUNT_NOFOLLOW " (since Linux 2.6.34)"
93 .\" Later added to 2.6.33-stable
94 Don't dereference
95 .I target
96 if it is a symbolic link.
97 This flag allows security problems to be avoided in set-user-ID-\fIroot\fP
98 programs that allow unprivileged users to unmount filesystems.
99 .SH RETURN VALUE
100 On success, zero is returned.
101 On error, \-1 is returned, and
102 .I errno
103 is set appropriately.
104 .SH ERRORS
105 The error values given below result from filesystem type independent
106 errors.
107 Each filesystem type may have its own special errors and its
108 own special behavior.
109 See the Linux kernel source code for details.
110 .TP
111 .B EAGAIN
112 A call to
113 .BR umount2 ()
114 specifying
115 .B MNT_EXPIRE
116 successfully marked an unbusy filesystem as expired.
117 .TP
118 .B EBUSY
119 .I target
120 could not be unmounted because it is busy.
121 .TP
122 .B EFAULT
123 .I target
124 points outside the user address space.
125 .TP
126 .B EINVAL
127 .I target
128 is not a mount point.
129 .TP
130 .B EINVAL
131 .BR umount2 ()
132 was called with
133 .B MNT_EXPIRE
134 and either
135 .B MNT_DETACH
136 or
137 .BR MNT_FORCE .
138 .TP
139 .BR EINVAL " (since Linux 2.6.34)"
140 .BR umount2 ()
141 was called with an invalid flag value in
142 .IR flags .
143 .TP
144 .B ENAMETOOLONG
145 A pathname was longer than
146 .BR MAXPATHLEN .
147 .TP
148 .B ENOENT
149 A pathname was empty or had a nonexistent component.
150 .TP
151 .B ENOMEM
152 The kernel could not allocate a free page to copy filenames or data into.
153 .TP
154 .B EPERM
155 The caller does not have the required privileges.
156 .SH VERSIONS
157 .BR MNT_DETACH
158 and
159 .BR MNT_EXPIRE
160 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092
161 are available in glibc since version 2.11.
162 .SH CONFORMING TO
163 These functions are Linux-specific and should not be used in
164 programs intended to be portable.
165 .SH NOTES
166 The original
167 .BR umount ()
168 function was called as \fIumount(device)\fP and would return
169 .B ENOTBLK
170 when called with something other than a block device.
171 In Linux 0.98p4, a call \fIumount(dir)\fP was added, in order to
172 support anonymous devices.
173 In Linux 2.3.99-pre7, the call \fIumount(device)\fP was removed,
174 leaving only \fIumount(dir)\fP (since now devices can be mounted
175 in more than one place, so specifying the device does not suffice).
176 .SH SEE ALSO
177 .BR mount (2),
178 .BR path_resolution (7),
179 .BR mount (8),
180 .BR umount (8)
181 .SH COLOPHON
182 This page is part of release 3.79 of the Linux
183 .I man-pages
184 project.
185 A description of the project,
186 information about reporting bugs,
187 and the latest version of this page,
188 can be found at
189 \%http://www.kernel.org/doc/man\-pages/.