Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
#define _OPEN_SYS
#include <sys/mntent.h>
int w_getmntent(char *buffer, int size);
Gets information about all currently mounted file systems.
Three mapping formats available. Their corresponding headers are:
Header | Eye Catcher | Entry | |
---|---|---|---|
struct mnte3 | MNTE3H (struct mnte3h) | MNTE3H_ID ("MNT3") | W_MNTENT3 (struct w_mntent3) |
struct mnte2 | MNTE2H (struct mnte2h) | MNTE2H_ID ("MNT2") | W_MNTENT2 (struct w_mntent2) |
struct mnte | W_MNTH (struct w_mnth) | "MNTE" | W_MNTENT (struct w_mntent) |
The buffer should be set to zero prior to setting of fields or the w_getmntent() call. The default mapping format is struct mnte when the eyecatcher field is unset.
Using structure w_mntent3: Prior to calling w_getmntent() with the w_mntent3 structure mapping, set the following fields in MNTE3H:
In the header, the field mnt3H_cblen returns the number of bytes of data put in the buffer. The field mh3_cursor contains positioning information that w_getmntent() uses to store the information. If multiple calls are made, use the same buffer because the positioning information in mh3_cursor indicates where the function should continue with its list. The positioning information should not be changed between calls.
The mount mode of the file system. A flag field that specifies the mount mode and additional mount options: mntentfsaunmount.
If all entries do not fit in the buffer supplied, multiple calls are required. If an entry together with its mount parameter will not fit in the buffer, the entry is returned without the mount parameter. In this case, mnt3_parmlen contains the length of the mount parameter, and mnt3_parmoffset is zero.
To assure that at least one entry, including the mount parameter, is returned, it is advisable to allocate space for at least two entries.
When the final entry has been placed in the buffer, w_getmntent() returns no entries.
In the header, the field mnt2h_cblen returns the number of bytes of data put in the buffer. The field mh2_cursor contains positioning information that w_getmntent() uses to store the information. If multiple calls are made, use the same buffer because the positioning information in mh2_cursor indicates where the function should continue with its list. The positioning information should not be changed between calls.
The mount mode of the file system. A flag field that specifies the mount mode and additional mount options:
If all entries do not fit in the buffer supplied, multiple calls are required. If an entry together with its mount parameter will not fit in the buffer, the entry is returned without the mount parameter. In this case, mnt2_parmlen contains the length of the mount parameter, and mnt2_parmoffset is zero.
To assure that at least one entry, including the mount parameter, is returned, it is advisable to allocate space for at least two entries.
When the final entry has been placed in the buffer, w_getmntent() returns no entries.
In the header, the field mnth_size returns the number of bytes of data put in the buffer. The fields mnth_cur1 and mnth_cur2 contain positioning information that w_getmntent() uses to store the information. If multiple calls are made, use the same buffer because the positioning information in mnth_cur1 and mnth_cur2 indicates where the function should continue with its list. The positioning information should not be changed between calls.
The pathname of the directory where the file system is mounted. This field ends with a NULL.
If the caller of w_getmntent() lacks search authorization to one or more of the directories in the mount point pathname, mnt_mountpoint is returned empty. That is, mnt_pathlen is zero and mnt_mountpoint contains a NULL as the first character.
The file-system-specific parameter specified on the mount() function when the file system was mounted. This field ends with a NULL.
If no parameter was specified, mnt_parmlen and mnt_parmoffset are each zero. If a parameter was specified, its address is the sum of the address of w_mntent and mnt_parmoffset.
If all entries do not fit in the buffer supplied, multiple calls are required. If an entry together with its mount parameter will not fit in the buffer, the entry is returned without the mount parameter. In this case, mnt_parmlen contains the length of the mount parameter, and mnt_parmoffset is zero.
To assure that at least one entry, including the mount parameter, is returned, it is advisable to allocate space for at least two entries.
When the final entry has been placed in the buffer, w_getmntent() returns no entries.
If successful, w_getmntent() returns the number of entries in the buffer.
⁄* CELEBW49
This example uses w_getmntent() to retrieve information
about currently mounted systems in the MNTE3 mapping format.
The MNTE3 mapping format is only available on z⁄OS V1.10 or higher,
target value of 0x410A0000.
*⁄
#define _OPEN_SYS
#include <sys⁄mntent.h>
#include <stdio.h>
main() {
int entries, entry;
struct {
MNTE3H header;
W_MNTENT3 mount_table[10];
} work_area;
memset(&work_area, 0x00, sizeof(work_area));
⁄* 'header' initialization to specify MNTE3 mapping format *⁄
memcpy(work_area.header.mnt3H_cbid, MNTE3H_ID, 4);
work_area.header.mnt3H_cblen = sizeof(struct mnte3);
work_area.header.mnt3H_bodylen = sizeof(struct w_mntent3);
do {
if ((entries = w_getmntent((char *) &work_area,
sizeof(work_area))) == -1)
perror("w_getmntent() error");
else for (entry=0; entry<entries; entry++) {
printf("filesystem %s is mounted at %s\n",
work_area.mount_table[entry].mnt3_fsname,
work_area.mount_table[entry].mnt3_mountpoint);
printf(" MNTE2 and MNTE3 common: reads done is %i, writes done is %i\n",
work_area.mount_table[entry].mnt3_readct,
work_area.mount_table[entry].mnt3_writect);
printf(" MNTE3 specific: mount time in seconds is %i\n",
work_area.mount_table[entry].mnt3_mntsec);
}
} while (entries > 0);
}
filesystem ZOS110.LPP.HFS is mounted at /usr/lpp
MNTE2 and MNTE3 common: reads done is 0, writes done is 0
MNTE3 specific: mount time in seconds is 5833
filesystem ZOS110.NLS.HFS is mounted at /usr/lib/nls
MNTE2 and MNTE3 common: reads done is 0, writes done is 0
MNTE3 specific: mount time in seconds is 5833
filesystem ZOS110.MAN.HFS is mounted at /usr/man
MNTE2 and MNTE3 common: reads done is 0, writes done is 0
MNTE3 specific: mount time in seconds is 5833
filesystem ZOS110.VAR.HFS is mounted at /SYSTEM/var
MNTE2 and MNTE3 common: reads done is 0, writes done is 0
MNTE3 specific: mount time in seconds is 5833
filesystem ZOS110.ETC.HFS is mounted at /SYSTEM/etc
MNTE2 and MNTE3 common: reads done is 0, writes done is 0
MNTE3 specific: mount time in seconds is 5833
filesystem ZOS110.ROOT.HFS is mounted at /
MNTE2 and MNTE3 common: reads done is 0, writes done is 0
MNTE3 specific: mount time in seconds is 5833
⁄* CELEBW48
This example uses w_getmntent() to retrieve information
about currently mounted systems in the MNTE2 mapping format.
*⁄
#define _OPEN_SYS
#include <sys⁄mntent.h>
#include <stdio.h>
main() {
int entries, entry;
struct {
MNTE2H header;
W_MNTENT2 mount_table[10];
} work_area;
memset(&work_area, 0x00, sizeof(work_area));
⁄* 'header' initialization to specify MNTE2 mapping format *⁄
memcpy(work_area.header.mh2_hdr.mnt2h_cbid, MNTE2H_ID, 4);
work_area.header.mh2_hdr.mnt2h_cblen = sizeof(struct mnte2);
work_area.header.mh_bodylen = sizeof(struct w_mntent2);
do {
if ((entries = w_getmntent((char *) &work_area,
sizeof(work_area))) == -1)
perror("w_getmntent() error");
else for (entry=0; entry<entries; entry++) {
printf("filesystem %s is mounted at %s\n",
work_area.mount_table[entry].mnt2_fsname,
work_area.mount_table[entry].mnt2_mountpoint);
printf(" MNTE2 specific: reads done is %i, writes done is %i\n",
work_area.mount_table[entry].mnt2_readct,
work_area.mount_table[entry].mnt2_writect);
}
} while (entries > 0);
}
filesystem ZOS110.LPP.HFS is mounted at /usr/lpp
MNTE2 specific: reads done is 0, writes done is 0
filesystem ZOS110.NLS.HFS is mounted at /usr/lib/nls
MNTE2 specific: reads done is 0, writes done is 0
filesystem ZOS110.MAN.HFS is mounted at /usr/man
MNTE2 specific: reads done is 0, writes done is 0
filesystem ZOS110.VAR.HFS is mounted at /SYSTEM/var
MNTE2 specific: reads done is 0, writes done is 0
filesystem ZOS110.ETC.HFS is mounted at /SYSTEM/etc
MNTE2 specific: reads done is 0, writes done is 0
filesystem ZOS110.ROOT.HFS is mounted at /
MNTE2 specific: reads done is 0, writes done is 0
⁄* CELEBW32
This example uses w_getmntent() to retrieve information
about currently mounted systems in the MNTE mapping format.
*⁄
#define _OPEN_SYS
#include <sys⁄mntent.h>
#include <stdio.h>
main() {
int entries, entry;
struct {
struct w_mnth header;
struct w_mntent mount_table[10];
} work_area;
memset(&work_area, 0x00, sizeof(work_area));
do {
if ((entries = w_getmntent((char *) &work_area,
sizeof(work_area))) == -1)
perror("w_getmntent() error");
else for (entry=0; entry<entries; entry++) {
printf("filesystem %s is mounted at %s\n",
work_area.mount_table[entry].mnt_fsname,
work_area.mount_table[entry].mnt_mountpoint);
}
} while (entries > 0);
}
filesystem ZOS110.LPP.HFS is mounted at /usr/lpp
filesystem ZOS110.NLS.HFS is mounted at /usr/lib/nls
filesystem ZOS110.MAN.HFS is mounted at /usr/man
filesystem ZOS110.VAR.HFS is mounted at /SYSTEM/var
filesystem ZOS110.ETC.HFS is mounted at /SYSTEM/etc
filesystem ZOS110.ROOT.HFS is mounted at /