Skip to content

Commit f6e501c

Browse files
committed
Merge branch 'ro'
2 parents d80cda3 + d3206f0 commit f6e501c

File tree

7 files changed

+26
-2
lines changed

7 files changed

+26
-2
lines changed

examples/mount.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ async fn main() -> Result<()> {
3939
false,
4040
false,
4141
false,
42+
false,
4243
);
4344
let handle = mount_point.mount().await?;
4445
let mut buffer = String::new();

java-bridge/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ pub extern "system" fn Java_RustLibrary_mount(
185185
false,
186186
false,
187187
false,
188+
false,
188189
);
189190

190191
let handle = match RT.block_on(async {

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
//! args.next(); // skip program name
4444
//! let mount_path = args.next().expect("mount_path expected");
4545
//! let data_path = args.next().expect("data_path expected");
46-
//!
4746
//! struct PasswordProviderImpl {}
4847
//! impl PasswordProvider for PasswordProviderImpl {
4948
//! fn get_password(&self) -> Option<SecretString> {
@@ -60,6 +59,7 @@
6059
//! false,
6160
//! false,
6261
//! false,
62+
//! false,
6363
//! );
6464
//! let handle = mount_point.mount().await?;
6565
//! let mut buffer = String::new();

src/mount.rs

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub trait MountPoint {
3636
allow_other: bool,
3737
direct_io: bool,
3838
suid_support: bool,
39+
read_only: bool,
3940
) -> Self
4041
where
4142
Self: Sized;
@@ -74,6 +75,7 @@ pub(crate) trait MountHandleInner: Future<Output = io::Result<()>> {
7475
/// **`allow_other`** allow other users to access the file system
7576
/// **`direct_io`** use direct I/O (bypass page cache for open files)
7677
/// **`suid_support`** if it should allow setting `SUID` and `SGID` when files are created. On `false` it will unset those flags when creating files
78+
/// **`read_only`** Set fuse filesystem read-only mount option, default is disabled.
7779
///
7880
#[must_use]
7981
#[allow(clippy::fn_params_excessive_bools)]
@@ -86,6 +88,7 @@ pub fn create_mount_point(
8688
allow_other: bool,
8789
direct_io: bool,
8890
suid_support: bool,
91+
read_only: bool,
8992
) -> impl MountPoint {
9093
MountPointImpl::new(
9194
mountpoint.to_path_buf(),
@@ -96,6 +99,7 @@ pub fn create_mount_point(
9699
allow_other,
97100
direct_io,
98101
suid_support,
102+
read_only,
99103
)
100104
}
101105

src/mount/dummy.rs

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct MountPointImpl {
2222
allow_other: bool,
2323
direct_io: bool,
2424
suid_support: bool,
25+
read_only: bool,
2526
}
2627

2728
#[async_trait]
@@ -35,6 +36,7 @@ impl MountPoint for MountPointImpl {
3536
allow_other: bool,
3637
direct_io: bool,
3738
suid_support: bool,
39+
read_only: bool,
3840
) -> Self {
3941
Self {
4042
mountpoint,
@@ -45,6 +47,7 @@ impl MountPoint for MountPointImpl {
4547
allow_other,
4648
direct_io,
4749
suid_support,
50+
read_only,
4851
}
4952
}
5053

src/mount/linux.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ pub struct MountPointImpl {
13861386
allow_other: bool,
13871387
direct_io: bool,
13881388
suid_support: bool,
1389+
read_only: bool,
13891390
}
13901391

13911392
#[async_trait]
@@ -1399,6 +1400,7 @@ impl MountPoint for MountPointImpl {
13991400
allow_other: bool,
14001401
direct_io: bool,
14011402
suid_support: bool,
1403+
read_only: bool,
14021404
) -> Self {
14031405
Self {
14041406
mountpoint,
@@ -1409,6 +1411,7 @@ impl MountPoint for MountPointImpl {
14091411
allow_other,
14101412
direct_io,
14111413
suid_support,
1414+
read_only,
14121415
}
14131416
}
14141417

@@ -1422,6 +1425,7 @@ impl MountPoint for MountPointImpl {
14221425
self.allow_other,
14231426
self.direct_io,
14241427
self.suid_support,
1428+
self.read_only,
14251429
)
14261430
.await?;
14271431
Ok(mount::MountHandle {
@@ -1459,6 +1463,7 @@ async fn mount_fuse(
14591463
allow_other: bool,
14601464
direct_io: bool,
14611465
suid_support: bool,
1466+
read_only: bool,
14621467
) -> FsResult<MountHandle> {
14631468
// create mount point if it doesn't exist
14641469
if !mountpoint.exists() {
@@ -1471,7 +1476,7 @@ async fn mount_fuse(
14711476
}
14721477
}
14731478
let mount_options = mount_options
1474-
.read_only(false)
1479+
.read_only(read_only)
14751480
.allow_root(allow_root)
14761481
.allow_other(allow_other)
14771482
.clone();

src/run.rs

+10
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ fn get_cli_args() -> ArgMatches {
188188
.requires("data-dir")
189189
.help("If it should allow setting SUID and SGID when files are created. Default is false and it will unset those flags when creating files"),
190190
)
191+
.arg(
192+
Arg::new("read-only")
193+
.long("read-only")
194+
.short('e')
195+
.action(ArgAction::SetTrue)
196+
.requires("mount-point")
197+
.requires("data-dir")
198+
.help("Set fuse filesystem read-only mount option, default is disabled.")
199+
)
191200
).subcommand(
192201
Command::new("passwd")
193202
.about("Change password for the master key used to encrypt the data")
@@ -355,6 +364,7 @@ async fn run_mount(cipher: Cipher, matches: &ArgMatches) -> Result<()> {
355364
matches.get_flag("allow-other"),
356365
matches.get_flag("direct-io"),
357366
matches.get_flag("suid"),
367+
matches.get_flag("read-only"),
358368
);
359369
let mount_handle = mount_point.mount().await.map_err(|err| {
360370
error!(err = %err);

0 commit comments

Comments
 (0)