Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ hasmntopt(3) — SunOS 4.0.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(3S)

getfsent(3)

fstab(5)

GETMNTENT(3)  —  C LIBRARY FUNCTIONS

NAME

getmntent, setmntent, addmntent, endmntent, hasmntopt − manipulate /etc/fstab and /etc/mtab file system description files

SYNOPSIS

#include <stdio.h>
#include <mntent.h>
FILE ∗setmntent(filep, type)
char ∗filep;
char ∗type;
struct mntent ∗getmntent(filep)
FILE ∗filep;
int addmntent(filep, mnt)
FILE ∗filep;
struct mntent ∗mnt;
char ∗hasmntopt(mnt, opt)
struct mntent ∗mnt;
char ∗opt;
int endmntent(filep)
FILE ∗filep;

DESCRIPTION

These routines replace the getfsent( ) routines for accessing the file system description file /etc/fstab and the mounted file system description file /etc/mtab. 

setmntent( ) opens a file system description file and returns a file pointer which can then be used with getmntent, addmntent, or endmntent.  The type argument is the same as in fopen(3).  getmntent( ) reads the next line from filep and returns a pointer to an object with the following structure containing the broken-out fields of a line in the file system description file, <mntent.h>.Onfailure, getmntent( ) returns the NULL pointer.  The fields have meanings described in fstab(5). 

structmntent{
char∗mnt_fsname;/∗ name of mounted file system ∗/
char∗mnt_dir;/∗ file system path prefix ∗/
char∗mnt_type;/∗ MNTTYPE_∗ ∗/
char∗mnt_opts;/∗ MNTOPT∗ ∗/
intmnt_freq;/∗ dump frequency, in days ∗/
intmnt_passno;/∗ pass number on parallel fsck ∗/
};

addmntent( ) adds the mntent structure mnt to the end of the open file filep. addmntent( ) returns 0 on success, 1 on failure.  Note: filep has to be opened for writing if this is to work.  hasmntopt( ) scans the mnt_opts field of the mntent structure mnt for a substring that matches opt. It returns the address of the substring if a match is found, 0 otherwise. endmntent( ) closes the file.  It always returns 1, so should be treated as type void. 

FILES

/etc/fstab

/etc/mtab

SEE ALSO

fopen(3S), getfsent(3), fstab(5)

DIAGNOSTICS

NULL pointer (0) returned on EOF or error. 

BUGS

The returned mntent structure pointer points to static information that is overwritten in each call. 

Sun Release 4.0  —  Last change: 3 May 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026