2 * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
13 main(int argc
, char** argv
)
16 DIR* dir
= opendir(".");
18 printf("first pass:\n");
20 dirent
= readdir(dir
);
24 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent
->d_dev
,
25 dirent
->d_ino
, dirent
->d_name
);
26 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);
30 printf("second pass:\n");
32 dirent
= readdir(dir
);
36 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent
->d_dev
,
37 dirent
->d_ino
, dirent
->d_name
);
38 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);
45 buf
= (struct dirent
*)malloc(sizeof(struct dirent
) + NAME_MAX
);
49 printf("first pass:\n");
51 if (readdir_r(dir
, buf
, &dirent
) != 0 || dirent
== NULL
)
54 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent
->d_dev
,
55 dirent
->d_ino
, dirent
->d_name
);
56 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);
60 printf("second pass:\n");
62 if (readdir_r(dir
, buf
, &dirent
) != 0 || dirent
== NULL
)
65 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent
->d_dev
,
66 dirent
->d_ino
, dirent
->d_name
);
67 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);