diff options
author | Jean-Pierre André <jpandre@users.noreply.github.com> | 2021-03-18 10:52:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 09:52:30 +0000 |
commit | bdd2d4110fbc6d2059eb699efad2cca4a7eacccb (patch) | |
tree | 62ca0ce9b94529a68e376922963993606af2f35a /test/readdir_inode.c | |
parent | 77d662459a0fcdf358d515477d33795837e859d5 (diff) | |
download | libfuse-bdd2d4110fbc6d2059eb699efad2cca4a7eacccb.tar.gz |
Fix returning d_ino and d_type by readdir(3) in non-plus mode
When not using the readdir_plus mode, the d_type was not returned,
and the use_ino flag was not used for returning d_ino.
This patch fixes the returned values for d_ino and d_type by readdir(3)
The test for the returned value of d_ino has been adjusted to also
take the d_type into consideration and to check the returned values in
both basic readdir and readdir_plus modes. This is done by executing
the passthrough test twice.
Co-authored-by: Jean-Pierre André <jpandre@users.sourceforge.net>
Diffstat (limited to 'test/readdir_inode.c')
-rw-r--r-- | test/readdir_inode.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/readdir_inode.c b/test/readdir_inode.c index 7f46c0a..99f95ff 100644 --- a/test/readdir_inode.c +++ b/test/readdir_inode.c @@ -1,7 +1,8 @@ /* - * Prints each directory entry and its inode as returned by 'readdir'. + * Prints each directory entry, its inode and d_type as returned by 'readdir'. * Skips '.' and '..' because readdir is not required to return them and - * some of our examples don't. + * some of our examples don't. However if they are returned, their d_type + * should be valid. */ #include <stdio.h> @@ -30,7 +31,18 @@ int main(int argc, char* argv[]) dent = readdir(dirp); while (dent != NULL) { if (strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0) { - printf("%llu %s\n", (unsigned long long)dent->d_ino, dent->d_name); + printf("%llu %d %s\n", (unsigned long long)dent->d_ino, + (int)dent->d_type, dent->d_name); + if ((long long)dent->d_ino < 0) + fprintf(stderr,"%s : bad d_ino %llu\n", + dent->d_name, (unsigned long long)dent->d_ino); + if ((dent->d_type < 1) || (dent->d_type > 15)) + fprintf(stderr,"%s : bad d_type %d\n", + dent->d_name, (int)dent->d_type); + } else { + if (dent->d_type != DT_DIR) + fprintf(stderr,"%s : bad d_type %d\n", + dent->d_name, (int)dent->d_type); } dent = readdir(dirp); } |