HP 3000 Manuals

opendir [ MPE/iX Developer's Kit Reference Manual Volume I ] MPE/iX 5.0 Documentation


MPE/iX Developer's Kit Reference Manual Volume I

opendir 

Opens a directory stream.

Syntax 

     #include <sys/types.h>
     #include <dirent.h>
     DIR *opendir (const char *pathname);

Parameters 

pathname   A pointer to a string containing a pathname of a directory to
           open.  The pathname must be terminated by a null character.

Return Values 

<>NULL     Success.  A pointer to an object of type DIR is returned.

NULL       An error occurred.  The directory is not opened, and errno is
           set to indicate the error condition.

Description 

The opendir() function opens a directory stream associated with the
directory specified by pathname and returns a pointer to the open
directory stream to be used by subsequent calls to readdir(),
rewinddir(), and closedir().

The directory stream is positioned at the first entry in the directory.

Implementation Considerations 

Refer to the EFAULT, EIMPL, EMFILE, and ESYSERR error descriptions below.

The type DIR (defined in <dirent.h>) is implemented using a file
descriptor.  Applications can only open a total of {OPEN_MAX} files and
directories.

The FD_CLOEXEC flag is not currently supported.

Errors 

If an error occurs, errno is set to one of the following values:

EACCES            CAUSE           Either the calling process does not have search
                                  permission to a component of pathname or does not
                                  have read permission to the directory to be opened.
                  ACTION          Make sure that the calling process has ACD traverse
                                  directory (TD) access for all components of the
                                  pathname and ACD read directory (RD) access to the
                                  directory to be opened.

EFAULT            CAUSE           The system detected a NULL or bad address in
                                  attempting to use the pathname parameter or the
                                  pathname was not terminated by a null character.
                  ACTION          Make sure that the pointer is correctly initialized.

EIMPL             CAUSE           The pathname begins with two slash characters (//).
                  ACTION          Do not begin pathnames with two slash characters
                                  (//).

EMFILE            CAUSE           The number of directory streams and files opened by
                                  the calling process would exceed {OPEN_MAX}.
                  ACTION          Reduce the number of directories and files opened by
                                  the process.

ENAMETOOLONG      CAUSE           One of the following:
                                     *   The length of the pathname exceeds the
                                         {PATH_MAX} limit (defined in the file
                                         <limits.h>).
                                     *   A component of the pathname is longer than
                                         {NAME_MAX} (defined in <limits.h>), and
                                         {_POSIX_NO_TRUNC} is in effect for that
                                         directory.
                  ACTION          Make sure that both the component's length and the
                                  full pathname length do not exceed the {NAME_MAX} or
                                  {PATH_MAX} limits.

ENOENT            CAUSE           The specified directory does not exist, or pathname 
                                  points to an empty string.
                  ACTION          Specify an existing directory name.

          Table 4-0.  (cont.) 

ENOTDIR           CAUSE           A component of the pathname is not a directory.
                  ACTION          Specify a valid pathname.

ESYSERR           CAUSE           An operating system error has occurred that does not
                                  map directly to any of the above errors.
                  ACTION          Examine the MPE/iX error stack for the type of system
                                  error.

See Also 

closedir(), readdir(), rewinddir(), <dirent.h>, POSIX.1 (Section 5.1.2)



MPE/iX 5.0 Documentation