Commit Graph

45 Commits

Author SHA1 Message Date
Lucas Manning 32c474d82f Allow multiple FUSE filesystems to share a connection.
Before this change FUSE connections were shared 1:1 with FUSE filesystems, which
is incorrect behavior. A FUSE FD should have a 1:1 relationship with a FUSE
connection, and any number of FUSE filesystems can use the same connection.

PiperOrigin-RevId: 445988328
2022-05-02 11:41:42 -07:00
gVisor bot 350f05d6cd Merge pull request #7138 from avagin:fuse-test
PiperOrigin-RevId: 426270625
2022-02-03 16:57:22 -08:00
Andrei Vagin 8b456152da Run a new fuse server in a new thread 2022-02-03 13:50:24 -08:00
Andrei Vagin 9d2df1a6ca Enable fuse tests 2022-02-03 13:50:24 -08:00
gVisor bot 70fba80730 Merge pull request #6937 from YaroslavLitvinov:yaro/fix-fuse
PiperOrigin-RevId: 426223561
2022-02-03 13:24:54 -08:00
Yaroslav Litvinov b7ccfa5084 Fixes #7086,#6964,#3413,#7001.
Also adds fuse fsync, rename, flock support.
2022-01-27 13:07:42 +02:00
Jamie Liu 0058fca32e Disable all tests dependent on cloud_gvisor::testing::FuseTest.
PiperOrigin-RevId: 378753134
2021-06-10 15:54:34 -07:00
Rahat Mahmood 192318a231 fusefs: Implement default_permissions and allow_other mount options.
By default, fusefs defers node permission checks to the server. The
default_permissions mount option enables the usual unix permission
checks based on the node owner and mode bits. Previously fusefs was
incorrectly checking permissions unconditionally.

Additionally, fusefs should restrict filesystem access to processes
started by the mount owner to prevent the fuse daemon from gaining
priviledge over other processes. The allow_other mount option
overrides this behaviour. Previously fusefs was incorrectly skipping
this check.

Updates #3229

PiperOrigin-RevId: 362419092
2021-03-11 17:59:13 -08:00
Andrei Vagin 2a200811d4 fs/fuse: check that a task has a specified file descriptor
Reported-by: syzbot+814105309d2ae8651084@syzkaller.appspotmail.com
PiperOrigin-RevId: 350159452
2021-01-05 09:47:30 -08:00
Rahat Mahmood 9c198e5df4 Fix error handling on fusefs mount.
Don't propagate arbitrary golang errors up from fusefs because errors
that don't map to an errno result in a sentry panic.

Reported-by: syzbot+697cb635346e456fddfc@syzkaller.appspotmail.com
PiperOrigin-RevId: 346220306
2020-12-07 18:00:54 -08:00
Howard Zhang b6a5204c51 ARM64:fuse:alian stat struct order on multiarch
fields order in stat struct is different from
x86 to arm64. Please refer to
x86_64-linux-gnu/bits/stat.h
aarch64-linux-gnu/bits/stat.h

Signed-off-by: Howard Zhang <howard.zhang@arm.com>
2020-11-03 10:35:28 +08:00
Jinmou Li 15f50c8da6 Fix kernfs unlinkat and rmdirat incorrect resolved path name 2020-09-17 21:07:12 +00:00
gVisor bot ae59e52979 Merge pull request #3934 from avagin:feature/fuse
PiperOrigin-RevId: 332122081
2020-09-16 17:12:57 -07:00
Jinmou Li 26879c32b8 FUSE readdir test fix ino initialization 2020-09-16 12:22:17 -07:00
Andrei Vagin 5bf05ad3ce test/fuse: use the getdents syscall instead of opendir/readdir
opendir() is a libc wrapper. Different libc-s can implement it
differently.
2020-09-16 12:22:17 -07:00
Andrei Vagin 99fca1bf9a test/fuse: clean up 2020-09-16 12:22:17 -07:00
Andrei Vagin 92a020c798 fuse: fix a compile time error
readdir_test.cc:134:24: error: variable length arrays are a C99 feature [-Werror,-Wvla-extension]
  char readdir_payload[readdir_payload_size];
2020-09-16 12:22:17 -07:00
Andrei Vagin f148242aba Revert "fuse: add benchmarking support for FUSE"
test/fuse/benchmark/read_benchmark.cc:34: Failure
Expected: (fuse_prefix) != (nullptr), actual: NULL vs (nullptr)
external/com_google_benchmark/src/benchmark_runner.cc:120: RunInThread:
Check `st.iterations() >= st.max_iterations' failed. Benchmark returned
before State::KeepRunning() returned false!
--- FAIL: Benchmarks_BM_Read/262144/real_time (0.29s)
    runner.go:502: test "Benchmarks.BM_Read/262144/real_time" failed
    with error exit status 134, want nil
FAIL
2020-09-16 12:22:17 -07:00
Boyuan He 2051260e82 Implement FUSE_UNLINK
Fixes #3696
2020-09-16 12:19:30 -07:00
Craig Chi bf8efe8cdf Implement FUSE_SETATTR
This commit implements FUSE_SETATTR command. When a system call modifies
the metadata of a regular file or a folder by chown(2), chmod(2),
truncate(2), utime(2), or utimes(2), they should be translated to
corresponding FUSE_SETATTR command and sent to the FUSE server.

Fixes #3332
2020-09-16 12:19:30 -07:00
Craig Chi 4181e8c974 Add fh support for revise attr and fstat(2) test
According to Linux 4.4's FUSE behavior, the flags and fh attributes in
FUSE_GETATTR are only used in read, write, and lseek. fstat(2) doesn't
use them either. Add tests to ensure the requests sent from FUSE module
are consistent with Linux's.

Updates #3655
2020-09-16 12:19:30 -07:00
Craig Chi 1146ab6bac Add fuse_fd_util library to include common fuse fd test functions 2020-09-16 12:19:30 -07:00
Craig Chi e63abd82dd Add default attr in fuse_util
fuse_util provides utilities for fuse testing. Add a function to return
a stub fuse_attr struct with specified mode and nodeid.
2020-09-16 12:19:30 -07:00
Jinmou Li 98faed55e6 Implement FUSE_WRITE
This commit adds basic write(2) support for FUSE.
2020-09-16 12:19:30 -07:00
Craig Chi 18f1e1c91b Implement FUSE_CREATE
FUSE_CREATE is called when issuing creat(2) or open(2) with O_CREAT. It
creates a new file on the FUSE filesystem.

Fixes #3825
2020-09-16 12:19:30 -07:00
Boyuan He & Ridwan Sharif cb9a2a1ad4 fuse: add benchmarking support for FUSE
This change adds the following:
-  Add support for containerizing syscall tests for FUSE
-  Mount tmpfs in the container so we can run benchmarks against it
-  Run the server in a background process
-  benchmarks for fuse syscall

Co-authored-by: Ridwan Sharif <ridwanmsharif@google.com>
2020-09-16 12:19:30 -07:00
Ridwan Sharif 4a5857d644 fuse: Implement IterDirents for directory file description
Fixes #3255.

This change adds support for IterDirents. You can now use `ls` in
the FUSE sandbox.

Co-authored-by: Craig Chi <craigchi@google.com>
2020-09-16 12:19:30 -07:00
Ridwan Sharif bc07df8887 Implement FUSE_RMDIR
Fixes #3587

Co-authored-by: Craig Chi <craigchi@google.com>
2020-09-16 12:19:30 -07:00
Jinmou Li 713400d6b0 Implement FUSE_READ
Fixes #3206
2020-09-16 12:19:30 -07:00
Boyuan He 4d26c9929d Implement FUSE_MKDIR
Fixes #3392
2020-09-16 12:19:30 -07:00
Boyuan He 733d013f97 Implement FUSE_READLINK
Fixes #3316
2020-09-16 12:19:30 -07:00
Boyuan He b50c03b571 Implement FUSE_SYMLINK
Fixes #3452
2020-09-16 12:19:30 -07:00
Boyuan He b53e10f391 Implement FUSE_MKNOD
Fixes #3492
2020-09-16 12:19:30 -07:00
Boyuan He 947088e10a Implement FUSE_RELEASE/RELEASEDIR
Fixes #3314
2020-09-16 12:19:30 -07:00
Boyuan He 32044f94e9 Implement FUSE_OPEN/OPENDIR
Fixes #3174
2020-09-16 12:19:30 -07:00
Craig Chi 717b661c45 Add function to create a fake inode in FUSE integration test
Adds a function for the testing thread to set up a fake inode with a
specific path under mount point. After this function is called, each
subsequent FUSE_LOOKUP request with the same path will be served with
the fixed stub response.

Fixes #3539
2020-09-16 12:19:30 -07:00
Craig Chi d928d3c00a Add function generating array of iovec with different FUSE structs
This commit adds a function in the newly created fuse_util library,
which accepts a variable number of arguments and data structures.

Fixes #3609
2020-09-16 12:19:30 -07:00
Craig Chi a289c38626 Add functions in FUSE integration test to get metrics from FUSE server
This commit adds 3 utility functions to ensure all received requests
and preset responses are consumed.

1. Get number of unconsumed requests (received by the FUSE server but
   not consumed by the testing thread).
2. Get number of unsent responses (set by the testing thread but not
   processed by the FUSE server).
3. Get total bytes of the received requests (to ensure some operations
   don't trigger FUSE requests).

Fixes #3607
2020-09-16 12:19:30 -07:00
Craig Chi 15ff2893d9 Extend integration test to test sequence of FUSE operation
Original FUSE integration test has limited capabilities. To test more
situations, the new integration test framework introduces a protocol
to communicate between testing thread and the FUSE server. In summary,
this change includes:

1. Remove CompareResult() and break SetExpected() into
   SetServerResponse() and GetServerActualRequest(). We no longer set
   up an expected request because we want to retrieve the actual FUSE
   request made to the FUSE server and check in the testing thread.

2. Declare a serial buffer data structure to save the received requests
   and expected responses sequentially. The data structure contains a
   cursor to indicate the progress of accessing. This change makes
   sequential SetServerResponse() and GetServerActualRequest() possible.

3. Replace 2 single directional pipes with 1 bi-directional socketpair.
   A protocol which starts with FuseTestCmd is used between the testing
   thread and the FUSE server to provide various functionality.

Fixes #3405
2020-09-16 12:19:30 -07:00
gVisor bot e6df6222ac Merge pull request #3250 from craig08:fuse-getattr
PiperOrigin-RevId: 326313858
2020-08-12 14:36:04 -07:00
Craig Chi 51e64d2fc5 Implement FUSE_GETATTR
FUSE_GETATTR is called when a stat(2), fstat(2), or lstat(2) is issued
from VFS2 layer to a FUSE filesystem.

Fixes #3175
2020-08-10 18:15:32 -07:00
gVisor bot 34d302cb8a Merge pull request #3502 from craig08:fuse-integration-test-fix-connection-refused
PiperOrigin-RevId: 325080329
2020-08-05 12:47:55 -07:00
Craig Chi 9094adfc27 Fix FUSE integration test failed with ECONNREFUSED
The newer version of FUSE_INIT checks the response from the FUSE server
if its major number is equal to 7. If it's not, then FUSE_INIT fails and
further filesystem operations will get ECONNREFUSED. To mitigate this
issue, we can send back a response with major version equals to 7 when
consuming the first FUSE_INIT request.

Fixes #3500
2020-08-04 14:48:37 -07:00
gVisor bot af2f456735 Merge pull request #3320 from craig08:fuse-integration-test
PiperOrigin-RevId: 324877577
2020-08-04 13:25:40 -07:00
Craig Chi 21d0334e7f Add FUSE integration test
This commit adds an integration test framework for FUSE support. Please
refer to the test example and test/fuse/README.md for further details.

Fixes #3098
2020-08-04 12:27:55 -07:00