NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | SEE ALSO
#include <sys/types.h> #include <sys/mount.h>int mount(const char *spec, const char *dir, int mflag, /* char *fstype, const char *dataptr, int datalen */ ...);
The mount() function requests that a removable file system contained on the block special file identified by spec be mounted on the directory identified by dir. The spec and dir arguments are pointers to path names. The fstype argument is the file system type, which can be determined by the sysfs(2) function. If both the MS_DATA and MS_FSS flag bits of mflag are off, the file system type defaults to the root file system type. Only if either flag is on is fstype used to indicate the file system type.
If the MS_DATA flag is set in mflag, the system expects the dataptr and datalen arguments to be present. Together they describe a block of file system-specific data at address dataptr of length datalen. This is interpreted by file system-specific code within the operating system and its format depends on the file system type. If a particular file system type does not require this data, dataptr and datalen should both be zero. Note that MS_FSS is obsolete and is ignored if MS_DATA is also set, but if MS_FSS is set and MS_DATA is not, dataptr and datalen are both assumed to be 0.
After a successful call to mount(), all references to the file dir refer to the root directory on the mounted file system.
The low-order bit of mflag is used to control write permission on the mounted file system: if 1, writing is forbidden; otherwise writing is permitted according to individual file accessibility.
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.
The mount() function will fail if:
The dir argument is currently mounted on, is someone's current working directory, or is otherwise busy; the device associated with spec is currently mounted; or there are no more mount table entries.
The spec, dir, or datalen argument points outside the allocated address space of the process.
The super block has an invalid magic number or the fstype is invalid.
Too many symbolic links were encountered in translating spec or dir.
The length of the path argument exceeds PATH_MAX, or the length of a path component exceeds NAME_MAX while _POSIX_NO_TRUNC is in effect.
None of the named files exists or is a null pathname.
The path argument points to a remote machine and the link to that machine is no longer active.
The file system state in the super-block is not FsOKAY and mflag requests write permission.
The spec argument is not a block special device.
The dir argument is not a directory, or a component of a path prefix is not a directory.
The device associated with spec does not exist.
The effective user ID is not super-user.
The spec argument is remote and cannot be mounted.
The spec argument is write protected and mflag requests write permission.
The mount() function can be invoked only by processes with super-user privileges.
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | SEE ALSO