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

Fix "No such file or directory" when launched with empty fd 0. #55

Merged
merged 1 commit into from
Mar 29, 2021

Conversation

kevin-vigor
Copy link
Collaborator

If any of the first three file descriptors are closed when squashfuse is
launched, it will get a fd <= 2 when it opens the squashfs image file.

Unfortunately fuse_daemonize() from libfuse unconditionally clobbers fds 0-2
by dup2-ing /dev/null over them. This made the squashfuse image inaccessible
and things went very poorly.

Fix by simply making sure fds 0-2 are open before calling sqfs_ll_open() so
it is guaranteed to get a safe fd.

Reproduction (previously failed with "No such file or directory", now
succeeds):
0<&- squashfuse_ll fs.image /tmp/crap
ls /tmp/crap

If any of the first three file descriptors are closed when squashfuse is
launched, it will get a fd <= 2 when it opens the squashfs image file.

Unfortunately fuse_daemonize() from libfuse unconditionally clobbers fds 0-2
by dup2-ing /dev/null over them. This made the squashfuse image inaccessible
and things went very poorly.

Fix by simply making sure fds 0-2 are open before calling sqfs_ll_open() so
it is guaranteed to get a safe fd.

Reproduction (previously failed with "No such file or directory", now
succeeds):
0<&- squashfuse_ll fs.image /tmp/crap
ls /tmp/crap
@vasi vasi merged commit 174a0d6 into vasi:master Mar 29, 2021
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

Successfully merging this pull request may close these issues.

2 participants