Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

chown(2)

creat(2)

link(2)

mknod(2)

pipe(2)

read(2)

time(2)

unlink(2)

utime(2)

write(2)

fs(0)



  statfs(2)                           CLIX                           statfs(2)



  NAME

    statfs, fstatfs - Gets file system information

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    #include <sys/types.h>

    #include <sys/statfs.h>

    int statfs(
      char *path ,
      struct statfs *buf ,
      int len ,
      int fstyp );

    int fstatfs(
      int fildes ,
      struct statfs *buf ,
      int len ,
      int fstyp );

  PARAMETERS

    path     Points to the pathname of a file in a mounted file system, or of
             the block special file which contains an unmounted file system.

    fildes   Specifies the file descriptor for a file in a mounted file
             system, or for the block special file which contains an unmounted
             file system.

    buf      Points to a statfs structure that will be filled by the function.

    len      Specifies the size in bytes of the buf parameter.

    fstyp    Specifies the type of file system.  (See the sysfs() function.)

  DESCRIPTION

    The statfs() function returns a generic superblock describing a file
    system.  It can be used to acquire information about mounted as well as
    unmounted file systems, and usage is slightly different in the two cases.
    In all cases, buf is a pointer to a structure (described below) which will
    be filled by the function, and len is the number of bytes of information
    which the system should return in the structure.  The value of len must be
    no greater than sizeof(struct statfs), and will ordinarily contain exactly
    that value.  If len holds a smaller value the system will fill the



  2/94 - Intergraph Corporation                                              1






  statfs(2)                           CLIX                           statfs(2)



    structure with that number of bytes.

    If the file system of interest is currently mounted, path should name a
    file which resides on that file system.  In this case the file system type
    is known to the operating system and the fstyp parameter must be 0.  For
    an unmounted file system path must name the block special file containing
    it and fstyp must contain the (nonzero) file system type.  In both cases
    read, write, or execute permission of the named file is not required, but
    all directories listed in the pathname leading to the file must be
    searchable.

    The statfs structure pointed to by buf includes the following members:

    short     f_fstyp;     /* File system type */
    short     f_bsize;     /* Block size */
    short     f_frsize;    /* Fragment size */
    long f_blocks;    /* Total number of blocks */
    long f_bfree;     /* Count of free blocks */
    long f_files;     /* Total number of file nodes */
    long f_ffree;     /* Count of free file nodes */
    char f_fname[6];  /* Volume name */
    char f_fpack[6];  /* Pack name */

    The fstatfs() function is similar to statfs(), except that the file named
    by path in statfs is identified by an open file descriptor (fildes)
    obtained from a successful open(), creat(), dup(), fcntl(), or pipe()
    function.

    The statfs() function obsoletes ustat(), and should be used in preference
    to it in new programs.

  EXAMPLES

    1.  To get information about an unmounted file system:

        if (statfs("/dev/dsk/s7u0p7.4", &statfs_buf,
                  sizeof(statfs_buf), fstyp) != 0)
             perror("statfs failed");


    2.  To get information about the file system which contains an open file:

        if (fstatfs(fd, &statfs_buf, sizeof(statfs_buf), fstyp)
            != 0)
             perror("fstatfs failed");


  RETURN VALUES

    Upon successful completion a value of 0 is returned.  Otherwise, a value
    of -1 is returned and errno is set to indicate the error.



  2                                              Intergraph Corporation - 2/94






  statfs(2)                           CLIX                           statfs(2)



  ERRORS

    The statfs() and fstatfs() functions fail if one or more of the following
    are true:

    [ENOTDIR]
           A component of the path prefix is not a directory.

    [ENOENT]
           The named file does not exist.

    [EACCES]
           Search permission is denied for a component of the path prefix.

    [EFAULT]
           The value of buf or path points to an address that is not valid.

    [EBADF]
           The value of fildes is not a valid open file descriptor.

    [EINVAL]
           The value of fstyp is not a valid file system type.  The value of
           path is not a block special file and fstyp is nonzero.  The value
           of len is negative or is greater than sizeof(struct statfs).

    [ENOLINK]
           The value of path points to a remote machine, and the link to that
           machine is no longer active.

    [EMULTIHOP]
           Components of path require hopping to multiple remote machines.

  RELATED INFORMATION

    Functions:  chmod(2), chown(2), creat(2), link(2), mknod(2), pipe(2),
    read(2), time(2), unlink(2), utime(2), write(2)

    Files:  fs(0)
















  2/94 - Intergraph Corporation                                              3




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