Skip to content

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

Merged
vasi merged 1 commit intovasi:masterfrom
kevin-vigor:fd0-fun
Mar 29, 2021
Merged

Fix "No such file or directory" when launched with empty fd 0.#55
vasi merged 1 commit intovasi:masterfrom
kevin-vigor:fd0-fun

Conversation

@kevin-vigor
Copy link
Copy Markdown
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