Contained WithinFind More DocumentationFeatured Support Resources | Download this book in PDF (1785 KB)
mount(2)Name | Synopsis | Description | Return Values | Errors | Usage | See Also | Notes Name
Synopsis#include <sys/types.h>
#include <sys/mount.h>
#include <sys/mntent.h>
int mount(const char *spec, const char *dir, int mflag,
char *fstype, char *dataptr,int datalen, char *optptr,
int optlen);
Description
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. After a successful call to mount(), all references to the file dir refer to the root directory on the mounted file system. The mounted file system is inserted into the kernel list of all mounted file systems. This list can be examined through the mounted file system table (see mnttab(4)). The fstype argument is the file system type name. Standard file system names are defined with the prefix MNTTYPE_ in <sys/mntent.h>. If neither MS_DATA nor MS_OPTIONSTR is set in mflag, then fstype is ignored and the type of the root file system is assumed. The dataptr argument is 0 if no file system-specific data is to be passed; otherwise it points to an area of size datalen that contains the file system-specific data for this mount and the MS_DATA flag should be set. If the MS_OPTIONSTR flag is set, then optptr points to a buffer containing the list of options to be used for this mount. The optlen argument specifies the length of the buffer. On completion of the mount() call, the options in effect for the mounted file system are returned in this buffer. If MS_OPTIONSTR is not specified, then the options for this mount will not appear in the mounted file systems table. If the caller does not have all privileges available in the current zone, the nosuid option is automatically set on the mount point. The restrict option is automatically added for autofs mounts. If the caller is not in the global zone, the nodevices option is automatically set. The mflag argument is constructed by a bitwise-inclusive-OR of flags from the following list, defined in <sys/mount.h>. Return ValuesUpon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. Errors
The mount() function will fail if: UsageThe mount() function can be invoked only by processes with appropriate privileges. See AlsoNotesMS_OPTIONSTR-type option strings should be used. Some flag bits set file system options that can also be passed in an option string. Options are first set from the option string with the last setting of an option in the string determining the value to be set by the option string. Any options controlled by flags are then applied, overriding any value set by the option string. Name | Synopsis | Description | Return Values | Errors | Usage | See Also | Notes |