HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)

g
getmntent(3X) getmntent(3X)
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 eld for
mnt_time is miss-
ing, 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);
}
return(retval);
APPLICATION USAGE
Data integrity is not guaranteed when reading the mntent data because setmntent() does not lock
the file when opening it with read only permission.
Programs should expect that the file accessed by these APIs may be write locked by another process
because setmntent() attempts to establish an exclusive write lock when opening it for write/update.
Use of a text editor to manipulate the file accessed by these APIs is not supported.
setmntent() and
endmntent() are safe for per process locking. setmntent() , getmntent() , addmntent() ,
delmntent() , hasmntent() , and endmntent() are not safe to be called by a child process after
fork() but before exec().
AUTHOR
addmntent() , endmntent() , getmntent() , hasmntopt() , and setmntent() were
developed by The University of California, Berkeley, Sun Microsystems, Inc., and HP. delmntent()
was developed by HP.
FILES
/etc/fstab
/etc/mnttab
SEE ALSO
fstab(4), getfsent(3X), mnttab(4), thread_safety(5).
Section 3342 Hewlett-Packard Company 3 HP-UX 11i Version 1: September 2005