from small one page howto to huge articles all in one place
 

search text in:





Poll
Which linux distribution do you use?







poll results



Last additions:
Disable Anti-Aliasing fonts

Disable Anti-Aliasing fonts

words:

186

views:

8266

userrating:

no votes yet


May 25th. 2007:
Words

491

Views

9600

why adblockers are bad


handy one-liners for sed (Unix stream editor)
Tutorial:

handy one-liners for sed (Unix stream editor)

words:

4078

views:

25003

userrating:

no votes yet


rotating apache logfiles with cronolog

rotating apache logfiles with cronolog

words:

294

views:

9730

userrating:

no votes yet


Druckversion
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



to the forum.
:
:
other Ads
Stellenangebote
Stellenangebote
für Fach- und
Führungskräfte
www.nachoben.com
Other free services
toURL.org
Shorten long
URLs to short
links like
http://tourl.org/2
tourl.org
.
FeedCollector
Combine various newsfeeds to one customized webpage
www.feedcollector.org
.
Reverse DNS lookup
Find out which hostname(s)
resolve to a
given IP or other hostnames for the server
www.reversednslookup.org
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004 S&P Softwaredesign
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 23.7 ms
system status display