This is an archive of the discontinued LLVM Phabricator instance.

Adjust sanitizers for FreeBSD 64-bit inode update
ClosedPublic

Authored by dim on May 26 2017, 11:04 AM.

Details

Summary

Very recently, FreeBSD 12 has been updated to use 64-bit inode numbers:
https://svnweb.freebsd.org/changeset/base/318737. This entails many
user-visible changes, but for the sanitizers the modifications are
limited in scope:

  • The stat and lstat syscalls were removed, and should be replaced with calls to fstatat.
  • The getdents syscall was removed, and should be replaced with calls to getdirentries.
  • The layout of struct dirent was changed to accomodate 64-bit inode numbers, and a new d_off field was added.
  • The system header <sys/_types.h> now contains a macro __INO64 to determine whether the system uses 64-bit inode numbers.

I tested these changes on both FreeBSD 12.0-CURRENT (after r318959,
which adds the __INO64 macro), and FreeBSD 11.0-STABLE (which still
uses 32-bit inode numbers).

Diff Detail

Repository
rL LLVM

Event Timeline

dim updated this revision to Diff 100437.May 26 2017, 11:04 AM
dim created this revision.

I accidentally left a debugging aid in place. Remove it.

vitalybuka edited edge metadata.May 26 2017, 2:46 PM

Do we have public build bot for FreeBSD?

lib/sanitizer_common/sanitizer_linux.cc
240 ↗(On Diff #100437)

Is this going to work for older versions?

dim added a comment.May 26 2017, 3:40 PM

Do we have public build bot for FreeBSD?

No, unfortunately the one that used to exist has disappeared a long time ago. I cannot provide one myself, so I will see if there is something to be done in the FreeBSD infrastructure.

lib/sanitizer_common/sanitizer_linux.cc
240 ↗(On Diff #100437)

The fstatat syscall was added in 2008, in FreeBSD 8.0. That particular version is now unsupported for ~7 years, so it is safe to assume the syscall exists in any recent (and usable) version of FreeBSD. :)

The getdirentries syscall used below is much older, even.

This revision is now accepted and ready to land.Jun 1 2017, 2:29 PM
This revision was automatically updated to reflect the committed changes.

Why does this code live in a Linux file? Are there plans to split it out, rename?

I'm going to add there NetBSD in the near future.

dim added a comment.Jun 3 2017, 4:47 AM

Why does this code live in a Linux file? Are there plans to split it out, rename?

I guess because at that time it was easiest to add it with #ifdefs? At some point the ifdef maze will become too large, and then it will make sense to split it out, like the Mac and Windows versions.

In D33600#772087, @dim wrote:

Why does this code live in a Linux file? Are there plans to split it out, rename?

I guess because at that time it was easiest to add it with #ifdefs? At some point the ifdef maze will become too large, and then it will make sense to split it out, like the Mac and Windows versions.

There is also an option to rename it to something generic like "posix". For now I will add NetBSD ifdefs and we will evaluate afterwards.