Skip to content

Commit

Permalink
ANDROID: fuse-bpf: set error_in to ENOENT in negative lookup
Browse files Browse the repository at this point in the history
Bug: 250617797
Test: fuse-test passes, app installs
Signed-off-by: Paul Lawrence <[email protected]>
Change-Id: I44544f8989d0ddf00a98eaddce5751df6598130f
  • Loading branch information
PaulLawrenceGoogle authored and bengris32 committed Jun 22, 2024
1 parent 6d356dc commit 9d94dd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/fuse/backing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,10 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir,
.mnt = mntget(dir_fuse_entry->backing_path.mnt),
};

if (d_is_negative(backing_entry))
if (d_is_negative(backing_entry)) {
fa->error_in = -ENOENT;
return 0;
}

err = vfs_getattr(&fuse_entry->backing_path, &stat,
STATX_BASIC_STATS, 0);
Expand Down
10 changes: 10 additions & 0 deletions tools/testing/selftests/filesystems/fuse/fuse_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ static int bpf_test_lookup_postfilter(const char *mount_dir)
{
const char *file1_name = "file1";
const char *file2_name = "file2";
const char *file3_name = "file3";
int result = TEST_FAILURE;
int bpf_fd = -1;
int src_fd = -1;
Expand Down Expand Up @@ -1944,18 +1945,27 @@ static int bpf_test_lookup_postfilter(const char *mount_dir)
TEST(fd = s_open(s_path(s(mount_dir), s(file2_name)), O_RDONLY),
fd != -1);
TESTSYSCALL(close(fd));
TESTEQUAL(s_open(s_path(s(mount_dir), s(file3_name)), O_RDONLY),
-1);
FUSE_DAEMON
struct fuse_in_header *in_header =
(struct fuse_in_header *)bytes_in;
struct fuse_entry_out *feo;
struct fuse_entry_bpf_out *febo;

TESTFUSELOOKUP(file1_name, FUSE_POSTFILTER);
TESTFUSEOUTERROR(-ENOENT);

TESTFUSELOOKUP(file2_name, FUSE_POSTFILTER);
feo = (struct fuse_entry_out *) (bytes_in +
sizeof(struct fuse_in_header) + strlen(file2_name) + 1);
febo = (struct fuse_entry_bpf_out *) ((char *)feo +
sizeof(*feo));
TESTFUSEOUT2(fuse_entry_out, *feo, fuse_entry_bpf_out, *febo);

TESTFUSELOOKUP(file3_name, FUSE_POSTFILTER);
TESTEQUAL(in_header->error_in, -ENOENT);
TESTFUSEOUTERROR(-ENOENT);
FUSE_DONE

result = TEST_SUCCESS;
Expand Down

0 comments on commit 9d94dd4

Please sign in to comment.