MOUNT(2) 1990 MOUNT(2) NNAAMMEE mount, unmount - mount or remove file system SSYYNNOOPPSSIISS #include <sys/mount.h> mmoouunntt((ttyyppee,, ddiirr,, ffllaaggss,, ddaattaa)) iinntt ttyyppee;; cchhaarr **ddiirr;; iinntt ffllaaggss;; ccaaddddrr__tt ddaattaa;; uunnmmoouunntt((ddiirr,, ffllaaggss)) cchhaarr **ddiirr;; iinntt ffllaaggss;; DDEESSCCRRIIPPTTIIOONN _M_o_u_n_t announces to the system that a file system has been mounted on the directory _d_i_r; following the mount, refer- ences to directory _d_i_r will refer to the root directory on the newly mounted file system. _D_i_r is a pointer to a null- terminated string containing the appropriate path name which must be a directory that already exists. Its old contents are inaccessible while the file system is mounted. The _f_l_a_g argument determines whether certain semantics should be suppressed when accessing the file system: M_RDONLY The file system should be treated as read- only; no writing is allowed (even by the super-user). 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. M_NOEXEC Do not allow files to be executed from the file system. M_NOSUID Do not honor setuid or setgid bits on files when executing them. M_NODEV Do not interpret special files on the file system. M_SYNCHRONOUS All I/O to the file system should be done syn- chronously. The flag M_UPDATE indicates that the mount command is being applied to an already mounted file system. This allows the mount flags to be changed without requiring that the file system be unmounted and remounted. Some file systems may Printed 7/27/90 June 1 MOUNT(2) 1990 MOUNT(2) not allow all flags to be changed. For example, most file systems will not allow a change from read-write to read- only. The _t_y_p_e argument defines the type of the file system. The types of file systems known to the system are defined in _m_o_u_n_t._h. _D_a_t_a is a pointer to a structure that contains the type specific arguments to mount. The currently supported types of file systems and their type specific data are: MOUNT_UFS struct ufs_args { char *fspec; /* Block special file to mount */ int exflags; /* export related flags */ uid_t exroot; /* mapping for root uid */ }; MOUNT_NFS struct nfs_args { struct sockaddr_in *addr; /* file server address */ nfsv2fh_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 0.1 secs */ int retrans; /* times to retry send */ char *hostname; /* server's name */ }; MOUNT_MFS struct mfs_args { char *name; /* name of backing process */ caddr_t base; /* base address of the file system */ u_long size; /* size of the file system */ }; _U_m_o_u_n_t announces to the system that the file system mounted at _d_i_r is no longer to contain that file system. The asso- ciated directory reverts to its ordinary interpretation. The _f_l_a_g_s argument may have the following values: MNT_NOFORCE The unmount should fail if any files are active on the file system. MNT_FORCE The file system should be forcibly unmounted even if files are still active. Active special devices continue to work, but any further accesses to any other active files result in errors even if the file system is later Printed 7/27/90 June 2 MOUNT(2) 1990 MOUNT(2) remounted. RREETTUURRNN VVAALLUUEE _M_o_u_n_t returns 0 if the action occurred, -1 if an error occurred. The mount can fail if _d_i_r does not exist or is not a directory. For a _u_f_s file system, the mount can fail if the special device specified in the ufs_args structure is inaccessible, is not an appropriate file, or is already mounted. A _u_f_s or _m_f_s mount can also fail if there are already too many file systems mounted. _U_m_o_u_n_t returns 0 if the action occurred; -1 if an error occurred. The unmount will fail if there are active files in the mounted file system. EERRRROORRSS _M_o_u_n_t will fail when one of the following occurs: [EPERM] The caller is not the super-user. [ENAMETOOLONG] A component of a pathname exceeded 255 char- acters, or the entire length of a path name exceeded 1023 characters. [ELOOP] Too many symbolic links were encountered in translating a pathname. [ENOENT] A component of _d_i_r does not exist. [ENOTDIR] A component of _n_a_m_e is not a directory, or a path prefix of _s_p_e_c_i_a_l is not a directory. [EINVAL] A pathname contains a character with the high-order bit set. [EBUSY] Another process currently holds a reference to _d_i_r. [EFAULT] _D_i_r points outside the process's allocated address space. The following errors can occur for a _u_f_s file system mount: [ENODEV] A component of ufs_args _f_s_p_e_c does not exist. [ENOTBLK] _F_s_p_e_c is not a block device. [ENXIO] The major device number of _f_s_p_e_c is out of range (this indicates no device driver exists for the associated hardware). [EBUSY] _F_s_p_e_c is already mounted. Printed 7/27/90 June 3 MOUNT(2) 1990 MOUNT(2) [EMFILE] No space remains in the mount table. [EINVAL] The super block for the file system had a bad magic number or an out of range block size. [ENOMEM] Not enough memory was available to read the cylinder group information for the file sys- tem. [EIO] An I/O error occurred while reading the super block or cylinder group information. [EFAULT] _F_s_p_e_c points outside the process's allocated address space. The following errors can occur for a _n_f_s file system mount: [ETIMEDOUT] _N_f_s timed out trying to contact the server. [EFAULT] Some part of the information described by nfs_args points outside the process's allo- cated address space. The following errors can occur for a _m_f_s file system mount: [EMFILE] No space remains in the mount table. [EINVAL] The super block for the file system had a bad magic number or an out of range block size. [ENOMEM] Not enough memory was available to read the cylinder group information for the file sys- tem. [EIO] An paging error occurred while reading the super block or cylinder group information. [EFAULT] _N_a_m_e points outside the process's allocated address space. _U_m_o_u_n_t may fail with one of the following errors: [EPERM] The caller is not the super-user. [ENOTDIR] A component of the path is not a directory. [EINVAL] The pathname contains a character with the high-order bit set. [ENAMETOOLONG] A component of a pathname exceeded 255 char- acters, or an entire path name exceeded 1023 characters. Printed 7/27/90 June 4 MOUNT(2) 1990 MOUNT(2) [ELOOP] Too many symbolic links were encountered in translating the pathname. [EINVAL] The requested directory is not in the mount table. [EBUSY] A process is holding a reference to a file located on the file system. [EIO] An I/O error occurred while writing cached file system information. [EFAULT] _D_i_r points outside the process's allocated address space. SSEEEE AALLSSOO mount(8), umount(8), mfs(8) BBUUGGSS Some of the error codes need translation to more obvious messages. Printed 7/27/90 June 5