Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getmntinfo(3) — OSF/1 3.0 αXP

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getfsstat(2)

statfs(2)

mount(2)

malloc(3)

mount(8)

getmntinfo(3)  —  Subroutines

NAME

getmntinfo, getmntinfo_r − Get information about mounted file systems

SYNOPSIS

#include <sys/types.h>
#include <sys/mount.h>

int getmntinfo(
        struct statfs ∗∗mntbufp,
        int flags);

int getmntinfo_r(
        struct statfs ∗∗mntbufp,
        int flags,
        int ∗mntsizep,
        int ∗bufsizep);

PARAMETERS

mntbufpPoints to a location to which the getmntinfo function returns an array of statfs structures that describe each currently mounted file system. If you specify an invalid address, [EFAULT] status is returned in errno.  If you specify NULL, an invalid memory access occurs. 

flagsSpecifies one of the following flags to be passed transparently to the getfsstat() function:

MNT_WAIT
Waits for an update from each file system before returning information.

MNT_NOWAIT
Information is returned without requesting an update from each file system. Thus, some of the information will be out of date, but the getfsstat() function will not block waiting for information from a file system that is unable to respond. 

mntsizepPoints to the location where the number of mounted file systems is stored. 

bufsizepPoints to the size of the buffer containing the array of statfs structures for all mounted file systems. 

DESCRIPTION

The getmntinfo() function returns an array of statfs structures describing each currently mounted file system (see the statfs() reference page).  The getmntinfo() function takes a struct statfs ∗∗mntbufp, which it sets to a malloc() ed buffer. 

The getmntinfo() function passes its flags parameter transparently to getfsstat(). 

The getmntinfo_r() function is the reentrant version of getmntinfo(). 

EXAMPLES

The following example shows a suggested way to use the getmntinfo_r() function. 

struct statfs ∗mntbuf;
int mntsize, bufsize, flags;
        mntsize = bufsize = 0;
        mntbuf = NULL;
        while (keep_on) {
                flags = MNT_WAIT;
                getmntinfo_r(&mntbuf, flags, &mntsize, &bufsize);
                /∗ Use the data accessible via mntbuf... ∗/
                ....
        }
        free(mntbuf);

NOTES

For the getmntinfo() function, all information is contained in a static area, so it must be copied if it is to be saved. 

Before the first call to getmntinfo_r(), you should set the ∗mntbufp parameter to NULL.  This is to prevent the free() function from being called on whatever ∗mntbufp already contains by the first getmntinfo_r() call.  The mntsizep and bufsizep parameters must also be set to 0 (zero).  This is illustrated in the EXAMPLES section. 

RETURN VALUES

Upon successful completion, the getmntinfo() function returns a count of the number of elements in the array.  Otherwise, a value of 0 (zero) is returned and mntbufp is unmodified. 

Upon successful completion, the getmntinfo_r() function stores the count of the number of elements in the array into the int pointed to by mntsizep, and returns a value of 0 (zero).  Otherwise, a value of -1 is returned. 

ERRORS

If the getmntinfo() or getmntinfo_r() function fails, errno may be set to the following:

[EFAULT]The mntbufp parameter points to a non-NULL invalid address. 

[EIO]An I/O error occurred while reading from or writing to the file system. 

[EINVAL]If the bufsizep parameter is invalid. 

[ENOMEM]If there is not enough storage memory in the system. 

RELATED INFORMATION

Functions: getfsstat(2), statfs(2), mount(2), malloc(3)

Commands: mount(8)

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