MOUNT(2)

NAME
mount - mount file system

SYNOPSIS
#include <sys/mount.h>

mount(type, dir, flags, data)
int type;
char *dir;
int flags;
caddr_t data;

DESCRIPTION
Mount attaches a file system to a directory. After a successful return, references to directory dir refer to the root directory on the newly mounted file system. Dir is a pointer to a null-terminated string containing a path name. Dir must exist already, and must be a directory. Its old contents are inaccessible while the file system is mounted.

The flags argument determines whether the file system can be written on, and if set-uid execution is allowed. Physically write-protected and magnetic tape file systems must be mounted read-only or errors will occur when access times are updated, whether or not any explicit write is attempted.

Type indicates the type of the filesystem. It must be one of the types defined in mount.h. Data is a pointer to a structure which contains the type specific arguments to mount. The following is a list of the filesystem types supported and the type specific arguments to each:

MOUNT_UFS struct ufs_args {
    char *fspec;    /* Block special file to mount */
}; MOUNT_NFS #include <nfs/nfs.h> #include <netinet/in.h> struct nfs_args {
    struct sockaddr_in    *addr;    /* file server address */
    fhandle_t    *fh;    /* File handle to be mounted */
    int    flags;    /* flags */
    int    wsize;    /* write size in bytes */
    int    rsize;    /* read size in bytes */
    int    timeo;    /* initial timeout in .1 secs */
    int    retrans;    /* times to retry send */
};

RETURN VALUE
Mount returns 0 if the action occurred; otherwise, it returns an error.

ERRORS
Mount fails when one of the following occurs:

[EACCES]
    Search permission is denied for a component of the path prefix of fspec or dir.

[EBUSY]
    Dir is not a directory, or another process currently holds a reference to it.

[EBUSY]
    No space remains in the mount table, or the device is already mounted in the mount table.

[EFAULT]
    Either addr, data, dir, fh, or fspec points outside the process's allocated address space.

[EINVAL]
    The super block for the file system had a bad magic number or an out of range block size.

[EINVAL]
    Either timeo, rsize, or wsize is less than or equal to zero, or retrans is less than zero.

[EIO]
    An I/O error occurred while reading the super block or cylinder group information.

[EIO]
    An I/O error occurred while reading from or writing to the file system.

[ELOOP]
    Too many symbolic links were encountered in translating the pathname of fspec or dir.

[ENAMETOOLONG]
    The pathname of fspec or dir was too long.

[ENODEV]
    Type is not a valid filesystem type.

[ENOENT]
    Either fspec or dir does not exist.

[ENOSPC]
    The filesystem is not marked as clean and flags specifies that the filesystem is to be mounted as writable.

[ENOTBLK]
    Fspec is not a block device.

[ENOTDIR]
    A component of the path prefix in fspec is not a directory.

[ENOTDIR]
    Dir is not a directory.

[ENXIO]
    The major device number of fspec is out of range (this indicates no device driver exists for the associated hardware).

[ENXIO]
    The attempt to open fspec failed.

[EPERM]
    The caller is not the super-user.

[EPERM]
    The pathname of either fspec or dir contains a character with the high-order bit set.

[EPFNOSUPPORT]
    The protocol family specified by addr->sin_family is not AF_INET.

SEE ALSO
unmount(2), mount(8)