OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / man2 / umount.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 1993 Rickard E. Faith <faith@cs.unc.edu>
4 .\" and Copyright (C) 1994 Andries E. Brouwer <aeb@cwi.nl>
5 .\" and Copyright (C) 2002, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
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 2010-06-19 "Linux" "Linux Programmer's Manual"
31 .SH NAME
32 umount, umount2 \- unmount file system
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) file system 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 file systems.
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 file systems.
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 file-system type independent
106 errors.
107 Each file system type may have its own special errors and its
108 own special behavior.
109 See the 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 file system 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 Or,
130 .BR umount2 ()
131 was called with
132 .B MNT_EXPIRE
133 and either
134 .B MNT_DETACH
135 or
136 .BR MNT_FORCE .
137 .TP
138 .B ENAMETOOLONG
139 A pathname was longer than
140 .BR MAXPATHLEN .
141 .TP
142 .B ENOENT
143 A pathname was empty or had a nonexistent component.
144 .TP
145 .B ENOMEM
146 The kernel could not allocate a free page to copy filenames or data into.
147 .TP
148 .B EPERM
149 The caller does not have the required privileges.
150 .SH VERSIONS
151 .BR MNT_DETACH
152 and
153 .BR MNT_EXPIRE
154 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092
155 are only available in glibc since version 2.11.
156 .SH "CONFORMING TO"
157 These functions are Linux-specific and should not be used in
158 programs intended to be portable.
159 .SH NOTES
160 The original
161 .BR umount ()
162 function was called as \fIumount(device)\fP and would return
163 .B ENOTBLK
164 when called with something other than a block device.
165 In Linux 0.98p4 a call \fIumount(dir)\fP was added, in order to
166 support anonymous devices.
167 In Linux 2.3.99-pre7 the call \fIumount(device)\fP was removed,
168 leaving only \fIumount(dir)\fP (since now devices can be mounted
169 in more than one place, so specifying the device does not suffice).
170 .SH "SEE ALSO"
171 .BR mount (2),
172 .BR path_resolution (7),
173 .BR mount (8),
174 .BR umount (8)