[Previous]
[Contents]
[Next]

mount()

mount a file system

Synopsis:

#include <unistd.h>
#include <sys/fsys.h>
int mount( const char *special,
           const char *dir,
           int rwflag );

Description:

The mount() function requests that the file system contained on the block special file identified by special be mounted on the directory specified by dir. If rwflag is 1, then writing is forbidden (the file system is mounted as a read-only file system); otherwise writing is permitted according to individual file accessibility.


Note: If the path named by dir exists, it must resolve to a directory, and the calling program must have write access to that directory.

Returns:

0
Success
-1
An error occurred. errno is set to indicate the error.

Errors:

EAGAIN
The mount table is full.
EBUSY
The block special file named by special is already mounted, or the directory named by dir exists as a prefix in the prefix table.
EEXIST
The directory named by dir is already a mount point.
EINVAL
The pathname named by dir doesn't start with '/', or it contains characters that aren't allowed to exist in pathnames.
ENAMETOOLONG
The pathname named by dir is longer than _MOUNT_PATH_MAX (see <sys/fsys.h>).
ENOENT
The block special file named by special doesn't exist.
ENOTBLK
The file named by special isn't a block special file.
ENOTDIR
The path named by dir exists, but not as a directory.
EPERM
The directory named by dir exists, but write access is denied, or the effective user ID of the caller doesn't match the user ID of the named block special file, or the caller isn't user ID 0 (that is, root).

Examples:

/*
 * mount the floppy as a read-only file system
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void main()
  {
    if( mount( "/dev/fd0", "/floppy0", 1 ) != 0 ) {
      perror( "mount /dev/fd0" );
      exit( EXIT_FAILURE );
    }
    exit( EXIT_SUCCESS );
  }

Classification:

UNIX

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, umount()


[Previous]
[Contents]
[Next]