[Previous]
[Contents]
[Next]

umount()

unmount a previously mounted file system or partition

Synopsis:

#include <unistd.h>
int umount( const char *special );

Description:

The umount() function requests that a previously mounted file system or previously mounted partitions contained on the block special file identified by special be unmounted. After unmounting the file system, the directory on which it was mounted (if any) reverts to its ordinary meaning.

The umount() function won't return until all dirty blocks are written to the disk. This action is similar to the sync() function with the exception that umount() blocks while waiting for the operation to be completed.

Returns:

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

Errors:

EBUSY
There are open files on the mounted filesystem.
EINVAL
The named block special file isn't mounted.
ENOENT
The named block special file doesn't exist.
ENOTBLK
The file named by special isn't a block special file.
EPERM
The process's effective user ID doesn't match the owner of the block special file, or the process's effective user ID isn't user ID 0 (that is, root)

Examples:

/*
 * Unmount the filesystem that's on the floppy
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void main()
{
    if( umount( "/dev/fd0" ) != 0 ) {
      perror( "umount /dev/fd0" );
      exit( EXIT_FAILURE );
    }

    exit( EXIT_SUCCESS );
}

Classification:

UNIX

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

errno, mount(), qnx_sync(), sync()


[Previous]
[Contents]
[Next]