|
from small one page howto to huge articles all in one place
poll results
Last additions:
May 25th. 2007:
|
You are here: manpages
GETDENTS
Section: Linux Programmer's Manual (2) Updated: 2008-06-22 Index
Return to Main Contents
NAME
getdents - get directory entries
SYNOPSIS
#include <unistd.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/unistd.h>
#include <errno.h>
int getdents(unsigned int fd, struct dirent *dirp,
unsigned int count);
DESCRIPTION
This is not the function you are interested in.
Look at
readdir(3)
for the POSIX conforming C library interface.
This page documents the bare kernel system call interface.
The system call
getdents()
reads several
dirent
structures from the directory
referred to by the open file descriptor
fd
into the buffer pointed to by
dirp.
The argument
count
is the size of the memory area.
The
dirent
structure is declared as follows:
struct linux_dirent {
unsigned long d_ino; /* Inode number */
unsigned long d_off; /* Offset to next dirent */
unsigned short d_reclen; /* Length of this dirent */
char d_name []; /* Filename (null-terminated) */
/* length is actually (d_reclen - 2 -
offsetof(struct linux_dirent, d_name) */
char pad; /* Zero padding byte */
char d_type; /* File type (only since Linux 2.6.4;
offset is (d_reclen - 1)) */
}
d_ino
is an inode number.
d_off
is the distance from the start of the directory to the start of the next
dirent.
d_reclen
is the size of this entire
dirent.
d_name
is a null-terminated filename.
d_type
is a byte at the end of the structure that indicates the file type.
It contains one of the following values:
- DT_BLK
-
This is a block device.
- DT_CHR
-
This is a character device.
- DT_DIR
-
This is a directory.
- DT_FIFO
-
This is a named pipe (FIFO).
- DT_LNK
-
This is a symbolic link.
- DT_REG
-
This is a regular file.
- DT_SOCK
-
This is a Unix domain socket.
- DT_UNKNOWN
-
The file type is unknown.
RETURN VALUE
On success, the number of bytes read is returned.
On end of directory, 0 is returned.
On error, -1 is returned, and
errno
is set appropriately.
ERRORS
- EBADF
-
Invalid file descriptor
fd.
- EFAULT
-
Argument points outside the calling process's address space.
- EINVAL
-
Result buffer is too small.
- ENOENT
-
No such directory.
- ENOTDIR
-
File descriptor does not refer to a directory.
CONFORMING TO
SVr4.
NOTES
Glibc does not provide a wrapper for this system call; call it using
syscall(2).
This call supersedes
readdir(2).
SEE ALSO
readdir(2),
readdir(3)
COLOPHON
This page is part of release 3.05 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/.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- ERRORS
-
- CONFORMING TO
-
- NOTES
-
- SEE ALSO
-
- COLOPHON
-
Please read "Why adblockers are bad".
Ärger mit Freenet.de
|
other Ads
Other free services
.
.
|