| 28 | } |
| 29 | |
| 30 | static int count_dir_entries(const char *dirname) |
| 31 | { |
| 32 | DIR *dir = opendir(dirname); |
| 33 | int len = 0; |
| 34 | struct dirent *d; |
| 35 | if (!dir) |
| 36 | return 0; |
| 37 | |
| 38 | while ((d = readdir(dir))) { |
| 39 | /* |
| 40 | * Besides skipping over "." and "..", we also need to |
| 41 | * skip over other files that have a leading ".". This |
| 42 | * is due to behaviour of NFS, which will rename files |
| 43 | * to ".nfs*" to emulate delete-on-last-close. |
| 44 | * |
| 45 | * In any case this should be fine as the reftable |
| 46 | * library will never write files with leading dots |
| 47 | * anyway. |
| 48 | */ |
| 49 | if (starts_with(d->d_name, ".")) |
| 50 | continue; |
| 51 | len++; |
| 52 | } |
| 53 | closedir(dir); |
| 54 | return len; |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | * Work linenumber into the tempdir, so we can see which tests forget to |