Closed illwieckz closed 4 months ago
The code does:
struct dirent* ep = readdir(dp);
[…]
const bool is_directory = (ep->d_type & DT_DIR) != 0;
const bool is_file = (ep->d_type & DT_REG) != 0;
If after that I add this line:
console::warning("is_directory: %d, is_file: %d, %s", is_directory, is_file, ep->d_name);
And I create a test folder and a test file:
touch test-file
mkdir test-directory
I get that on disk filesystem APFS:
Warning: is_directory: 0, is_file: 1, test-file
Warning: is_directory: 1, is_file: 0, test-directory
But I get that on network filesystem NFS:
Warning: is_directory: 0, is_file: 0, test-file
Warning: is_directory: 0, is_file: 0, test-directory
This test was done on macOS but it's probably the same problem I face on Linux with SSHFS.
On Linux the man of readdir
says:
In the glibc implementation, the dirent structure is defined as follows:
struct dirent {
ino_t d_ino; /* Inode number */
off_t d_off; /* Not an offset; see below */
unsigned short d_reclen; /* Length of this record */
unsigned char d_type; /* Type of file; not supported
by all filesystem types */
char d_name[256]; /* Null-terminated filename */
};
Especially the type of file is not supported by all filesystem types. It's probably the same one macOS…
I edited the logger this way:
console::warning("d_type: %d, is_directory: %d, is_file: %d, %s", ep->d_type, is_directory, is_file, ep->d_name);
And I get on APFS:
Warning: d_type: 8, is_directory: 0, is_file: 1, test-file
Warning: d_type: 4, is_directory: 1, is_file: 0, test-directory
and on NFS:
Warning: d_type: 0, is_directory: 0, is_file: 0, test-file
Warning: d_type: 0, is_directory: 0, is_file: 0, test-directory
So basically the feature is not supported at all…
Assumed to have been fixed by #41 long time ago:
Crunch fails to open files on NFS and SSHFS network file systems.
I verified it on both macOS and FreeBSD with NFS, and on Linux with SSHFS:
While it works on local filesystem:
We can notice the absolute file path is properly computed anyway.
On Windows the
crunch
command line tool properly open files stored on native CIFS network share, so that looks specific to Unix APIs and/or NFS storage.