13 #include <linux/unistd.h>
17 static _syscall3(long, getdents64, uint, fd, struct dirent64 *, dirp, uint, count);
19 int main(int argc,char **argv)
24 fprintf(stderr,"Required directory name argument!\n");
27 if (-1==(fd=open(argv[1],O_RDONLY /* |O_DIRECTORY */))) {
28 fprintf(stderr,"open(\"%s\"): %m\n",argv[1]);
34 struct dirent64 *dirent64;
37 if ((off_t)-1==(off=lseek(fd,0,SEEK_CUR))) {
38 fprintf(stderr,"lseek(): %m\n");
41 printf("@=%lld\n",(long long)off);
42 memset(buf,0,sizeof(buf));
43 got=getdents64(fd,(void *)buf,sizeof(buf));
44 printf("got=%d\n",got);
47 assert(got<=sizeof(buf));
52 (char *)dirent64<buf+got;
53 dirent64=(void *)((char *)dirent64+dirent64->d_reclen)
55 printf("dirent64_rel=%d, d_off=0x%llx; d_ino=%llu, d_reclen=%u, d_type=%u, d_name=%s\n",
57 (long long)dirent64->d_off,(unsigned long long)dirent64->d_ino,
58 (unsigned)dirent64->d_reclen,
59 (unsigned)dirent64->d_type,dirent64->d_name);
61 printf("trailing=%d\n",(buf+got)-(char *)dirent64);