getmntent.3x (2010 09)

g
getmntent(3X) getmntent(3X)
NAME
getmntent(), 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);
DESCRIPTION
These 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.
setmntent() Opens a file system description file and returns a file pointer which can then be
used with getmntent(), addmntent(), delmntent(),orendmntent().
The type argument is the same as in fopen().
getmntent() Reads the next line from stream and returns a pointer to an object with the follow-
ing structure containing the broken-out fields of a line in the file-system description
file, <mntent.h>. The fields have meanings described in fstab (4).
struct mntent {
char *mnt_fsname; /* file system name */
char *mnt_dir; /* file system path prefix */
char *mnt_type; /* hfs, nfs, swap, or xx */
char *mnt_opts; /* ro, suid, etc. */
int mnt_freq; /* dump frequency, in days */
int mnt_passno; /* pass number on parallel fsck */
long mnt_time; /* When file system was mounted;*/
/* see mnttab(4). */
/* (0 for NFS) */
};
getmntent_r() Uses three extra parameters to provide results equivalent to those produced by
getmntent(). The extra parameters are:
1. The address of a struct mntent where the result will be stored.
2. A buffer to store character strings to which fields in the struct mntent will
point.
3. The length of the user-supplied buffer. A buffer length of 1025 is recommended.
addmntent() Adds the mntent structure mnt to the end of the open file stream . Note that
stream must be opened for writing. Upon return from the call to addmntent, the
file position indicator for the stream will point to EOF.
delmntent() Deletes all entries from the file stream opened with setmntent that match both
mnt_fsname and mnt_dir in mntent structure mnt.Ifmnt_fsname is a null
pointer, all entries that match mnt_dir will be deleted. If mnt_dir is a null pointer,
all entries that match mnt_fsname will be deleted. It is an error if both mnt_fsname
and mnt_dir are null pointers. Note that stream must be opened via setmntent
for reading and writing (r+ or a+). Upon return from the call to delmntent, the
file position indicator for the stream will point to EOF.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (6 pages)