Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

opendir(3) [redhat man page]

OPENDIR(3)						     Linux Programmer's Manual							OPENDIR(3)

NAME
opendir - open a directory SYNOPSIS
#include <sys/types.h> #include <dirent.h> DIR *opendir(const char *name); DESCRIPTION
The opendir() function opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream. The stream is positioned at the first entry in the directory. RETURN VALUE
The opendir() function returns a pointer to the directory stream or NULL if an error occurred. ERRORS
EACCES Permission denied. EMFILE Too many file descriptors in use by process. ENFILE Too many files are currently open in the system. ENOENT Directory does not exist, or name is an empty string. ENOMEM Insufficient memory to complete the operation. ENOTDIR name is not a directory. NOTES
The underlying file descriptor of the directory stream can be obtained using dirfd(3). CONFORMING TO
SVID 3, POSIX, BSD 4.3 SEE ALSO
open(2), closedir(3), dirfd(3), readdir(3), rewinddir(3), scandir(3), seekdir(3), telldir(3) 1995-06-11 OPENDIR(3)

Check Out this Related Man Page

OPENDIR(3)						     Linux Programmer's Manual							OPENDIR(3)

NAME
opendir, fdopendir - open a directory SYNOPSIS
#include <sys/types.h> #include <dirent.h> DIR *opendir(const char *name); DIR *fdopendir(int fd); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): fdopendir(): Since glibc 2.10: _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L Before glibc 2.10: _GNU_SOURCE DESCRIPTION
The opendir() function opens a directory stream corresponding to the directory name, and returns a pointer to the directory stream. The stream is positioned at the first entry in the directory. The fdopendir() function is like opendir(), but returns a directory stream for the directory referred to by the open file descriptor fd. After a successful call to fdopendir(), fd is used internally by the implementation, and should not otherwise be used by the application. RETURN VALUE
The opendir() and fdopendir() functions return a pointer to the directory stream. On error, NULL is returned, and errno is set appropri- ately. ERRORS
EACCES Permission denied. EBADF fd is not a valid file descriptor opened for reading. EMFILE Too many file descriptors in use by process. ENFILE Too many files are currently open in the system. ENOENT Directory does not exist, or name is an empty string. ENOMEM Insufficient memory to complete the operation. ENOTDIR name is not a directory. VERSIONS
fdopendir() is available in glibc since version 2.4. CONFORMING TO
opendir() is present on SVr4, 4.3BSD, and specified in POSIX.1-2001. fdopendir() is specified in POSIX.1-2008. NOTES
The underlying file descriptor of the directory stream can be obtained using dirfd(3). The opendir() function sets the close-on-exec flag for the file descriptor underlying the DIR *. The fdopendir() function leaves the set- ting of the close-on-exec flag unchanged for the file descriptor, fd. POSIX.1-200x leaves it unspecified whether a successful call to fdopendir() will set the close-on-exec flag for the file descriptor, fd. SEE ALSO
open(2), closedir(3), dirfd(3), readdir(3), rewinddir(3), scandir(3), seekdir(3), telldir(3) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-06-20 OPENDIR(3)
Man Page

9 More Discussions You Might Find Interesting

1. Programming

about convertions

hi i got in this way DIR *dd; dd = opendir("/root/ramesh/"); ..... then now i have problem how can i convert a string to hexadecimals ex: ram/es:h show me the way thank you for your feedback ramesh (4 Replies)
Discussion started by: ramesh.jella
4 Replies

2. Programming

opendir() + customly created directories

Gday all In a program I am designing, I am using opendir() to test whether entries under a certain directory are sub-directories or not. This method works fine for the directory itself (.) and the parent directory (..), however it does not work for any sub-directories I manually create. i.e.... (5 Replies)
Discussion started by: JamesGoh
5 Replies

3. UNIX for Dummies Questions & Answers

transfering a directory to the toolman

I have a question about transferring a directory to the toolman. I have a directory called assn3 that contains two txt files and one empty directory and I want to transfer the assn3 to my my tooman account. Every time I try to transfer the file it says that the assn3 is not a regular file! what... (3 Replies)
Discussion started by: aama100
3 Replies

4. HP-UX

(13)Permission denied: make_sock:

while starting apache i'm getting this error (13)Permission denied: make_sock: could not bind to address :80 no listening sockets available, shutting down Unable to open logs Plz guide me to resolve this issue.. (2 Replies)
Discussion started by: oracle_rajesh_k
2 Replies

5. Shell Programming and Scripting

Hiding the Directory

Hi, I have a directory i want to just hide this directory. Could you please tell me the command to hide directory. (2 Replies)
Discussion started by: shivanete
2 Replies

6. UNIX for Advanced & Expert Users

How can I find out the open files in a directory

Hello all, Is there any other way of finding the open files in a directory apart from command 'lsof'. thanks (3 Replies)
Discussion started by: joshi123
3 Replies

7. UNIX for Advanced & Expert Users

how to open a last modified file in a directory

how to directly open a last modified file in a directory? Please help (5 Replies)
Discussion started by: apsprabhu
5 Replies

8. UNIX for Dummies Questions & Answers

Unix directory system calls question

I'm currently studying for my exam, and is practicing with sample exam questions. However there is a question asking "Name THREE UNIX Directory system calls" and the answer given is "opendir, closedir and readdir", however the next question ask "Why is a write directory system call not included... (1 Reply)
Discussion started by: Izzy123
1 Replies

9. Programming

Function open() sets errno

I am opening a text file using open() system call in O_RDONLY mode. open() returns me a valid handler but also sets errno to 13 i.e. EACCES(Permission denied). Question is when open() is returning a valid handler then why does it sets the errno? Should not errno be set only in case of error... (10 Replies)
Discussion started by: rupeshkp728
10 Replies