fssb icon indicating copy to clipboard operation
fssb copied to clipboard

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

Open dyatlov opened this issue 7 years ago • 7 comments

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

dyatlov avatar Dec 19 '16 19:12 dyatlov

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)

dyatlov avatar Dec 19 '16 19:12 dyatlov

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:

adtac avatar Dec 20 '16 05:12 adtac

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.

haydenflinner avatar Jan 18 '17 20:01 haydenflinner

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 avatar Jan 29 '17 18:01 adtac

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

adtac avatar Jan 29 '17 18:01 adtac

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 .

haydenflinner avatar Jan 31 '17 03:01 haydenflinner

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

adtac avatar Jan 31 '17 05:01 adtac