Page MenuHomeFreeBSD

libsysdecode/truss: linux stat syscalls
AbandonedPublic

Authored by yuripv on Oct 28 2019, 5:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 3, 2:42 AM
Unknown Object (File)
Tue, Oct 28, 10:28 PM
Unknown Object (File)
Sun, Oct 26, 4:39 AM
Unknown Object (File)
Thu, Oct 16, 10:30 AM
Unknown Object (File)
Oct 4 2025, 1:34 AM
Unknown Object (File)
Aug 12 2025, 2:19 PM
Unknown Object (File)
Aug 8 2025, 5:51 AM
Unknown Object (File)
Jul 22 2025, 10:54 AM

Details

Reviewers
jhb
Summary
  • libsysdecode: decode LINUX_AT_* flags
  • truss: decode l_newstat and l_stat64 structures; the best way to do this that I could think of is unrolling the definitions in newly added linux.h (some linux definitions were moved there as well from syscall.h)
Test Plan

Build-tested on aarch64, amd64, and i386. Run-tested on amd64, both 32 and 64 bit linux binaries.

Sample output:

$ truss ./l32 2>&1 | grep stat
linux_fstat64(3,{ mode=-rw-r--r-- ,inode=156918,size=50346,blksize=50688 }) = 0 (0x0)
linux_fstat64(3,{ mode=-rwxr-xr-x ,inode=47786,size=2107464,blksize=131072 }) = 0 (0x0)
linux_newstat("/etc/sysconfig/64bit_strstr_via_64bit_strstr_sse2_unaligned",0xffffb640) ERR#-2 'No such file or directory'
linux_fstatat64(3,"/COPYRIGHT",{ mode=-r--r--r-- ,inode=1025,size=6174,blksize=6656 },LINUX_AT_SYMLINK_NOFOLLOW) = 0 (0x0)
linux_fstat64(1,{ mode=p--------- ,inode=1291598,size=0,blksize=4096 }) = 0 (0x0)
$ truss ./l64 2>&1 | grep stat
linux_newfstat(3,{ mode=-rw-r--r-- ,inode=156918,size=50346,blksize=50688 }) = 0 (0x0)
linux_newfstat(3,{ mode=-rwxr-xr-x ,inode=80791,size=2156160,blksize=131072 }) = 0 (0x0)
linux_newfstatat(3,"/COPYRIGHT",{ mode=-r--r--r-- ,inode=1025,size=6174,blksize=6656 },LINUX_AT_SYMLINK_NOFOLLOW) = 0 (0x0)
linux_newfstat(1,{ mode=p--------- ,inode=1291600,size=0,blksize=4096 }) = 0 (0x0)

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

lib/libsysdecode/flags.c
74

Otherwise /usr/include/sysdecode.h was used.

usr.bin/truss/Makefile
11

Otherwise /usr/include/sysdecode.h was used.

lib/libsysdecode/flags.c
74

That should not matter during buildworld since buildworld installs the new sysdecode.h to the sysroot.

264

Is it not possible to build this table automatically by matching on the LINUX_AT_* pattern in mktables?

lib/libsysdecode/sysdecode.h
132

I'd rather sort this into the existing prototypes.

usr.bin/truss/Makefile
11

Again, should not fail during a buildworld.

usr.bin/truss/linux.h
126

Perhaps put #ifdef's in syscalls.c instead for the uses? If there are multiple places to have the list, you could have a LINUX_STAT macro that each arch defines in it's #if clause above and make the code in syscalls.c conditional on #ifdef LINUX_STAT so that only linux.h has to change if a new platform gains Linux support in the future.