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

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
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 field 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.
MULTITHREAD USAGE
setmntent() and endmntent() are safe for per process locking, but are not safe for locking from
multiple threads of the same process. getmntent() , addmntent() , delmntent() , and
hasmntent() are safe to be called from multi-threaded applications. setmntent() , getmntent() ,
addmntent() , delmntent() , hasmntent() , and endmntent() are not async-signal safe, and
they are not safe to be called by a child process after fork() but before exec().
addmntent() is
async-cancel safe, however
setmntent() , getmntent() , delmntent() , hasmntent() , and
endmntent() are not async-cancel safe.
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).
HP-UX Release 11i: December 2000 3 Section 3311
___
___