HP-UX Reference (11i v2 03/08) - 3 Library Functions A-M (vol 6)
g
getmntent(3X) getmntent(3X)
#define MNTOPT_MIN "min" /* minimum file system swap */
#define MNTOPT_LIM "lim" /* maximum file system swap */
#define MNTOPT_RES "res" /* reserve space for file system */
#define MNTOPT_PRI "pri" /* file system swap priority */
NETWORKING FEATURES
NFS
The following definitions are provided in
<mntent.h>:
#define MNTOPT_BG "bg" /* Retry mount in background */
#define MNTOPT_FG "fg" /* Retry mount in foreground */
#define MNTOPT_RETRY "retry" /* Number of retries allowed */
#define MNTOPT_RSIZE "rsize" /* Read buffer size in bytes */
#define MNTOPT_WSIZE "wsize" /* Write buffer size in bytes*/
#define MNTOPT_TIMEO "timeo" /* Timeout in 1/10 seconds */
#define MNTOPT_RETRANS "retrans" /* Number of retransmissions */
#define MNTOPT_PORT "port" /* Server’s IP NFS port */
#define MNTOPT_SOFT "soft" /* Soft mount */
#define MNTOPT_HARD "hard" /* Hard mount */
#define MNTOPT_INTR "intr" /* Interruptible hard mounts */
#define MNTOPT_NOINTR "nointr" /* Uninterruptible hard mounts*/
#define MNTOPT_DEVS "devs" /* Device file access allowed */
#define MNTOPT_NODEVS "nodevs" /* No device file access allowed*/
RETURN VALUE
setmntent() Returns a null pointer on error. setmntent() attempts to establish an
exclusive write lock on the file it is opening, ie: when one of the following types is
passed to setmntent() to open the file for write/update: "w", "a", "r+", "w+", or
"a+". If setmntent() cannot get the lock, it returns a null pointer and sets errno
to either [EACCES] or [EAGAIN]. See APPLICATION USAGE below for more
information about
setmntent().
getmntent() Returns a null pointer on error or EOF. Otherwise, getmntent() returns a
pointer to a mntent structure. Some of the fields comprising a mntent structure are
optional in /etc/fstab and /etc/mnttab. In the supplied structure, such
missing character pointer fields are set to NULL and missing integer fields are set
to −1 for mnt_freq and mnt_passno. If the integer field for mnt_time is
missing, it is set to 0.
getmntent_r() Returns a -1 on error or EOF, or if the supplied buffer is of insufficient length. If
the operation is successful, 0 is returned.
addmntent() Returns 1 on error.
delmntent() Returns -1 on error. Sets errno to [EINVAL] if stream or mnt are null pointers, or
if both mnt_fsname and mnt_dir in
mntent structure mnt are null pointers. Sets
errno to [EBADF] if stream has been opened for read (r), append (a) or write (w). If
the operation is successful, returns the number of entries deleted from the file.
When no entries are matched, delmntent returns 0 and does not set errno.
endmntent() Returns 1, and unlocks the file if it was locked by setmntent().
EXAMPLES
The following code deletes an entry:
struct mntent mnt_entry;
FILE *fp;
int retval = NOT_DELETED;
mnt_entry.mnt_fsname = "/dev/vg00/lvol7";
mnt_entry.mnt_dir = "/disk7";
if ((fp = setmntent(MNT_MNTTAB, "r+")) != NULL) {
if (delmntent(fp, &mnt_entry) > 0)
retval = DELETED;
(void)endmntent(fp);
Section 3−−378 Hewlett-Packard Company − 3 − HP-UX 11i Version 2: August 2003