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"
8 mount \- mount a file system
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);
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
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)).
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.
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
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.
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.
61 If the caller is not in the global zone, the \fBnodevices\fR option is
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>.
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
87 Prevent programs that are marked set-user-\fBID\fR or set-group-\fBID\fR from
88 executing (see \fBchmod\fR(1)). It also causes \fBopen\fR(2) to return
89 \fBENXIO\fR when attempting to open block or character special files.
95 \fB\fBMS_OPTIONSTR\fR\fR
98 The \fIoptptr\fR and \fIoptlen\fR arguments describe a character buffer at
99 address \fIoptptr\fR of size \fIoptlen\fR. When calling \fBmount()\fR, the
100 character buffer should contain a null-terminated string of options to be
101 passed to the file system-specific code within the operating system. On a
102 successful return, the file system-specific code will return the list of
103 options recognized. Unrecognized options are ignored. The format of the string
104 is a list of option names separated by commas. Options that have values (rather
105 than binary options such as \fBsuid\fR or \fBnosuid\fR), are separated by
106 "\fB=\fR" such as \fBdev=2c4046c\fR. Standard option names are defined in
107 <\fBsys/mntent.h\fR>. Only strings defined in the "C" locale are supported. The
108 maximum length option string that can be passed to or returned from a
109 \fBmount()\fR call is defined by the \fBMAX_MNTOPT_STR\fR constant. The buffer
110 should be long enough to contain more options than were passed in, as the state
111 of any default options that were not passed in the input option string may also
112 be returned in the recognized options list that is returned.
118 \fB\fBMS_OVERLAY\fR\fR
121 Allow the file system to be mounted over an existing file system mounted on
122 \fIdir\fR, making the underlying file system inaccessible. If a mount is
123 attempted on a pre-existing mount point without setting this flag, the mount
130 \fB\fBMS_RDONLY\fR\fR
133 Mount the file system for reading only. This flag should also be specified for
134 file systems that are incapable of writing (for example, CDROM). Without this
135 flag, writing is permitted according to individual file accessibility.
141 \fB\fBMS_REMOUNT\fR\fR
144 Remount a read-only file system as read-write.
150 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
151 returned and \fBerrno\fR is set to indicate the error.
155 The \fBmount()\fR function will fail if:
162 The permission bits of the mount point do not permit read/write access or
163 search permission is denied on a component of the path prefix.
165 The calling process is not the owner of the mountpoint.
167 The mountpoint is not a regular file or a directory and the caller does not
168 have all privileges available in a its zone.
170 The special device device does not permit read access in the case of read-only
171 mounts or read-write access in the case of read/write mounts.
180 The \fIdir\fR argument is currently mounted on, is someone's current working
181 directory, or is otherwise busy; or the device associated with \fIspec\fR is
191 The \fIspec\fR, \fIdir\fR, \fIfstype\fR, \fIdataptr\fR, or \fIoptptr\fR
192 argument points outside the allocated address space of the process.
201 The super block has an invalid magic number, the \fIfstype\fR is invalid, or
202 \fIdir\fR is not an absolute path.
211 Too many symbolic links were encountered in translating \fIspec\fR or
218 \fB\fBENAMETOOLONG\fR\fR
221 The length of the \fIpath\fR argument exceeds \fIPATH_MAX\fR, or the length of
222 a \fIpath\fR component exceeds \fINAME_MAX\fR while \fB_POSIX_NO_TRUNC\fR is in
232 None of the named files exists or is a null pathname.
241 The \fIpath\fR argument points to a remote machine and the link to that machine
251 The file system state in the super-block is not \fBFsOKAY\fR and \fImflag\fR
252 requests write permission.
261 The \fIspec\fR argument is not a block special device.
270 The \fIdir\fR argument is not a directory, or a component of a path prefix is
280 A remount was attempted on a file system that does not support remounting.
289 The device associated with \fIspec\fR does not exist.
295 \fB\fBEOVERFLOW\fR\fR
298 The length of the option string to be returned in the \fIoptptr\fR argument
299 exceeds the size of the buffer specified by \fIoptlen\fR.
308 The {\fBPRIV_SYS_MOUNT\fR} privilege is not asserted in the effective set of
318 The \fIspec\fR argument is remote and cannot be mounted.
327 The \fIspec\fR argument is write protected and \fImflag\fR requests write
334 The \fBmount()\fR function can be invoked only by processes with appropriate
339 \fBmount\fR(8), \fBumount\fR(2), \fBmnttab\fR(4)
343 \fBMS_OPTIONSTR\fR-type option strings should be used.
346 Some flag bits set file system options that can also be passed in an option
347 string. Options are first set from the option string with the last setting of
348 an option in the string determining the value to be set by the option string.
349 Any options controlled by flags are then applied, overriding any value set by