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

What if after I created a file I list directory contents? #3

Open
dyatlov opened this issue Dec 19, 2016 · 7 comments
Open

What if after I created a file I list directory contents? #3

dyatlov opened this issue Dec 19, 2016 · 7 comments

Comments

@dyatlov
Copy link

dyatlov commented Dec 19, 2016

Sorry, I didn't run your program in real but I suspect that this behavior exists.

@dyatlov
Copy link
Author

dyatlov commented Dec 19, 2016

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)

@adtac
Copy link
Owner

adtac commented Dec 20, 2016

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 👍

@haydenflinner
Copy link

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.

@adtac
Copy link
Owner

adtac commented Jan 29, 2017

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.

@adtac
Copy link
Owner

adtac commented Jan 29, 2017

@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 :)

@haydenflinner
Copy link

haydenflinner commented Jan 31, 2017 via email

@adtac
Copy link
Owner

adtac commented Jan 31, 2017

strace was the inspiration for fssb in the first place :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants