xref: /netbsd/lib/libc/sys/mount.2 (revision bf9ec67e)
1.\"	$NetBSD: mount.2,v 1.26 2002/02/08 01:28:19 ross Exp $
2.\"
3.\" Copyright (c) 1980, 1989, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)mount.2	8.3 (Berkeley) 5/24/95
35.\"
36.Dd November 7, 1999
37.Dt MOUNT 2
38.Os
39.Sh NAME
40.Nm mount ,
41.Nm unmount
42.Nd mount or dismount a file system
43.Sh LIBRARY
44.Lb libc
45.Sh SYNOPSIS
46.Fd #include \*[Lt]sys/param.h\*[Gt]
47.Fd #include \*[Lt]sys/mount.h\*[Gt]
48.Ft int
49.Fn mount "const char *type" "const char *dir" "int flags" "void *data"
50.Ft int
51.Fn unmount "const char *dir" "int flags"
52.Sh DESCRIPTION
53The
54.Fn mount
55function grafts
56a file system object onto the system file tree
57at the point
58.Ar dir .
59The argument
60.Ar data
61describes the file system object to be mounted.
62The argument
63.Ar type
64tells the kernel how to interpret
65.Ar data
66(See
67.Ar type
68below).
69The contents of the file system
70become available through the new mount point
71.Ar dir .
72Any files in
73.Ar dir
74at the time
75of a successful mount are swept under the carpet so to speak, and
76are unavailable until the file system is unmounted.
77.Pp
78The following
79.Ar flags
80may be specified to
81suppress default semantics which affect file system access.
82.Bl -tag -width MNT_SYNCHRONOUS
83.It Dv MNT_RDONLY
84The file system should be treated as read-only;
85Even the super-user may not write on it.
86.It Dv MNT_NOEXEC
87Do not allow files to be executed from the file system.
88.It Dv MNT_NOSUID
89Do not honor setuid or setgid bits on files when executing them.
90.It Dv MNT_NODEV
91Do not interpret special files on the file system.
92.It Dv MNT_UNION
93Union with underlying filesystem instead of obscuring it.
94.It Dv MNT_SYNCHRONOUS
95All I/O to the file system should be done synchronously.
96.It Dv MNT_ASYNC
97All I/O to the file system should be done asynchronously.
98.It Dv MNT_NOCOREDUMP
99Do not allow programs to dump core files on the file system.
100.It Dv MNT_NOATIME
101Never update access time in the file system.
102.It Dv MNT_SYMPERM
103Recognize the permission of symbolic link when reading or traversing.
104.It Dv MNT_NODEVMTIME
105Never update modification time of device files.
106.It Dv MNT_SOFTDEP
107Use soft dependencies.
108.El
109.Pp
110The flag
111.Dv MNT_UPDATE
112indicates that the mount command is being applied
113to an already mounted file system.
114This allows the mount flags to be changed without requiring
115that the file system be unmounted and remounted.
116Some file systems may not allow all flags to be changed.
117For example,
118most file systems will not allow a change from read-write to read-only.
119.Pp
120The
121.Fa type
122argument defines the type of the file system.
123The types of file systems known to the system are defined in
124.Aq Pa sys/mount.h .
125.\" XXX from lite-2:
126.\" The types of filesystems known to the system can be obtained with
127.\" .Xr sysctl 8
128.\" by using the command:
129.\" .Bd -literal -offset indent
130.\" sysctl vfs
131.\" .Ed
132.\" .Pp
133.Fa data
134is a pointer to a structure that contains the type
135specific arguments to mount.
136The currently supported types of file systems and
137their type specific data are:
138.Pp
139.Dv MOUNT_FFS
140.Bd -literal -offset indent -compact
141struct ufs_args {
142      char      *fspec;             /* block special file to mount */
143      struct    export_args export; /* network export information */
144};
145.Ed
146.Pp
147.Dv MOUNT_NFS
148.Bd -literal -offset indent -compact
149struct nfs_args {
150      int             version;      /* args structure version */
151      struct sockaddr *addr;        /* file server address */
152      int             addrlen;      /* length of address */
153      int             sotype;       /* Socket type */
154      int             proto;        /* and Protocol */
155      u_char          *fh;          /* File handle to be mounted */
156      int             fhsize;       /* Size, in bytes, of fh */
157      int             flags;        /* flags */
158      int             wsize;        /* write size in bytes */
159      int             rsize;        /* read size in bytes */
160      int             readdirsize;  /* readdir size in bytes */
161      int             timeo;        /* initial timeout in .1 secs */
162      int             retrans;      /* times to retry send */
163      int             maxgrouplist; /* Max. size of group list */
164      int             readahead;    /* # of blocks to readahead */
165      int             leaseterm;    /* Term (sec) of lease */
166      int             deadthresh;   /* Retrans threshold */
167      char            *hostname;    /* server's name */
168};
169.Ed
170.Pp
171.Dv MOUNT_MFS
172.Bd -literal -offset indent -compact
173struct mfs_args {
174      char	*fspec;             /* name to export for statfs */
175      struct	export_args export; /* if we can export an MFS */
176      caddr_t	base;               /* base of file system in mem */
177      u_long	size;               /* size of file system */
178};
179.Ed
180.\" XXX from lite-2:
181.\" The format for these argument structures is described in the
182.\" manual page for each filesystem.
183.\" By convention filesystem manual pages are named
184.\" by prefixing ``mount_'' to the name of the filesystem as returned by
185.\" .Xr sysctl 8 .
186.\" Thus the
187.\" .Nm NFS
188.\" filesystem is described by the
189.\" .Xr mount_nfs 8
190.\" manual page.
191.Pp
192The
193.Fn unmount
194function call disassociates the file system from the specified
195mount point
196.Fa dir .
197.Pp
198The
199.Fa flags
200argument may specify
201.Dv MNT_FORCE
202to specify that the file system should be forcibly unmounted even if files are
203still active.
204Active special devices continue to work,
205but any further accesses to any other active files result in errors
206even if the file system is later remounted.
207.Sh RETURN VALUES
208.Fn mount
209returns the value 0 if the mount was successful, otherwise -1 is returned
210and the variable
211.Va errno
212is set to indicate the error.
213.Pp
214.Fn unmount
215returns the value 0 if the unmount succeeded; otherwise -1 is returned
216and the variable
217.Va errno
218is set to indicate the error.
219.Sh ERRORS
220.Fn mount
221will fail when one of the following occurs:
222.Bl -tag -width Er
223.It Bq Er EPERM
224The caller is not the super-user.
225.It Bq Er ENAMETOOLONG
226A component of a pathname exceeded
227.Dv {NAME_MAX}
228characters, or an entire path name exceeded
229.Dv {PATH_MAX}
230characters.
231.It Bq Er ELOOP
232Too many symbolic links were encountered in translating a pathname.
233.It Bq Er ENOENT
234A component of
235.Fa dir
236does not exist.
237.It Bq Er ENOTDIR
238A component of
239.Ar name
240is not a directory,
241or a path prefix of
242.Ar special
243is not a directory.
244.It Bq Er EBUSY
245Another process currently holds a reference to
246.Fa dir .
247.It Bq Er EFAULT
248.Fa dir
249points outside the process's allocated address space.
250.El
251.Pp
252The following errors can occur for a
253.Em ufs
254file system mount:
255.Bl -tag -width Er
256.It Bq Er ENODEV
257A component of ufs_args
258.Ar fspec
259does not exist.
260.It Bq Er ENOTBLK
261.Ar Fspec
262is not a block device.
263.It Bq Er ENXIO
264The major device number of
265.Ar fspec
266is out of range (this indicates no device driver exists
267for the associated hardware).
268.It Bq Er EBUSY
269.Ar Fspec
270is already mounted.
271.It Bq Er EMFILE
272No space remains in the mount table.
273.It Bq Er EINVAL
274The super block for the file system had a bad magic
275number or an out of range block size.
276.It Bq Er ENOMEM
277Not enough memory was available to read the cylinder
278group information for the file system.
279.It Bq Er EIO
280An I/O error occurred while reading the super block or
281cylinder group information.
282.It Bq Er EFAULT
283.Ar Fspec
284points outside the process's allocated address space.
285.El
286.Pp
287The following errors can occur for a
288.Em nfs
289file system mount:
290.Bl -tag -width Er
291.It Bq Er ETIMEDOUT
292.Em Nfs
293timed out trying to contact the server.
294.It Bq Er EFAULT
295Some part of the information described by nfs_args
296points outside the process's allocated address space.
297.El
298.Pp
299The following errors can occur for a
300.Em mfs
301file system mount:
302.Bl -tag -width Er
303.It Bq Er EMFILE
304No space remains in the mount table.
305.It Bq Er EINVAL
306The super block for the file system had a bad magic
307number or an out of range block size.
308.It Bq Er ENOMEM
309Not enough memory was available to read the cylinder
310group information for the file system.
311.It Bq Er EIO
312A paging error occurred while reading the super block or
313cylinder group information.
314.It Bq Er EFAULT
315.Em Name
316points outside the process's allocated address space.
317.El
318.Pp
319.Fn unmount
320may fail with one of the following errors:
321.Bl -tag -width Er
322.It Bq Er EPERM
323The caller is not the super-user.
324.It Bq Er ENOTDIR
325A component of the path is not a directory.
326.It Bq Er ENAMETOOLONG
327A component of a pathname exceeded
328.Dv {NAME_MAX}
329characters, or an entire path name exceeded
330.Dv {PATH_MAX}
331characters.
332.It Bq Er ELOOP
333Too many symbolic links were encountered in translating the pathname.
334.It Bq Er EINVAL
335The requested directory is not in the mount table.
336.It Bq Er EBUSY
337A process is holding a reference to a file located
338on the file system.
339.It Bq Er EIO
340An I/O error occurred while writing cached file system information.
341.It Bq Er EFAULT
342.Fa dir
343points outside the process's allocated address space.
344.El
345.Pp
346A
347.Em ufs
348or
349.Em mfs
350mount can also fail if the maximum number of file systems are currently
351mounted.
352.Sh SEE ALSO
353.Xr getfsstat 2 ,
354.Xr getmntinfo 3 ,
355.Xr symlink 7 ,
356.Xr mount 8 ,
357.Xr sysctl 8 ,
358.Xr umount 8
359.Sh HISTORY
360The
361.Fn mount
362and
363.Fn umount
364(now
365.Fn unmount )
366function calls appeared in
367.At v6 .
368.Sh BUGS
369Some of the error codes need translation to more obvious messages.
370