add mockedFiles to directory listing commands
Opened this issue · 0 comments
matthandlersux commented
when a script attempts to list items in a directory that has mockedFiles
, we should intercept the syscalls responsible for that and include the mocked files in the response(s).
for example: in ruby, if i do Dir.glob("/foo/*")
i get the following (truncated) debug output:
807: Open(filename: "/tmp/test.8MzdhLsx0kws/file") -> 11
807: Fcntl(fd: 11, cmd: F_SETFL) -> 0
807: Fstat(fd: 11) -> 0
807: Fstat(fd: 11) -> 0
807: Ioctl() -> ENOTTY: Not a typewriter
807: Read(fd: 11) -> 20
807: Read(fd: 11) -> 0
807: Close(fd: 11) -> 0
807: Lstat() -> 0
807: Lstat() -> 0
807: Lstat() -> 0
807: Open(filename: "/foo") -> 11
807: Fstat(fd: 11) -> 0
807: Getdents() -> 576
807: Getdents() -> 264
807: Getdents() -> 0
807: Close(fd: 11) -> 0
807: Rt_sigaction() -> 0
807: Rt_sigaction() -> 0
807: Close(fd: 8) -> 0
807: Close(fd: 10) -> 0
807: Munmap() -> 0
i believe Fstat and Getdents are the two calls we need to intercept in order to make this work.