.\" 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 .\" Modified 22 July 1995 by Michael Chastain : .\" Derived from 'readdir.2'. .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond .\" .\" Дата последней коррекции перевода 09.06.2004 .\" Перевод с английского сделал Виктор Вислобоков .\" http://www.linuxshare.ru/projects/trans/mans.html .\" .TH GETDENTS 2 1995-07-22 "Linux 1.3.6" "Руководство программиста Linux" .SH ИМЯ getdents \- получить записи каталога .SH ОБЗОР .nf .B #include .B #include .B #include .B #include .sp .B _syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count); .sp .BI "int getdents(unsigned int " fd ", struct dirent *" dirp ", unsigned int " count ); .fi .SH ОПИСАНИЕ Эта не та функция, которая должна представлять для вас интерес. Смотрите функцию .BR readdir (3), которая является интерфейсом библиотеки языка C, соответствующим стандарту POSIX. .PP Системный вызов .B getdents читает несколько структур .I dirent из каталога, на который указывает .I fd в область памяти, на которую указывает .IR dirp . Параметр .I count является размером этой области памяти. .PP Структура .I dirent определена следующим образом: .PP .RS .nf struct dirent { long d_ino; /* номер inode */ off_t d_off; /* смещение до следущей \fIdirent\fP */ unsigned short d_reclen; /* длина данной \fIdirent\fP */ char d_name [NAME_MAX+1]; /* имя файла (завершаемое нулём) */ } .fi .RE .PP .I d_ino является номером индексного дескриптора (inode). .I d_off является дистанцией от начала данного каталога до начала следующей структуры .IR dirent . .I d_reclen является размером данной структуры .IR dirent . .I d_name является именем файла, которое завершается нулевым символом. .PP Данный вызов замещает .BR readdir (2). .SH "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" В случае успеха возвращается количество прочитанных байт. При достижении конца каталога возвращается 0. В случае ошибки возвращается \-1 и значение .I errno устанавливается соответствующим образом. .SH ОШИБКИ .TP .B EBADF Неправильный файловый дескриптор .IR fd . .TP .B EFAULT Аргумент указывает за пределы адресного пространства, вызывающего процесса. .TP .B EINVAL Буфер результата слишком мал. .TP .B ENOENT Нет такого каталога. .TP .B ENOTDIR Файловый дескриптор не указывает на каталог. .SH "СООТВЕТСТВИЕ СТАНДАРТАМ" SVr4, SVID. SVr4 документирует дополительные ошибки ENOLINK, EIO. .SH "СМОТРИ ТАКЖЕ" .BR readdir (2), .BR readdir (3) .SH ПЕРЕВОД Перевёл с английского Виктор Вислобоков 2004