MOUNT(T) Linux Programmer's Manual MOUNT(T) NAME mount, umount - mount and unmount filesystems. SYNOPSIS #include <sys/mount.h> int mount(const char *source, const char *target , const char *filesystemtype, unsigned long mountflags , const void *data); int umount(const char *target); DESCRIPTION mount attaches the filesystem specified by source (which is often a device name, but can also be a directory name or a dummy) to the directory specified by target. umount removes the attachment of the (topmost) filesystem mounted on target. 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 mountflags argument may have the magic number 0xC0ED in the top 16 bits, and various mount flags (as defined in <linux/fs.h> for libc4 and libc5 and in <sys/mount.h> for glibc2) 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 /* no access to device special files */ #define MS_NOEXEC 8 /* no program execution */ #define MS_SYNCHRONOUS 16 /* writes are synced at once */ #define MS_REMOUNT 32 /* alter flags of a mounted fs */ #define MS_MANDLOCK 64 /* allow mandatory locks */ #define MS_NOATIME 1024 /* do not update access times */ #define MS_NODIRATIME 2048 /* do not update dir access times */ #define MS_BIND 4096 /* bind subtree elsewhere */ #define MS_MOVE 8192 /* atomically move subtree */ 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 Source is not a block device (and a device was required). EBUSY Source is already mounted. Or, it cannot be remounted read-only, because it still holds files open for writing. Or, it cannot be mounted on tar- get because target is still busy (it is the working directory of some task, the mount point of another device, has open files, etc.). EINVAL Source had an invalid superblock. Or, a remount was attempted, while source was not already mounted on target. Or, a move was attempted, while source was not a mount point, or was '/'. Or, an umount was attempted, while target was not a mount point. ENOTDIR The second argument, or a prefix of the first argu- ment, is not a directory. 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. ELOOP Too many link encountered during pathname resolu- tion. Or, a move was attempted, while target is a descendant of source. 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 Source is located on a filesystem mounted with the MS_NODEV option. ENXIO The major number of the block device source 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. HISTORY The original umount function was called as umount(t) and would return ENOTBLK when called with something other than a block device. In Linux 0.98p4 a call umount(t) was added, in order to support anonymous devices. In Linux 2.3.99-pre7 the call umount(t) was removed, leaving only umount(t) (since now devices can be mounted in more than one place, so specifying the device does not suffice). The original MS_SYNC flag was renamed MS_SYNCHRONOUS in 1.1.69 when a different MS_SYNC was added to <mman.h>. Before Linux 2.4 an attempt to execute a set-UID or set- GID program on a filesystem mounted with MS_NOSUID would fail with EPERM. Since Linux 2.4 the set-UID and set-GID bits are just silently ignored in this case. SEE ALSO mount(t), umount(t) Linux 2.5 2001-12-20 MOUNT(T)