Page MenuHomePhabricator

FileSystem: Check for DTTOIF alone, not _DIRENT_HAVE_D_TYPE

Authored by jordan_rose on Jul 18 2019, 11:58 AM.



While d_type is a non-standard extension to struct dirent, only glibc signals its presence with another macro _DIRENT_HAVE_D_TYPE. However, any platform with d_type also includes a way to convert to mode_t values using the macro DTTOIF, so we can check for that alone and still be confident that the d_type member exists.

(If this turns out to be wrong, I'll go back and set up an actual CMake check.)

I couldn't think of how to write a test for this, because I couldn't think of how to test that a stat call doesn't happen without controlling the filesystem or intercepting stat, and there's no good cross-platform way to do that that I know of.

Follow-up (almost a year later) to D51918.


Diff Detail


Event Timeline

jordan_rose created this revision.Jul 18 2019, 11:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2019, 11:58 AM
sammccall accepted this revision.Jul 18 2019, 12:22 PM

Thanks for the detailed comment, and apologies for missing this case the first time around.

As noted previously, if this check isn't sufficient, than we'll fail to compile, so it shouldn't go unnoticed.

This revision is now accepted and ready to land.Jul 18 2019, 12:22 PM
jordan_rose closed this revision.Jul 18 2019, 1:42 PM

Committed as rL366486.