NAME
vfsmount — mount a file system
SYNOPSIS
#include <sys/mount.h>
int vfsmount(int type,
const char *dir,
int flags,
caddr_t data);
Remarks
This routine is included only for compatibility with past releases.
It works only with UFS (HFS), NFS, and CDFS file systems.
For maximum portability and improved functionality,
new applications should use the
mount()
system call (see
mount(2)).
DESCRIPTION
The
vfsmount()
system call attaches a file system to a directory.
After a successful return, references to directory
dir
refer to the root directory of the newly mounted file system.
dir
is a pointer to a null-terminated string containing a path name.
dir
must exist already, and must be a directory.
Its old contents are inaccessible while the file system is mounted.
type
indicates the type of the file system.
It must be one of the types described below.
vfsmount()
does not check that the file system is actually of type
type;
if
type
is incorrect,
vfsmount()
may cause the process to hang.
To prevent such problems,
statfsdev()
(see
statfsdev(3C))
should be called before
vfsmount()
to check the file system type, which
statfsdev()
places in the
f_fsid[1]
field of the
statfs
structure that it returns.
The
flags
argument determines whether the file system can be written to.
It also controls whether programs from the mounted file system
are allowed to have set-user-ID execution.
Physically write-protected and magnetic tape file systems
must be mounted read-only.
Failure to do so results in a return of -1 by
vfsmount()
and a value of [EIO] in
errno.
The following values for the
flags
argument are defined in
<sys/mount.h>:
- M_RDONLY
Mount done as read-only.
- M_NOSUID
Execution of set-user-ID programs not permitted.
data
is a pointer to a structure containing arguments
specific to the value contained in
type.
The following values for
type
are defined in
<sys/mount.h>:
- MOUNT_CDFS
Mount a local CD-ROM file system.
data
points to a structure of the following format:
struct cdfs_args {
char *fspec;
};
fspec
points to the name of the block special file that is to be mounted.
- MOUNT_UFS
Mount a local HFS file system.
data
points to a structure of the following format:
struct ufs_args {
char *fspec;
int flags;
};
fspec
points to the name of the block special file that is to be mounted.
This is identical in use and function to the first argument of
mount()
(see
mount(2)).
flags
points to a bit map that sets options.
The following values of the bits are defined in
<sys/mount.h>:
- MS_DELAY
Specify that the writes to disks are to be delayed till the buffer
needs to be reused.
This is the default.
- MS_BEHIND
Specify that the writes to disks are to be done asynchronously,
where possible, without waiting for completion.
MS_BEHIND
and
MS_DELAY
are mutually exclusive.
- MS_NO_FSASYNC
Specify that rigorous posting of file system metadata is to be used.
This is the default.
- MS_FSASYNC
Specify that relaxed posting of file system metadata is to be used.
This may lead to better performance for certain applications; but
there is increased potential for data loss in case of a crash.
MS_FSASYNC
and
MS_NO_FSASYNC
are mutually exclusive.
Notes
The
MOUNT_NFS
type is no longer supported through this interface.
RETURN VALUE
vfsmount()
returns the following values:
- 0
Successful completion.
- -1
Failure.
No file system is mounted.
errno
is set to indicate the error.
ERRORS
If
vfsmount()
fails,
errno
is set to one of the following values.
- EBUSY
dir
is not a directory, or another process currently
holds a reference to it.
- EBUSY
No space remains in the mount table.
- EBUSY
The superblock for the file system had a bad magic number
or an out-of-range block size.
- EBUSY
Not enough memory was available to read the cylinder group information
for the file system.
- EFAULT
data
or
dir
points outside the allocated address space of the process.
- EINVAL
type
is not
MOUNT_UFS,
or
MOUNT_CDFS.
- EIO
An I/O error occurred while reading from or writing to the file system.
- EIO
An attempt was made to mount a physically write protected
or magnetic tape file system as read-write.
- ELOOP
Too many symbolic links were encountered while translating
the path name of file system referred to by
data
or
dir.
- ENAMETOOLONG
The path name of the file system referred to by
data
or
dir
is longer than
PATH_MAX
bytes, or the length of a component of the path name exceeds
NAME_MAX
bytes while
_POSIX_NO_TRUNC
is in effect.
- ENOENT
The file system referred to by
data
or
dir
does not exist.
- ENOENT
The file system referred to by
data
does not exist.
- ENOTBLK
The file system referred to by
data
is not a block device.
This message can occur only during a local mount.
- ENOTDIR
A component of the path prefix in
dir
is not a directory.
- ENOTDIR
A component of the path prefix of the file system referred to by
data
or
dir
is not a directory.
- ENXIO
The major device number of the file system referred to by
data
is out of range
(indicating that no device driver exists for the associated hardware).
- EPERM
The caller does not have
appropriate privileges.
DEPENDENCIES
NFS
If
vfsmount()
fails,
errno
can also be set to one of the following values.
- EFAULT
A pointer in the
data
structure points outside the process's allocated address space.
- EINVAL
A value in a field of
data
is out of proper range.
See
mountd(1M),
getfh(2),
and
inet(7F)
for more information.
WARNINGS
The
mount
command (see
mount(1M))
is preferred over
vfsmount()
because
mount
supports all mounting options that are available from
vfsmount()
directly, plus
mount
also maintains the
/etc/mnttab
file which lists what file systems are mounted.
Obsolescent Interfaces
vfsmount()
is to be obsoleted at a future date.
AUTHOR
vfsmount()
was developed by HP and Sun Microsystems, Inc.