fssb
fssb copied to clipboard
What if after I created a file I list directory contents?
Sorry, I didn't run your program in real but I suspect that this behavior exists.
Like (pseudo code):
Print("creating a file..") Create("file.dat") Print("now we have these files in our dir:") Let files = Readdir("./") For (f in files) Print(f)
Indeed, the file wouldn't be listed there. I have a rough solution that might solve this (that is return as if the file exists).
Anyway, thanks for bringing this to my notice! I'll work on it soon :+1:
Curious as to what the rough solution is. I'm uninformed, but I would think just creating the path that they asked for as a phantom path in the sandbox would be a good solution.
So linux uses a sycall called getdents
to get directory listings. The function prototype is like this:
int getdents(unsigned int fd, struct linux_dirent *dirp,
unsigned int count);
dirp
is a pointer to an array of directory entries. The number of entries is given by the return value. So we simply add another entry to the array (we'll probably have space to do this - count
contains the size of the dirp
buffer and it's usually very large. So we can probably get away with creating another element after the last element).
Much more difficult than other syscalls indeed.
@haydenflinner take a look at man -s 2 getdents
to know more. I found this out by running strace ls
and looking at what exactly retrieves the file list :)
strace was an interesting rabbit hole to go down, thank you!
Hayden D. Flinner Computer Science Georgia Institute of Technology '18
On Sun, Jan 29, 2017 at 1:23 PM, Adhityaa Chandrasekar < [email protected]> wrote:
@haydenflinner https://github.com/haydenflinner take a look at man -s 2 getdents to know more. I found this out by running strace ls and looking at what exactly retrieves the file list :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adtac/fssb/issues/3#issuecomment-275934400, or mute the thread https://github.com/notifications/unsubscribe-auth/AOKFbHaSRhpEqX7WGowfKsPgKbQzyawTks5rXNk7gaJpZM4LRGLs .
strace
was the inspiration for fssb
in the first place :P