diff options
author | Zim <zezeozue@google.com> | 2020-03-25 11:09:51 +0000 |
---|---|---|
committer | Zim <zezeozue@google.com> | 2020-03-25 12:41:18 +0000 |
commit | 3a69a04fa62baddd397619eb78ea237eb4c0056d (patch) | |
tree | cada9b2e1b49fb45f44493666bd195d44231888c /lib | |
parent | 237c71124326a332f67135576204731a6dbebaeb (diff) | |
download | libfuse-3a69a04fa62baddd397619eb78ea237eb4c0056d.tar.gz |
Fix FUSE_CANONICAL_PATH response
The bluecross kernel introduced a change,
4fb542f2aa1414cea5686efcf72a411b7213c375 that breaks responses to
canonical paths.
The patch above tried to guarantee that the canonical path
returned from the FUSE daemon is null terminated. It does this by
replacing the last character in the path returned from the FUSE daemon
with '\0'.
Since the size of the response returned from the FUSE daemon is gotten
from strlen which doesn't take into account the null terminating
character. This means that the kernel fix above will break the file
path returned from userspace. Effectively replacing
/storage/emulated/0 with /storage/emulated/.
It is unclear how this breaks inotify on the root path but not inotify
on Download/ for instance since that too is replaced by
/storage/emulated/Downloa.
One thing I've noticed is that in the case of Download, being
replaced with Downloa, there is an error generated, since Downloa
doesn't exist, but in the case of /storage/emulated/0, there is no
error since /storage/emulated/ exists.
In any case, this cl returns a buffer size including the '\0' to the
kernel and seems right given that the actual size of the buffer
returned to the kernel is now correct.
Test: Manual tests with inotify and Documents UI detecting changes on
/sdcard on both taimen and crosshatch
Bug: 152035889
Change-Id: Ia4b9adec09dd501ec0c5327b9ea9577412cea6a2
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fuse_lowlevel.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 334b497..fc76b7c 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -452,7 +452,9 @@ int fuse_reply_readlink(fuse_req_t req, const char *linkname) int fuse_reply_canonical_path(fuse_req_t req, const char *path) { - return send_reply_ok(req, path, strlen(path)); + // The kernel expects a buffer containing the null terminator for this op + // So we add the null terminator size to strlen + return send_reply_ok(req, path, strlen(path) + 1); } int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *f) |