MOUNTSection: Linux Programmer's Manual (2)
Return to Main Contents
NAMEmount, umount - mount and unmount filesystems.
int mount(const char *specialfile, const char * dir , const char * filesystemtype, unsigned long mountflags , const void * data);
DESCRIPTIONmount attaches the filesystem specified by specialfile (which is often a device name) to the directory specified by dir.
umount removes the attachment of the (topmost) filesystem mounted on 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 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 */
The data argument is interpreted by the different file systems.
RETURN VALUEOn success, zero is returned. On error, -1 is returned, and errno is set appropriately.
ERRORSThe 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 kernel source code for details.
CONFORMING TOThese functions are Linux-specific and should not be used in programs intended to be portable.
HISTORYThe original umount function was called as umount(device) and would return ENOTBLK when called with something other than a block device. In Linux 0.98p4 a call umount(dir) was added, in order to support anonymous devices. In Linux 2.3.99-pre7 the call umount(device) was removed, leaving only umount(dir) (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>.
SEE ALSOmount(8), umount(8)
This document was created by man2html, using the manual pages.
Time: 19:53:49 GMT, May 23, 2013