Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fstat on pipes #3319

Open
stevenengler opened this issue Apr 1, 2024 · 0 comments
Open

Support fstat on pipes #3319

stevenengler opened this issue Apr 1, 2024 · 0 comments
Labels
Status: Help Wanted Well suited for community contributions Type: Enhancement New functionality or improved design

Comments

@stevenengler
Copy link
Contributor

stevenengler commented Apr 1, 2024

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:

  1. Fill in the correct syscall arguments in SyscallHandler::fstat in src/main/host/syscall/handler/file.rs.
  2. Figure out what the struct stat equivalent is in the linux kernel, and create bindings for it in linux-api library.
  3. Figure out what values to return for each field in struct stat.
  4. Add fstat syscall 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.

@stevenengler stevenengler added Type: Enhancement New functionality or improved design Status: Help Wanted Well suited for community contributions labels Apr 1, 2024
@stevenengler stevenengler added this to the Support missing syscalls milestone Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Help Wanted Well suited for community contributions Type: Enhancement New functionality or improved design
Projects
None yet
Development

No branches or pull requests

1 participant