8815 mega_sas: variable set but not used
[unleashed.git] / usr / src / man / man2 / mount.2
blob1e6aec0e1856174c45d982c582f1a095a2e78a35
1 '\" te
2 .\" Copyright 1989 AT&T. Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH MOUNT 2 "Feb 26, 2004"
7 .SH NAME
8 mount \- mount a file system
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/types.h>
13 #include <sys/mount.h>
14 #include <sys/mntent.h>
16 \fBint\fR \fBmount\fR(\fBconst char *\fR\fIspec\fR, \fBconst char *\fR\fIdir\fR, \fBint\fR \fImflag\fR,
17      \fBchar *\fR\fIfstype\fR, \fBchar *\fR\fIdataptr\fR,\fBint\fR \fIdatalen\fR, \fBchar *\fR\fIoptptr\fR,
18      \fBint\fR \fIoptlen\fR);
19 .fi
21 .SH DESCRIPTION
22 .sp
23 .LP
24 The \fBmount()\fR function requests that a removable file system contained on
25 the block special file identified by \fIspec\fR be mounted on the directory
26 identified by \fIdir\fR. The \fIspec\fR and \fIdir\fR arguments are pointers to
27 path names.
28 .sp
29 .LP
30 After a successful call to \fBmount()\fR, all references to the file \fIdir\fR
31 refer to the root directory on the mounted file system. The mounted file system
32 is inserted into the kernel list of all mounted file systems. This list can be
33 examined through the mounted file system table (see \fBmnttab\fR(4)).
34 .sp
35 .LP
36 The \fIfstype\fR argument is the file system type name. Standard file system
37 names are defined with the prefix \fBMNTTYPE_\fR in <\fBsys/mntent.h\fR>. If
38 neither \fBMS_DATA\fR nor \fBMS_OPTIONSTR\fR is set in \fImflag\fR, then
39 \fIfstype\fR is ignored and the type of the root file system is assumed.
40 .sp
41 .LP
42 The \fIdataptr\fR argument is 0 if no file system-specific data is to be
43 passed; otherwise it points to an area of size \fIdatalen\fR that contains the
44 file system-specific data for this mount and the \fBMS_DATA\fR flag should be
45 set.
46 .sp
47 .LP
48 If the \fBMS_OPTIONSTR\fR flag is set, then \fIoptptr\fR points to a buffer
49 containing the list of options to be used for this mount. The \fIoptlen\fR
50 argument specifies the length of the buffer. On completion of the \fBmount()\fR
51 call, the options in effect for the mounted file system are returned in this
52 buffer. If \fBMS_OPTIONSTR\fR is not specified, then the options for this mount
53 will not appear in the mounted file systems table.
54 .sp
55 .LP
56 If the caller does not have all privileges available in the current zone, the
57 \fBnosuid\fR option is automatically set on the mount point. The \fBrestrict\fR
58 option is automatically added for \fBautofs\fR mounts.
59 .sp
60 .LP
61 If the caller is not in the global zone, the \fBnodevices\fR option is
62 automatically set.
63 .sp
64 .LP
65 The \fImflag\fR argument is constructed by a bitwise-inclusive-OR of flags from
66 the following list, defined in <\fBsys/mount.h\fR>.
67 .sp
68 .ne 2
69 .na
70 \fB\fBMS_DATA\fR\fR
71 .ad
72 .RS 16n
73 The \fIdataptr\fR and \fIdatalen\fR arguments describe a block of file
74 system-specific binary data at address \fIdataptr\fR of length \fIdatalen\fR.
75 This is interpreted by file system-specific code within the operating system
76 and its format depends on the file system type. If a particular file system
77 type does not require this data, \fIdataptr\fR and \fIdatalen\fR should both be
79 .RE
81 .sp
82 .ne 2
83 .na
84 \fB\fBMS_GLOBAL\fR\fR
85 .ad
86 .RS 16n
87 Mount a file system globally if the system is configured and booted as part of
88 a cluster (see \fBclinfo\fR(1M)).
89 .RE
91 .sp
92 .ne 2
93 .na
94 \fB\fBMS_NOSUID\fR\fR
95 .ad
96 .RS 16n
97 Prevent programs that are marked set-user-\fBID\fR or set-group-\fBID\fR from
98 executing (see \fBchmod\fR(1)). It also causes \fBopen\fR(2) to return
99 \fBENXIO\fR when attempting to open block or character special files.
103 .ne 2
105 \fB\fBMS_OPTIONSTR\fR\fR
107 .RS 16n
108 The \fIoptptr\fR and \fIoptlen\fR arguments describe a character buffer at
109 address \fIoptptr\fR of size \fIoptlen\fR. When calling \fBmount()\fR, the
110 character buffer should contain a null-terminated string of options to be
111 passed to the file system-specific code within the operating system. On a
112 successful return, the file system-specific code will return the list of
113 options recognized. Unrecognized options are ignored. The format of the string
114 is a list of option names separated by commas. Options that have values (rather
115 than binary options such as \fBsuid\fR or \fBnosuid\fR), are separated by
116 "\fB=\fR" such as \fBdev=2c4046c\fR. Standard option names are defined in
117 <\fBsys/mntent.h\fR>. Only strings defined in the "C" locale are supported. The
118 maximum length option string that can be passed to or returned from a
119 \fBmount()\fR call is defined by the \fBMAX_MNTOPT_STR\fR constant. The buffer
120 should be long enough to contain more options than were passed in, as the state
121 of any default options that were not passed in the input option string may also
122 be returned in the recognized options list that is returned.
126 .ne 2
128 \fB\fBMS_OVERLAY\fR\fR
130 .RS 16n
131 Allow the file system to be mounted over an existing file system mounted on
132 \fIdir\fR, making the underlying file system inaccessible. If a mount is
133 attempted on a pre-existing mount point without setting this flag, the mount
134 will fail.
138 .ne 2
140 \fB\fBMS_RDONLY\fR\fR
142 .RS 16n
143 Mount the file system for reading only. This flag should also be specified for
144 file systems that are incapable of writing (for example, CDROM). Without this
145 flag, writing is permitted according to individual file accessibility.
149 .ne 2
151 \fB\fBMS_REMOUNT\fR\fR
153 .RS 16n
154 Remount a read-only file system as read-write.
157 .SH RETURN VALUES
160 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
161 returned and \fBerrno\fR is set to indicate the error.
162 .SH ERRORS
165 The \fBmount()\fR function will fail if:
167 .ne 2
169 \fB\fBEACCES\fR\fR
171 .RS 16n
172 The permission bits of the mount point do not permit read/write access or
173 search permission is denied on a component of the path prefix.
175 The calling process is not the owner of the mountpoint.
177 The mountpoint is not a regular file or a directory and the caller does not
178 have all privileges available in a its zone.
180 The special device device does not permit read access in the case of read-only
181 mounts or read-write access in the case of read/write mounts.
185 .ne 2
187 \fB\fBEBUSY\fR\fR
189 .RS 16n
190 The \fIdir\fR argument is currently mounted on, is someone's current working
191 directory, or is otherwise busy; or the device associated with \fIspec\fR is
192 currently mounted.
196 .ne 2
198 \fB\fBEFAULT\fR\fR
200 .RS 16n
201 The \fIspec\fR, \fIdir\fR, \fIfstype\fR, \fIdataptr\fR, or \fIoptptr\fR
202 argument points outside the allocated address space of the process.
206 .ne 2
208 \fB\fBEINVAL\fR\fR
210 .RS 16n
211 The super block has an invalid magic number, the \fIfstype\fR is invalid, or
212 \fIdir\fR is not an absolute path.
216 .ne 2
218 \fB\fBELOOP\fR\fR
220 .RS 16n
221 Too many symbolic links were encountered in translating \fIspec\fR or
222 \fIdir\fR.
226 .ne 2
228 \fB\fBENAMETOOLONG\fR\fR
230 .RS 16n
231 The length of the \fIpath\fR argument exceeds \fIPATH_MAX\fR, or the length of
232 a \fIpath\fR component exceeds \fINAME_MAX\fR while \fB_POSIX_NO_TRUNC\fR is in
233 effect.
237 .ne 2
239 \fB\fBENOENT\fR\fR
241 .RS 16n
242 None of the named files exists or is a null pathname.
246 .ne 2
248 \fB\fBENOLINK\fR\fR
250 .RS 16n
251 The \fIpath\fR argument points to a remote machine and the link to that machine
252 is no longer active.
256 .ne 2
258 \fB\fBENOSPC\fR\fR
260 .RS 16n
261 The file system state in the super-block is not \fBFsOKAY\fR and \fImflag\fR
262 requests write permission.
266 .ne 2
268 \fB\fBENOTBLK\fR\fR
270 .RS 16n
271 The \fIspec\fR argument is not a block special device.
275 .ne 2
277 \fB\fBENOTDIR\fR\fR
279 .RS 16n
280 The \fIdir\fR argument is not a directory, or a component of a path prefix is
281 not a directory.
285 .ne 2
287 \fB\fBENOTSUP\fR\fR
289 .RS 16n
290 A global mount is attempted (the \fBMS_GLOBAL\fR flag is set in \fImflag\fR) on
291 a machine which is not booted as a cluster; a local mount is attempted and
292 \fIdir\fR is within a globally mounted file system; or a remount was attempted
293 on a file system that does not support remounting.
297 .ne 2
299 \fB\fBENXIO\fR\fR
301 .RS 16n
302 The device associated with \fIspec\fR does not exist.
306 .ne 2
308 \fB\fBEOVERFLOW\fR\fR
310 .RS 16n
311 The length of the option string to be returned in the \fIoptptr\fR argument
312 exceeds the size of the buffer specified by \fIoptlen\fR.
316 .ne 2
318 \fB\fBEPERM\fR\fR
320 .RS 16n
321 The {\fBPRIV_SYS_MOUNT\fR} privilege is not asserted in the effective set of
322 the calling process.
326 .ne 2
328 \fB\fBEREMOTE\fR\fR
330 .RS 16n
331 The \fIspec\fR argument is remote and cannot be mounted.
335 .ne 2
337 \fB\fBEROFS\fR\fR
339 .RS 16n
340 The \fIspec\fR argument is write protected and \fImflag\fR requests write
341 permission.
344 .SH USAGE
347 The \fBmount()\fR function can be invoked only by processes with appropriate
348 privileges.
349 .SH SEE ALSO
352 \fBmount\fR(1M), \fBumount\fR(2), \fBmnttab\fR(4)
353 .SH NOTES
356 \fBMS_OPTIONSTR\fR-type option strings should be used.
359 Some flag bits set file system options that can also be passed in an option
360 string. Options are first set from the option string with the last setting of
361 an option in the string determining the value to be set by the option string.
362 Any options controlled by flags are then applied, overriding any value set by
363 the option string.