Steps to reproduce:
./fuse z80 in the build directory)Expected result:
A vaguely helpful error message telling you that you tried to open a directory.
Actual result:
./fuse: error: error reading file: expected 4096 bytes, but read only 0
./fuse: error initialising -- giving up!
(The "expected" obviously varies with the size of the directory on disk)
Patch proposal with a message good enough to me:
I see two problems with this patch:
1) The access() call is unnecessary. If the user has no access to the file then the stat() call will fail anyway, producing the expected result.
2) If there's an error the calling function prints a message based on the value of errno, but S_ISREG() doesn't set errno upon failure, so you get undefined behaviour.
Alternative for the second problem: set errno yourself to EINVAL or something like that before returning 0 if S_ISREG() fails.
Another alternative, possibly better, is to get rid of the compat_file_exists() call that you have in this patch add that S_ISREG() logic to compat_file_open(). That function should only open regular files, or is there any case in which that function needs to open anything else?
Thanks. Your proposal is better. I think compat_file_open() should open only files. Pipes (e.g. --rs232-rx) are handled in other way. Patch attached.
Looks good to me!
Thanks all. Committed in [d9ce57].
Related
Commit: [d9ce57]