#, fuzzy msgid "" msgstr "" "Project-Id-Version: man-pages-l10n VERSION\n" "POT-Creation-Date: 2014-07-17 17:53+0900\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: man-pages/man2/getdents.2:30 #, no-wrap msgid "GETDENTS" msgstr "" #. type: TH #: man-pages/man2/getdents.2:30 #, no-wrap msgid "2012-08-03" msgstr "" #. type: TH #: man-pages/man2/getdents.2:30 #, no-wrap msgid "Linux" msgstr "" #. type: TH #: man-pages/man2/getdents.2:30 #, no-wrap msgid "Linux Programmer's Manual" msgstr "" #. type: SH #: man-pages/man2/getdents.2:31 #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:33 msgid "getdents - get directory entries" msgstr "" #. type: SH #: man-pages/man2/getdents.2:33 #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:37 #, no-wrap msgid "" "BIB<, struct linux_dirent *>IB<,>\n" "B< unsigned int >IB<);>\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:41 msgid "I: There is no glibc wrapper for this system call; see NOTES." msgstr "" #. type: SH #: man-pages/man2/getdents.2:41 #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:47 msgid "" "This is not the function you are interested in. Look at B(3) for " "the POSIX conforming C library interface. This page documents the bare " "kernel system call interface." msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:60 msgid "" "The system call B() reads several I structures from " "the directory referred to by the open file descriptor I into the buffer " "pointed to by I. The argument I specifies the size of that " "buffer." msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:64 msgid "The I structure is declared as follows:" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:79 #, no-wrap msgid "" "struct linux_dirent {\n" " unsigned long d_ino; /* Inode number */\n" " unsigned long d_off; /* Offset to next I */\n" " unsigned short d_reclen; /* Length of this I */\n" " char d_name[]; /* Filename (null-terminated) */\n" " /* length is actually (d_reclen - 2 -\n" " offsetof(struct linux_dirent, d_name)) */\n" " /*\n" " char pad; // Zero padding byte\n" " char d_type; // File type (only since Linux\n" " // 2.6.4); offset is (d_reclen - 1)\n" " */\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:81 #, no-wrap msgid "}\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:94 msgid "" "I is an inode number. I is the distance from the start of the " "directory to the start of the next I. I is the size " "of this entire I. I is a null-terminated filename." msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:99 msgid "" "I is a byte at the end of the structure that indicates the file type." " It contains one of the following values (defined in Idirent.hE>):" "" msgstr "" #. type: TP #: man-pages/man2/getdents.2:99 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:102 msgid "This is a block device." msgstr "" #. type: TP #: man-pages/man2/getdents.2:102 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:105 msgid "This is a character device." msgstr "" #. type: TP #: man-pages/man2/getdents.2:105 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:108 msgid "This is a directory." msgstr "" #. type: TP #: man-pages/man2/getdents.2:108 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:111 msgid "This is a named pipe (FIFO)." msgstr "" #. type: TP #: man-pages/man2/getdents.2:111 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:114 msgid "This is a symbolic link." msgstr "" #. type: TP #: man-pages/man2/getdents.2:114 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:117 msgid "This is a regular file." msgstr "" #. type: TP #: man-pages/man2/getdents.2:117 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:120 msgid "This is a UNIX domain socket." msgstr "" #. type: TP #: man-pages/man2/getdents.2:120 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:123 msgid "The file type is unknown." msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:133 msgid "" "The I field is implemented since Linux 2.6.4. It occupies a space " "that was previously a zero-filled padding byte in the I " "structure. Thus, on kernels before 2.6.3, attempting to access this field " "always provides the value 0 (B)." msgstr "" #. kernel 2.6.27 #. The same sentence is in readdir.2 #. type: Plain text #: man-pages/man2/getdents.2:142 msgid "" "Currently, only some filesystems (among them: Btrfs, ext2, ext3, and ext4) " "have full support for returning the file type in I. All " "applications must properly handle a return of B." msgstr "" #. type: SH #: man-pages/man2/getdents.2:142 #, no-wrap msgid "RETURN VALUE" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:148 msgid "" "On success, the number of bytes read is returned. On end of directory, 0 is " "returned. On error, -1 is returned, and I is set appropriately." msgstr "" #. type: SH #: man-pages/man2/getdents.2:148 #, no-wrap msgid "ERRORS" msgstr "" #. type: TP #: man-pages/man2/getdents.2:149 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:153 msgid "Invalid file descriptor I." msgstr "" #. type: TP #: man-pages/man2/getdents.2:153 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:156 msgid "Argument points outside the calling process's address space." msgstr "" #. type: TP #: man-pages/man2/getdents.2:156 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:159 msgid "Result buffer is too small." msgstr "" #. type: TP #: man-pages/man2/getdents.2:159 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:162 msgid "No such directory." msgstr "" #. type: TP #: man-pages/man2/getdents.2:162 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:165 msgid "File descriptor does not refer to a directory." msgstr "" #. type: SH #: man-pages/man2/getdents.2:165 #, no-wrap msgid "CONFORMING TO" msgstr "" #. SVr4 documents additional ENOLINK, EIO error conditions. #. type: Plain text #: man-pages/man2/getdents.2:168 msgid "SVr4." msgstr "" #. type: SH #: man-pages/man2/getdents.2:168 #, no-wrap msgid "NOTES" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:177 msgid "" "Glibc does not provide a wrapper for this system call; call it using " "B(2). You will need to define the I structure " "yourself. However, you probably want to use B(3) instead." msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:180 msgid "This call supersedes B(2)." msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:193 msgid "" "The original Linux B() system call did not handle large " "filesystems and large file offsets. Consequently, Linux 2.4 added " "B(), with wider types for the I and I fields " "employed in the I structure." msgstr "" #. type: SH #: man-pages/man2/getdents.2:193 #, no-wrap msgid "EXAMPLE" msgstr "" #. FIXME: This program uses the older getdents() system call #. and the structure with smaller field widths. #. type: Plain text #: man-pages/man2/getdents.2:200 msgid "" "The program below demonstrates the use of B(). The following " "output shows an example of what we see when running this program on an ext2 " "directory:" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:213 #, no-wrap msgid "" "$B< ./a.out /testfs/>\n" "--------------- nread=120 ---------------\n" "i-node# file type d_reclen d_off d_name\n" " 2 directory 16 12 .\n" " 2 directory 16 24 ..\n" " 11 directory 24 44 lost+found\n" " 12 regular 16 56 a\n" " 228929 directory 16 68 sub\n" " 16353 directory 16 80 sub2\n" " 130817 directory 16 4096 sub3\n" msgstr "" #. type: SS #: man-pages/man2/getdents.2:215 #, no-wrap msgid "Program source" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:226 #, no-wrap msgid "" "#define _GNU_SOURCE\n" "#include Edirent.hE /* Defines DT_* constants */\n" "#include Efcntl.hE\n" "#include Estdio.hE\n" "#include Eunistd.hE\n" "#include Estdlib.hE\n" "#include Esys/stat.hE\n" "#include Esys/syscall.hE\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:229 #, no-wrap msgid "" "#define handle_error(msg) \\e\n" " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:236 #, no-wrap msgid "" "struct linux_dirent {\n" " long d_ino;\n" " off_t d_off;\n" " unsigned short d_reclen;\n" " char d_name[];\n" "};\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:238 #, no-wrap msgid "#define BUF_SIZE 1024\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:247 #, no-wrap msgid "" "int\n" "main(int argc, char *argv[])\n" "{\n" " int fd, nread;\n" " char buf[BUF_SIZE];\n" " struct linux_dirent *d;\n" " int bpos;\n" " char d_type;\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:251 #, no-wrap msgid "" " fd = open(argc E 1 ? argv[1] : \".\", O_RDONLY | O_DIRECTORY);\n" " if (fd == -1)\n" " handle_error(\"open\");\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:256 #, no-wrap msgid "" " for ( ; ; ) {\n" " nread = syscall(SYS_getdents, fd, buf, BUF_SIZE);\n" " if (nread == -1)\n" " handle_error(\"getdents\");\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:259 #, no-wrap msgid " if (nread == 0)\n" " break;\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:278 #, no-wrap msgid "" " printf(\"--------------- nread=%d ---------------\\en\", nread);\n" " printf(\"i-node# file type d_reclen d_off d_name\\en\");\n" " for (bpos = 0; bpos E nread;) {\n" " d = (struct linux_dirent *) (buf + bpos);\n" " printf(\"%8ld \", d-Ed_ino);\n" " d_type = *(buf + bpos + d-Ed_reclen - 1);\n" " printf(\"%-10s \", (d_type == DT_REG) ? \"regular\" :\n" " (d_type == DT_DIR) ? \"directory\" :\n" " (d_type == DT_FIFO) ? \"FIFO\" :\n" " (d_type == DT_SOCK) ? \"socket\" :\n" " (d_type == DT_LNK) ? \"symlink\" :\n" " (d_type == DT_BLK) ? \"block dev\" :\n" " (d_type == DT_CHR) ? \"char dev\" : \"???\");\n" " printf(\"%4d %10lld %s\\en\", d-Ed_reclen,\n" " (long long) d-Ed_off, d-Ed_name);\n" " bpos += d-Ed_reclen;\n" " }\n" " }\n" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:281 #, no-wrap msgid " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: SH #: man-pages/man2/getdents.2:282 #, no-wrap msgid "SEE ALSO" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:285 msgid "B(2), B(3)" msgstr "" #. type: SH #: man-pages/man2/getdents.2:285 #, no-wrap msgid "COLOPHON" msgstr "" #. type: Plain text #: man-pages/man2/getdents.2:293 msgid "" "This page is part of release 3.70 of the Linux I project. A " "description of the project, information about reporting bugs, and the latest " "version of this page, can be found at \\%http://www.kernel.org/doc/man-pages/" "." msgstr ""