getdents()函数 Unix/Linux

getdents - 获得目录项


#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);


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 pointed at by fd into the memory area pointed to by dirp. The parameter count is the size of the memory area.

The dirent structure is declared as follows:

struct dirent {
    long d_ino;                 /* inode number */
    off_t d_off;                /* offset to next dirent */
    unsigned short d_reclen;    /* length of this dirent */
    char d_name [NAME_MAX+1];   /* filename (null-terminated) */

d_ino is an inode number. d_off is the distance from the start of the directory to the start of the next direntd_reclen is the size of this entire direntd_name is a null-terminated filename.

This call supersedes readdir(2).


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.


标签 描述
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.
  File descriptor does not refer to a directory.




Glibc does not provide a wrapper for this system call; call it using syscall(2).


getdents 函数 Unix Linux getdent 在线教程
1 getdents()函数 Unix/Linux getdents - 获得目录项 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 no
2 msgop()函数 Unix/Linux msgop - 消息操作 SYNOPSIS #include sys/types.h#include sys/ipc.h#include sys/msg.h int msgsnd(int msqid , const void * msgp , size_t msgsz , int msgflg ); ssize_t msgrcv(int msqid , void * msgp , size_t msgsz , long msgtyp , int msgflg
3 get_robust_list()函数 Unix/Linux get_robust_list, set_robust_list - 获取/设置强健futexes的清单 SYNOPSIS #include linux/futex.h #include syscall.h long get_robust_list(int pid , struct robust_list_head ** head_ptr , size_t * long set_robust_list(struct robust_list_
4 mincore()函数 Unix/Linux mincore - 得到的页面是否在核心信息 SYNOPSIS #include unistd.h #include sys/mman.h int mincore(void * start , size_t length , unsigned char * vec ); DESCRIPTION The mincore () function requests a vector describing which pages of
5 arch_prctl()函数 Unix/Linux 名称 arch_prctl - 设置架构特定的线程状态 内容简介 #include asm/prctl.h #include sys/prctl.h int arch_prctl(int code, unsigned long addr) 描述 arch_prctl () 函数设置架构的具体进程或线程状态。代码选择一个
6 _newselect()函数 Unix/Linux select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - 同步I / O复用 SYNOPSIS /* According to POSIX.1-2001 */ #include sys/select.h /* According to earlier standards */ #include sys/time.h #include sys/types.h #include unistd.h int select
7 Unix/Linux系统调用 Unix/Linux的系统调用的手册页(联机帮助)列表,本UNIX教程包含:Unix Bourne Shell编程,实用工具,文件系统,目录,内存管理,特殊变量的完整的知识,vi编辑器,进程等
8 move_pages()函数 Unix/Linux move_pages - 移动一组的处理的页面不同的NUMA节点 SYNOPSIS #include syscall.h long move_pages(pid_t pid , unsigned long nr_pages , const void ** address , const int * nodes , int * status , int flags ); DESCRIPTION move_pages 移
9 adjtimex()函数 Unix/Linux NAME adjtimex - 调内核时钟 SYNOPSIS #include sys/timex.h int adjtimex(struct timex * buf ); DESCRIPTION Linux使用大卫L. Mills的时钟调整算法(参见RFC1305)。adjtimex()系统调用读取和任选设置该算法的调整参数
10 posix_fadvise()函数 Unix/Linux posix_fadvise - 预先声明对文件数据的访问模式 SYNOPSIS #define _XOPEN_SOURCE 600 #include fcntl.h int posix_fadvise(int fd , off_t offset , off_t len , int advice ); DESCRIPTION 程序可以使用 posix_fadvise () 公布的意图
  • Copyright © 2021 猿狮院, All rights reserved.