On 2/5/24 22:13, Dave Chinner wrote:
On Mon, Feb 05, 2024 at 02:12:43PM +0100, Donald Buczek wrote:
On 2/4/24 22:56, Dave Chinner wrote:
On Sat, Feb 03, 2024 at 06:50:31PM +0100, Donald Buczek wrote:
Dear Experts,
I'm encountering consistent build failures with the Zig
language from source on certain systems, and I'm seeking
insights into the issue.
The reason for this difference seems obvious: there's a distinct
lack of stat() calls in the ftype=0 (bad) case. dirent->d_type in
this situation will be reporting DT_UNKNOWN for all entries except
'.' and '..'. It is the application's responsibility to handle this,
as the only way to determine if a DT_UNKNOWN entry is a directory is
to stat() the pathname and look at the st_mode returned.
You've nailed it. [1][2]
I'll take this over to the zig community.
Thanks!
Donald
[1]: https://github.com/ziglang/zig/blob/39ec3d311673716e145957d6d81f9d4ec7848471/lib/std/fs/Dir.zig#L372
[2]: https://github.com/ziglang/zig/blob/39ec3d311673716e145957d6d81f9d4ec7848471/lib/std/fs/Dir.zig#L669
The code is clearly not doing this, and so I'm guessing that the zig
people have rolled their own nftw() function and didn't pay
attention to the getdents() man page:
Currently, only some filesystems (among them: Btrfs, ext2,
ext3, and ext4) have full support for returning the file
type in d_type. All applications must properly handle a
return of DT_UNKNOWN.
So, yeah, looks like someone didn't read the getdents man page
completely and it's not a filesystem issue.
-Dave.
--
Donald Buczek
buczek@xxxxxxxxxxxxx
Tel: +49 30 8413 1433