Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Carl Jones <[email protected]>
Signed-off-by: Burak Varlı <[email protected]>
  • Loading branch information
unexge and dannycjones authored Dec 17, 2024
1 parent 04ba1c9 commit e7f231a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
20 changes: 10 additions & 10 deletions doc/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,22 @@ ExecStop=/usr/bin/fusermount -u /home/ec2-user/s3-bucket-mount
WantedBy=remote-fs.target
```

### Configuring mount point
### Providing a FUSE file descriptor for mounting

Mountpoint supports mounting S3 buckets to a directory or a FUSE file descriptor (only on Linux).
Mountpoint supports mounting S3 buckets at a given path, or using a provided FUSE file descriptor (only on Linux).

For directory mount points, the passed path must be an existing directory.

For FUSE file descriptors on Linux, you can specify an open FUSE file descriptor as a mount point with `/dev/fd/N` syntax.
This is useful in container environments to achieve unprivileged mounts.
In this case, it's callers responsibility to:
1. Opening FUSE device (`/dev/fuse`) in read-write mode to obtain a file descriptor
2. Performing `mount` syscall with desired mount point, the file descriptor and mount options.
Mountpoint by default uses and recommends enabling `nodev`, `nosuid`, `default_permissions` and `noatime` mount options,
see [Linux kernel documentation](https://man7.org/linux/man-pages/man8/mount.fuse3.8.html#OPTIONS) about more details on mount options.
3. Spawning Mountpoint with the file descriptor using `/dev/fd/N` syntax as mount point
4. Closing the file descriptor in the parent process
5. Performing `unmount` syscall on the mount point once its desired and/or Mountpoint process terminates
In this case, the caller is responsible for the following:
1. Opening the FUSE device (`/dev/fuse`) in read-write mode to obtain a file descriptor.
2. Performing the `mount` syscall with the desired mount point, the file descriptor, and any mount options.
Mountpoint by default uses and recommends enabling `nodev`, `nosuid`, `default_permissions`, and `noatime` mount options.
See the [Linux kernel documentation](https://man7.org/linux/man-pages/man8/mount.fuse3.8.html#OPTIONS) for more details on mount options.
3. Spawning Mountpoint with the file descriptor using `/dev/fd/N` syntax as the mount point argument.
4. Closing the file descriptor in the parent process.
5. Performing the `unmount` syscall on the mount point when unmounting is desired or when the Mountpoint process terminates.

See [mounthelper.go](https://github.com/awslabs/mountpoint-s3/tree/main/examples/fuse-fd-mount-point/mounthelper.go) as an example usage of this feature.

Expand Down
6 changes: 5 additions & 1 deletion examples/fuse-fd-mount-point/mounthelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func main() {
}

// 2. Perform `mount` syscall
// Mountpoint enables and recommends these mount options and flags by default
// These mount options and flags match those typically set when using Mountpoint.
// Some are set by the underlying FUSE library.
// Mountpoint sets (correct at the time of authoring this comment):
// * `noatime` to avoid unsupported access time updates.
// * `default_permissions` to tell the Kernel to evaluate permissions itself, since Mountpoint does not currently provide any handler for FUSE `access`.
options := []string{
fmt.Sprintf("fd=%d", fd),
fmt.Sprintf("rootmode=%o", stat.Mode),
Expand Down
1 change: 1 addition & 0 deletions mountpoint-s3/tests/fuse_tests/read_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const READ_WRITE: bool = false;
const FUSE_PASS_FD: bool = true;
const FUSE_SELF_MOUNT: bool = false;

/// Test wrapper to support generate of test names when used with [test_case].
enum BucketPrefix {
None,
Some(&'static str),
Expand Down

0 comments on commit e7f231a

Please sign in to comment.