mount()

mount file systems 

Function


SYNOPSIS

#include <unistd.h>

int mount(int char *spec, const char *dir, int mflag...);


DESCRIPTION

mount() requests that a removable file system contained on the block special file identified by spec be mounted on the directory identified by dir. spec and dir 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 low-order bit of mflag controls write permission on the mounted file system: if it is 1, writing is forbidden; otherwise, writing is permitted according to the individual file accessibility.

The mount() function may be invoked only by the super-user. It is intended for use only by the mount utility.


PARAMETERS

spec 

identifies the file system to be mounted at the mount point.

dir 

identifies the directory to be used as the mount point for the mounted file system.

mflag 

is a set of flags that describes which optional arguments are present.


RETURN VALUES

If successful, mount() returns a value of zero. On failure, it returns -1 and sets errno to one of the following values:

EFAULT 

spec or dir is an invalid pointer.

EINVAL 

spec or dir contains an invalid character.

ENAMETOOLONG 

The length of the spec or dir parameter exceeds PATH_MAX or a path name component is longer than NAME_MAX.

ENOTDIR 

spec or dir contains an invalid character.


CONFORMANCE

UNIX 98, with exceptions.


PORTING ISSUES

The value passed in mflag is ignored — read-only mounts are not supported. The mount() and umount() functions do not maintain an /etc/mnttab file. The mount() function and mount command behave in a similar fashion when given the same arguments.

There are 3 different ways in which the NuTCRACKER Platform mount() function can mount a file system. mount() determines the method used based on the paths passed in spec and dir.

  1. The mount() function can be used to mount a network share point and associate it with an unused drive letter. For this type of mount, the spec argument must be the name of the network share point (for example, //hostname/sharepoint, or hostname:/sharepoint). The mount point must be an unused drive letter (for example, t:/). Using mount() to mount a network share is supported for all systems that the NuTCRACKER Platform supports.

    The mount() function can be used to do substitution style mounts. In this instance, the spec argument must indicate an existing directory, and the dir argument must point to an unused drive letter. Using mount() to perform substitution style mounts is only supported on 10/2016/2019/11/2022/2025.

    The mount() function requests that a Windows Volume (a bit like a UNIX block special device in this context), directory, or network share identified by spec be mounted on the directory or drive letter identified by dir. spec and dir are pointers to path names.

  2. The mount() function can be used to mount a volume onto a directory or unused drive letter. If passed an existing drive letter and there is a volume mounted on that drive letter, that volume is then mounted onto the new mount point.

    For example, if //?/Volume{2a537b5c-924e-11d7-a242-806e6f6e6963}/ is mounted on r:/ and q:/ is an unused drive letter:

    mount("//?/Volume{2a537b5c-924e-11d7-a242-806e6f6e6963}/", "q:/", 0);
    

    or

    mount("r:/", "q:/", 0);
    

    mounts the same volume on q:/ as is on r:/.

    The mount point can be any NTFS directory as well as a drive letter:

    mount("//?/Volume{2a537b5c-924e-11d7-a242-806e6f6e6963}/", "c:/mnt/cdrom", 0);
    

    In which case, the specified volume mounted on c:/mnt/cdrom, just like a block special device (for example, like /dev/hda3 on Linux) would be mounted on a directory on UNIX systems. Using mount() to perform this style of mount is only supported on 2016/2019/2022/2025 on local NTFS5 file systems.


SEE ALSO

Commands:
mount, umount

Functions:
umount()


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


PTC MKS Toolkit 10.5 Documentation Build 40.