|
|
HP-UX Reference Volume 4 of 5 > ggetmntent(3X) |
|
NAMEgetmntent(), getmntent_r(), setmntent(), addmntent(), delmntent(), endmntent(), hasmntopt() — get file system descriptor file entry SYNOPSIS#include <mntent.h> FILE *setmntent(const char *path, char *type); struct mntent *getmntent(FILE *stream); int getmntent_r( FILE *stream, struct mntent *result, char *buffer, int buflen); int addmntent(FILE *stream, struct mntent *mnt); int delmntent(FILE *stream, struct mntent *mnt); char *hasmntopt(struct mntent *mnt, const char *opt); int endmntent(FILE *stream); DESCRIPTIONThese routines replace the obsolete getfsent() routines (see getfsent(3X)) for accessing the file system description file /etc/fstab. They are also used to access the mounted file system description file /etc/mnttab.
The following definitions are provided in <mntent.h>: #define MNT_CHECKLIST "/etc/fstab" #define MNT_MNTTAB "/etc/mnttab" #define MNTMAXSTR 128 /* Max size string in mntent */ #define MNTTYPE_HFS "hfs" /* HFS file system */ #define MNTTYPE_CDFS "cdfs" /* CD-ROM file system */ #define MNTTYPE_NFS "nfs" /* Network file system */ #define MNTTYPE_SWAP "swap" /* Swap device */ #define MNTTYPE_SWAPFS "swapfs" /* File system swap */ #define MNTTYPE_IGNORE "ignore" /* Ignore this entry */ #define MNTOPT_DEFAULTS "defaults" /* Use all default options */ #define MNTOPT_RO "ro" /* Read only */ #define MNTOPT_RW "rw" /* Read/write */ #define MNTOPT_SUID "suid" /* Set uid allowed */ #define MNTOPT_NOSUID "nosuid" /* No set uid allowed */ #define MNTOPT_QUOTA "quota" /* Enable disk quotas */ #define MNTOPT_NOQUOTA "noquota" /* Disable disk quotas */ The following definition is provided for device swap in <mntent.h>: #define MNTOPT_END "end" /* swap after end of file system, Series 300/400/700 only */ The following definitions are provided for file system swap in <mntent.h>: #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 FEATURESNFSThe 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
EXAMPLESThe 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 USAGEData 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. MT-USAGEsetmntent() 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. |
|