Standards
Standards / Extensions |
C or C++ |
Dependencies |
z/OS® UNIX |
both |
|
Format
#include <sys/stat.h>
int mount(const char *path, char *filesystem,
char *filesystype, mtm_t mtm,
int parmlen, char *parm);
General description
Adds a file
system to the hierarchical file system (HFS). The same file system
cannot be mounted at more than one place in the hierarchical file
system.
In
order to mount a file system, the caller must be an authorized program,
or must be running for a user with appropriate privileges.
- path
- The mount point directory that the file system is to be mounted
to.
- filesystem
- The name of the file system to be mounted; it must be unique within
the system. For a hierarchical file system (HFS) data set, this is
a 1-to-44-character MVS™ data
set name specified as all uppercase letters.
This name is terminated
with NULL characters.
- filesystype
- The name for the file system that will perform the mount. This
8-character name must match the TYPE operand on a FILESYSTYPE statement
in the BPXPRMxx parmlib member for the file system.
- mtm
- A flag field that specifies the mount mode and additional mount
options:
- MTM_RDONLY
- Mount the file system as a read-only file system.
- MTM_RDWR
- Mount the file system as a read/write file system.
- MTM_NOSUID
- The SETUID and SETGID mode flags will be ignored for programs
that reside in this file system.
- MTM_SYNCHONLY
- The mount must be completed synchronously or fail if it cannot.
- parmlen
- Length of the parm argument. The maximum
length is 500 characters. For a hierarchical file system (HFS) data
set, this is not specified.
- parm
- A parameter passed to the physical file system that performs the
mount. This parameter may not be required. The form and content of
the parm are determined by the physical
file system. A hierarchical file system (HFS) data set does not require
a parm.
Returned value
If successful, mount() returns
0.
If the mount() is proceeding asynchronously, it returns
1.
If unsuccessful, mount() returns -1 and sets errno to one
of the following values:
- Error Code
- Description
- EBUSY
- The specified file system is unavailable.
- EINVAL
- A parameter was incorrectly specified. Verify filesystype and mtm.
Another possible reason for this error is that the mount point is
the root of a file system or that the file system is already mounted.
- EIO
- An I/O error occurred.
- ELOOP
- A loop exists in symbolic links. This error is issued if more
than POSIX_SYMLOOP (defined in the limits.h header file) symbolic
links are detected in the resolution of pathname.
- ENOENT
- The mount point does not exist.
- ENOMEM
- There is not enough storage available to save the information
required for this file system.
- ENOTDIR
- The mount point is not a directory.
- EPERM
- Superuser authority is required to issue a mount.
Example
CELEBM21 ⁄* CELEBM21
This example adds a file system to the hierarchical
file system.
*⁄
#define _OPEN_SYS
#include <sys⁄stat.h>
#include <stdio.h>
#include <unistd.h>
main() {
char mount_point[]="⁄new_fs";
char HFS[]="POSIX.NEW.HFS";
char filesystype[9]="HFS ";
setvbuf(stdout, NULL, _IOLBF, 0);
puts("before mount()");
system("df -Pk");
if (mount(mount_point, HFS, filesystype, MTM_RDWR, 0, NULL) != 0)
perror("mount() error");
else {
puts("After mount()");
system("df -Pk");
if (umount(HFS, MTM_UMOUNT) != 0)
perror("umount() error");
}
}
Output before mount()
Filesystem 1024-blocks Used Available Capacity Mounted on
POSIX.ROOT.FS 9600 8660 940 90% /
After mount()
Filesystem 1024-blocks Used Available Capacity Mounted on
POSIX.NEW.HFS 200 20 180 10% /new_fs
POSIX.ROOT.FS 9600 8660 940 90% /