Skip to content

Commit 9f5a719

Browse files
jiangliueryugey
authored andcommitted
macos: clean up code related to macos
Clean up code related to macos. Follow up of #162 Signed-off-by: Jiang Liu <[email protected]>
1 parent 6708951 commit 9f5a719

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

src/api/server/sync_io.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,11 @@ impl<F: FileSystem + Sync> Server<F> {
696696
return ctx.reply_ok(Some(out), None);
697697
}
698698

699-
#[cfg(not(target_os = "macos"))]
700-
let mut flags_u64 = flags as u64;
701699
#[cfg(target_os = "macos")]
702700
let flags_u64 = flags as u64;
703701
#[cfg(not(target_os = "macos"))]
702+
let mut flags_u64 = flags as u64;
703+
#[cfg(not(target_os = "macos"))]
704704
if flags_u64 & FsOptions::INIT_EXT.bits() != 0 {
705705
let InitIn2 { flags2, unused: _ } = ctx.r.read_obj().map_err(Error::DecodeMessage)?;
706706
flags_u64 |= (flags2 as u64) << 32;

src/api/vfs/mod.rs

+27-20
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ struct MountPointData {
226226
#[derive(Debug, Copy, Clone)]
227227
/// vfs init options
228228
pub struct VfsOptions {
229+
/// Make readdir/readdirplus request return zero dirent even if dir has children.
230+
pub no_readdir: bool,
231+
/// Reject requests which will change the file size, or allocate file
232+
/// blocks exceed file size.
233+
pub seal_size: bool,
234+
/// File system options passed in from client
235+
pub in_opts: FsOptions,
236+
/// File system options returned to client
237+
pub out_opts: FsOptions,
238+
/// Declaration of ID mapping, in the format (internal ID, external ID, range).
239+
/// For example, (0, 1, 65536) represents mapping the external UID/GID range of `1~65536`
240+
/// to the range of `0~65535` within the filesystem.
241+
pub id_mapping: (u32, u32, u32),
242+
229243
/// Disable fuse open request handling. When enabled, fuse open
230244
/// requests are always replied with ENOSYS.
231245
#[cfg(not(target_os = "macos"))]
@@ -238,24 +252,11 @@ pub struct VfsOptions {
238252
/// buffer writes.
239253
#[cfg(not(target_os = "macos"))]
240254
pub no_writeback: bool,
241-
/// Make readdir/readdirplus request return zero dirent even if dir has children.
242-
pub no_readdir: bool,
243255
/// Enable fuse killpriv_v2 support. When enabled, fuse file system makes sure
244256
/// to remove security.capability xattr and setuid/setgid bits. See details in
245257
/// comments for HANDLE_KILLPRIV_V2
246258
#[cfg(not(target_os = "macos"))]
247259
pub killpriv_v2: bool,
248-
/// Reject requests which will change the file size, or allocate file
249-
/// blocks exceed file size.
250-
pub seal_size: bool,
251-
/// File system options passed in from client
252-
pub in_opts: FsOptions,
253-
/// File system options returned to client
254-
pub out_opts: FsOptions,
255-
/// Declaration of ID mapping, in the format (internal ID, external ID, range).
256-
/// For example, (0, 1, 65536) represents mapping the external UID/GID range of `1~65536`
257-
/// to the range of `0~65535` within the filesystem.
258-
pub id_mapping: (u32, u32, u32),
259260
}
260261

261262
impl VfsOptions {
@@ -265,8 +266,8 @@ impl VfsOptions {
265266
}
266267

267268
impl Default for VfsOptions {
269+
#[cfg(not(target_os = "macos"))]
268270
fn default() -> Self {
269-
#[cfg(not(target_os = "macos"))]
270271
let out_opts = FsOptions::ASYNC_READ
271272
| FsOptions::PARALLEL_DIROPS
272273
| FsOptions::BIG_WRITES
@@ -284,24 +285,30 @@ impl Default for VfsOptions {
284285
| FsOptions::ZERO_MESSAGE_OPENDIR
285286
| FsOptions::HANDLE_KILLPRIV_V2
286287
| FsOptions::PERFILE_DAX;
287-
#[cfg(target_os = "macos")]
288-
let out_opts = FsOptions::ASYNC_READ | FsOptions::BIG_WRITES | FsOptions::ATOMIC_O_TRUNC;
289288
VfsOptions {
290-
#[cfg(not(target_os = "macos"))]
291289
no_open: true,
292-
#[cfg(not(target_os = "macos"))]
293290
no_opendir: true,
294-
#[cfg(not(target_os = "macos"))]
295291
no_writeback: false,
296292
no_readdir: false,
297293
seal_size: false,
298-
#[cfg(not(target_os = "macos"))]
299294
killpriv_v2: false,
300295
in_opts: FsOptions::empty(),
301296
out_opts,
302297
id_mapping: (0, 0, 0),
303298
}
304299
}
300+
301+
#[cfg(target_os = "macos")]
302+
fn default() -> Self {
303+
let out_opts = FsOptions::ASYNC_READ | FsOptions::BIG_WRITES | FsOptions::ATOMIC_O_TRUNC;
304+
VfsOptions {
305+
no_readdir: false,
306+
seal_size: false,
307+
in_opts: FsOptions::empty(),
308+
out_opts,
309+
id_mapping: (0, 0, 0),
310+
}
311+
}
305312
}
306313

307314
/// A union fs that combines multiple backend file systems.

0 commit comments

Comments
 (0)