MAN getdents 2
Материал из Gentoo Linux Wiki
- Вернуться в раздел мануалов
Содержание |
[править] Имя
getdents - получить записи каталога
[править] Обзор
#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 );
[править] Описание
Эта не та функция, которая должна представлять для вас интерес. Смотрите функцию readdir (3), которая является интерфейсом библиотеки языка C, соответствующим стандарту POSIX.
Системный вызов getdents читает несколько структур dirent из каталога, на который указывает fd в область памяти, на которую указывает dirp . Параметр count является размером этой области памяти.
Структура dirent определена следующим образом:
struct dirent {
long d_ino; /* номер inode */ off_t d_off; /* смещение до следущей dirent */ unsigned short d_reclen; /* длина данной dirent */ char d_name [NAME_MAX+1]; /* имя файла (завершаемое нулём) */
}
d_ino
является номером индексного дескриптора (inode).
d_off
является дистанцией от начала данного каталога до начала следующей
структуры
dirent .
d_reclen
является размером данной структуры
dirent .
d_name
является именем файла, которое завершается нулевым символом.
Данный вызов замещает readdir (2).
[править] Возвращаемое значение
В случае успеха возвращается количество прочитанных байт. При достижении конца каталога возвращается 0. В случае ошибки возвращается -1 и значение errno устанавливается соответствующим образом.
[править] Ошибки
EBADF Неправильный файловый дескриптор fd . EFAULT Аргумент указывает за пределы адресного пространства, вызывающего процесса.
EINVAL Буфер результата слишком мал.
ENOENT Нет такого каталога.
ENOTDIR Файловый дескриптор не указывает на каталог.
[править] Соответствие стандартам
SVr4, SVID. SVr4 документирует дополительные ошибки ENOLINK, EIO.
[править] Смотри также
[править] Перевод
Перевёл с английского Виктор Вислобоков <corochoone@perm.ru> 2004
[править] Комментарии к man файлу
Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one
Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date. The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein. The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
professionally.
Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.
Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
Modified 22 July 1995 by Michael Chastain <mec@duracef.shout.net>:
Derived from 'readdir.2'.
Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
Дата последней коррекции перевода 09.06.2004
Перевод с английского сделал Виктор Вислобоков <corochoone@perm.ru>
http://www.linuxshare.ru/projects/trans/mans.html
