-
Notifications
You must be signed in to change notification settings - Fork 268
Support fstat on pipes #3319
Copy link
Copy link
Closed
Labels
Status: Help WantedWell suited for community contributionsWell suited for community contributionsType: EnhancementNew functionality or improved designNew functionality or improved design
Milestone
Description
Shadow's fstat syscall handler is in C, which only supports RegularFiles. This means that fstat in shadow currently returns EBADF for pipes. Shadow should properly handle pipe fds in the fstat syscall handler. This is used by Python when the subprocess module executes programs.
strace python3 -c 'import subprocess; subprocess.run(["ls", "-l", "/dev/null"], capture_output=True)'pipe2([3, 4], O_CLOEXEC) = 0
pipe2([5, 6], O_CLOEXEC) = 0
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
To implement:
- Fill in the correct syscall arguments in
SyscallHandler::fstatinsrc/main/host/syscall/handler/file.rs. - Figure out what the
struct statequivalent is in the linux kernel, and create bindings for it in linux-api library. - Figure out what values to return for each field in
struct stat. - Add
fstatsyscall tests with pipes.
Note: The SYS_fstat syscall calls the kernel's sys_newfstat on x86-64, not sys_fstat: arch/x86/entry/syscalls/syscall_64.tbl#L16, which should be fs/stat.c#L475.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Status: Help WantedWell suited for community contributionsWell suited for community contributionsType: EnhancementNew functionality or improved designNew functionality or improved design