man(1) Manual page archive


     DIRREAD(2)                                             DIRREAD(2)

     NAME
          dirread - read from directory, hiding format

     SYNOPSIS
          int dirread(fildes, buffer, nbytes)
          char *buffer;

     DESCRIPTION
          Dirread reads at most nbytes bytes of directory information
          from the file pointer location in the directory associated
          with fildes into memory at buffer. The information is con-
          verted into a canonical form, independent of the format used
          by the file system in which the directory resides.

          Each canonicalized entry consists of a decimal ASCII inode
          number, a tab character, a file name, and an ASCII NUL.
          Buffer is filled with as many entries as will fit; the num-
          ber of bytes used is returned.  0 is returned when there are
          no more entries.

          The file pointer is advanced by the number of bytes passed
          over in the directory, not the number of bytes placed in
          buffer. Ask lseek for the new pointer; don't try to compute
          it.

     SEE ALSO
          open(2), read(2), directory(3), dir(5)

     DIAGNOSTICS
          EBADF, ENOSPC (buffer too small), ENOTDIR, EFAULT, EINVAL

     BUGS
          Not all file system types support dirread. The routines in
          directory(3) know how to cope.
          Seeking in directories is dangerous, because the contents
          often change under foot.