[ Next Article |
Previous Article |
Book Contents |
Library Home |
Legal |
Search ]
Base Operating System and Extensions Technical Reference, Volume 2
vmount or mount Subroutine
Purpose
Makes a file system available for use.
Library
Standard C Library (libc.a)
Syntax
#include <sys/vmount.h>
int vmount (VMount, Size)
struct vmount *VMount;
int Size;
int mount
(Device, Path, Flags)
char *Device;
char *Path;
int Flags;
Description
The vmount subroutine mounts a file
system, thereby making the file available for use. The vmount subroutine
effectively creates what is known as a virtual file system. After a file
system is mounted, references to the path name that is to be mounted over refer to
the root directory on the mounted file system.
A directory can only be mounted over a directory,
and a file can only be mounted over a file.
(The file or directory may be a symbolic link.)
Therefore, the vmount subroutine can
provide the following types of mounts:
- A local file over a local or remote file
- A local directory over a local or remote directory
- A remote file over a local or remote file
- A remote directory over a local or remote
directory.
A mount to a directory or a file can be issued if the calling process has root
user authority or is in the system group and has write access to the mount point.
To mount a block device, remote file, or remote
directory, the calling process must also have root user authority.
The mount subroutine only allows mounts of
a block device over a local directory with the default file system type. The
mount subroutine searches the /etc/filesystems file to find a
corresponding stanza for the desired file system.
Note: The mount subroutine
interface is provided only for compatibility with previous releases of the
operating system. The use of the mount subroutine is strongly discouraged by
normal application programs.
If the directory you are trying to mount over has
the sticky bit set to on, you must either own that directory or be the root user
for the mount to succeed. This restriction applies only to directory-over-directory
mounts.
Parameters
Device |
A path name identifying the block device (also called a special file)
that contains the physical file system. |
Path |
A path name identifying the directory on which the file system is to be
mounted. |
Flags |
Values that define characteristics of the object to be mounted.
Currently these values are defined in the /usr/include/sys/vmount.h file:
MNT_READONLY |
Indicates that the object to be mounted is read-only and that write
access is not allowed. If this value is not specified, writing is permitted
according to individual file accessibility. |
MNT_NOSUID |
Indicates that setuid and setgid programs referenced
through the mount should not be executable. If this value is not specified,
setuid and setgid programs referenced through the mount may be
executable. |
MNT_NODEV |
Indicates that opens of device special files referenced through the
mount should not succeed. If this value is not specified, opens of device special
files referenced through the mount may succeed. |
|
VMount |
A pointer to a variable-length vmount structure. This structure
is defined in the sys/vmount.h file.
The following fields of the VMount
parameter must be initialized before the call to the vmount subroutine:
vmt_revision |
The revision code in effect when the program that created this virtual
file system was compiled. This is the value VMT_REVISION. |
vmt_length |
The total length of the structure with all its data. This must be a
multiple of the word size (4 bytes) and correspond with the Size
parameter. |
vmt_flags |
Contains the general mount characteristics. The following value may be
specified:
MNT_READONLY |
A read-only virtual file system is to be created. |
|
vmt_gfstype |
The type of the generic file system underlying the VMT_OBJECT.
Values for this field are defined in the sys/vmount.h file and include:
MNT_JFS |
Indicates the native file system. |
MNT_NFS |
Indicates a Network File System client. |
MNT_CDROM |
Indicates a CD-ROM file system. |
|
vmt_data |
An array of structures that describe variable length data associated
with the vmount structure. The structure consists of the following fields:
vmt_off |
The offset of the data from the beginning of the vmount
structure. |
|
vmt_size |
The size, in bytes, of the data.
The array consists of the following fields:
vmt_data[VMT_OBJECT] |
Specifies he name of the device, directory, or file to be mounted. |
vmt_data[VMT_STUB] |
Specifies the name of the device, directory, or file to be mounted over. |
vmt_data[VMT_HOST] |
Specifies the short (binary) name of the host that owns the mounted object. This
need not be specified if VMT_OBJECT is local (that is, it has the same
vmt_gfstype as / (root), the root of all file systems). |
vmt_data[VMT_HOSTNAME] |
Specifies the long (character) name of the host that owns the mounted object. This
need not be specified if VMT_OBJECT is local. |
vmt_data[VMT_INFO] |
Specifies binary information to be passed to the generic file-system implementation
that supports VMT_OBJECT. The interpretation of this field is specific to
the gfs_type. |
vmt_data[VMT_ARGS] |
Specifies a character string representation of VMT_INFO. |
|
On return from the vmount subroutine, the
following additional fields of the VMount parameter are initialized:
vmt_fsid |
Specifies the two-word file system identifier; the interpretation of
this identifier depends on the gfs_type. |
vmt_vfsnumber |
Specifies the unique identifier of the virtual file system. Virtual file
systems do not survive the IPL; neither does this identifier. |
vmt_time |
Specifies the time at which the virtual file system was created. |
|
Size |
Specifies the size, in bytes, of the supplied data area. |
Return Values
Upon successful completion, a value of 0 is
returned. Otherwise, a value of -1 is returned, and the errno global
variable is set to indicate the error.
Error Codes
The mount and vmount subroutines fail and the virtual file system is not created if any of the
following is true:
EACCES |
The calling process does not have write permission on the stub directory
(the directory to be mounted over). |
EBUSY |
VMT_OBJECT specifies a device that is already mounted or an
object that is open for writing, or the kernel's mount table is full. |
EFAULT |
The VMount parameter points to a location outside of the
allocated address space of the process. |
EFBIG |
The size of the file system is too big. |
EFORMAT |
An internal inconsistency has been detected in the file system. |
EINVAL |
The contents of the VMount parameter are unintelligible (for
example, the vmt_gfstype is unrecognizable, or the file system
implementation does not understand the VMT_INFO provided). |
ENOSYS |
The file system type requested has not been configured. |
ENOTBLK |
The object to be mounted is not a file, directory, or device. |
ENOTDIR |
The types of VMT_OBJECT and VMT_STUB are
incompatible. |
EPERM |
VMT_OBJECT specifies a block device, and the calling process does
not have root user authority. |
EROFS |
An attempt has been made to mount a file system for read/write when the
file system cannot support writing. |
The mount and vmount subroutines can
also fail if additional
errors
occur.
Implementation Specifics
These subroutines are part of Base Operating
System (BOS) Runtime.
Related Information
The mntctl subroutine, umount subroutine.
The mount command, umount command.
Files, Directories,
and File Systems for Programmers in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.
Understanding Mount Helpers in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs
explains and examines the execution syntax of mount helpers.
[ Next Article |
Previous Article |
Book Contents |
Library Home |
Legal |
Search ]