Computer Science
MOUNT(2) Linux Programmer's Manual MOUNT(2)
NAME
mount, umount - mount and unmount filesystems.
SYNOPSIS
#include <sys/mount.h>
#include <linux/fs.h> /* very unwise */
int mount(const char *specialfile, const char * dir ,
const char * filesystemtype, unsigned long rwflag , const
void * data);
int umount(const char *specialfile);
int umount(const char *dir);
DESCRIPTION
mount attaches the filesystem specified by specialfile
(which is often a device name) to the directory specified
by dir.
umount removes the attachment of the filesystem specified
by specialfile or dir.
Only the super-user may mount and unmount filesystems.
The filesystemtype argument may take one of the values
listed in /proc/filesystems (like "minix", "ext2",
"msdos", "proc", "nfs", "iso9660" etc.).
The rwflag argument has the magic number 0xC0ED in the top
16 bits, and various mount flags (as defined in
<linux/fs.h>) in the low order 16 bits:
#define MS_RDONLY 1 /* mount read-only */
#define MS_NOSUID 2 /* ignore suid and sgid bits */
#define MS_NODEV 4 /* disallow access to device special files */
#define MS_NOEXEC 8 /* disallow program execution */
#define MS_SYNC 16 /* writes are synced at once */
#define MS_REMOUNT 32 /* alter flags of a mounted FS */
#define MS_MGC_VAL 0xC0ED0000
If the magic number is absent, then the last two arguments
are not used.
The data argument is interpreted by the different file
systems.
RETURN VALUE
On success, zero is returned. On error, -1 is returned,
and errno is set appropriately.
ERRORS
The error values given below result from filesystem type
independent errors. Each filesystem type may have its own
special errors and its own special behavior. See the ker-
nel source code for details.
EPERM The user is not the super-user.
ENODEV Filesystemtype not configured in the kernel.
ENOTBLK Specialfile is not a block device (if a device was
required).
EBUSY Specialfile is already mounted. Or, it cannot be
remounted read-only, because it still holds files
open for writing. Or, it cannot be mounted on dir
because dir is still busy (it is the working
directory of some task, the mount point of another
device, has open files, etc.).
EINVAL Specialfile had an invalid superblock. Or, a
remount was attempted, while specialfile was not
already mounted on dir. Or, an umount was
attempted, while dir was not a mount point.
EFAULT One of the pointer arguments points outside the
user address space.
ENOMEM The kernel could not allocate a free page to copy
filenames or data into.
ENAMETOOLONG
A pathname was longer than MAXPATHLEN.
ENOENT A pathname was empty or had a nonexistent compo-
nent.
ENOTDIR The second argument, or a prefix of the first
argument, is not a directory.
EACCES A component of a path was not searchable.
Or, mounting a read-only filesystem was attempted
without giving the MS_RDONLY flag.
Or, the block device Specialfile is located on a
filesystem mounted with the MS_NODEV option.
ENXIO The major number of the block device specialfile
is out of range.
EMFILE (In case no block device is required:) Table of
dummy devices is full.
CONFORMING TO
These functions are Linux-specific and should not be used
in programs intended to be portable.
SEE ALSO
mount(8), umount(8)
Linux 1.1.67 28 Nov 1994 1
Back to the index