getdents

Autres langues

Langue: pl

Autres versions - même langue

Version: 1995-07-22 (fedora - 25/11/07)

Section: 2 (Appels système)

NAZWA

getdents - pobranie wpisów z katalogu

SKŁADNIA

 #include <unistd.h>
 #include <linux/types.h>
 #include <linux/dirent.h>
 #include <linux/unistd.h>
 
 _syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count);
 
 int getdents(unsigned int fd, struct dirent *dirp, unsigned int count);
 

OPIS

getdents odczytuje kolejne struktury dirent z katalogu wskazywanego przez fd do obszaru pamięci wskazywanego przez dirp. Parametr count jest rozmiarem obszaru pamięci.

Struktura dirent jest zadeklarowana następująco:

 struct dirent
 {
     long d_ino;                 /* numer i-węzła */
     off_t d_off;                /* offset do następnego dirent */
     unsigned short d_reclen;    /* długość tego dirent */
     char d_name [NAZWA_MAX+1];   /* nazwa pliku (zakończona NUL) */
 }
 

d_ino jest numerem i-węzła. d_off jest odległością od początku katalogu do początku następnej struktury dirent. d_reclen jest wielkością tej całej struktury dirent. d_name jest nazwą pliku zakończoną znakiem NUL.

Ta funkcja zastępuje readdir(2).

WARTOŚĆ ZWRACANA

Po pomyślnym zakończeniu zwracana jest ilość odczytanych bajtów. Na końcu katalogu zwracane jest 0. Przy błędzie zwracane jest -1 i odpowiednio ustawiane errno.

BŁĘDY

EBADF
Nieprawidłowy deskryptor pliku fd.
EFAULT
Argument wskazuje poza przestrzeń adresową wywołującego procesu.
EINVAL
Bufor wynikowy jest za mały.
ENOENT
Nie ma takiego katalogu.
ENOTDIR
Deskryptor pliku nie odnosi się do katalogu.

ZGODNE Z

SVr4, SVID. SVr4 dokumentuje dodatkowe błędy ENOLINK, EIO.

ZOBACZ TAKŻE

readdir(2), readdir(3)