Skip to content

Commit 20da8b1

Browse files
jiangliubergwolf
authored andcommitted
build: fix a build failure related to conditional compilation
Fix a build failure related to conditional compilation: error[E0063]: missing field `id_mapping` in initializer of `VfsOptions` --> src/api/vfs/mod.rs:751:16 | 751 | Ok(VfsOptions { | ^^^^^^^^^^ missing `id_mapping` Signed-off-by: Jiang Liu <[email protected]>
1 parent 9f5a719 commit 20da8b1

File tree

4 files changed

+62
-36
lines changed

4 files changed

+62
-36
lines changed

src/api/server/async_io.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ impl<F: AsyncFileSystem + Sync> Server<F> {
185185
x if x == Opcode::NotifyReply as u32 => self.notify_reply(ctx),
186186
x if x == Opcode::BatchForget as u32 => self.batch_forget(ctx),
187187
x if x == Opcode::Fallocate as u32 => self.async_fallocate(ctx).await,
188-
#[cfg(not(target_os = "macos"))]
188+
#[cfg(target_os = "linux")]
189189
x if x == Opcode::Readdirplus as u32 => self.readdirplus(ctx),
190-
#[cfg(not(target_os = "macos"))]
190+
#[cfg(target_os = "linux")]
191191
x if x == Opcode::Rename2 as u32 => self.rename2(ctx),
192-
#[cfg(not(target_os = "macos"))]
192+
#[cfg(target_os = "linux")]
193193
x if x == Opcode::Lseek as u32 => self.lseek(ctx),
194194
#[cfg(feature = "virtiofs")]
195195
x if x == Opcode::SetupMapping as u32 => self.setupmapping(ctx, vu_req),

src/api/server/sync_io.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ impl<F: FileSystem + Sync> Server<F> {
137137
x if x == Opcode::NotifyReply as u32 => self.notify_reply(ctx),
138138
x if x == Opcode::BatchForget as u32 => self.batch_forget(ctx),
139139
x if x == Opcode::Fallocate as u32 => self.fallocate(ctx),
140-
#[cfg(not(target_os = "macos"))]
140+
#[cfg(target_os = "linux")]
141141
x if x == Opcode::Readdirplus as u32 => self.readdirplus(ctx),
142-
#[cfg(not(target_os = "macos"))]
142+
#[cfg(target_os = "linux")]
143143
x if x == Opcode::Rename2 as u32 => self.rename2(ctx),
144-
#[cfg(not(target_os = "macos"))]
144+
#[cfg(target_os = "linux")]
145145
x if x == Opcode::Lseek as u32 => self.lseek(ctx),
146146
#[cfg(feature = "virtiofs")]
147147
x if x == Opcode::SetupMapping as u32 => self.setupmapping(ctx, vu_req),
@@ -358,7 +358,7 @@ impl<F: FileSystem + Sync> Server<F> {
358358
self.do_rename(ctx, size_of::<RenameIn>(), newdir, 0)
359359
}
360360

361-
#[cfg(not(target_os = "macos"))]
361+
#[cfg(target_os = "linux")]
362362
pub(super) fn rename2<S: BitmapSlice>(&self, mut ctx: SrvContext<'_, F, S>) -> Result<usize> {
363363
let Rename2In { newdir, flags, .. } = ctx.r.read_obj().map_err(Error::DecodeMessage)?;
364364

@@ -698,9 +698,9 @@ impl<F: FileSystem + Sync> Server<F> {
698698

699699
#[cfg(target_os = "macos")]
700700
let flags_u64 = flags as u64;
701-
#[cfg(not(target_os = "macos"))]
701+
#[cfg(target_os = "linux")]
702702
let mut flags_u64 = flags as u64;
703-
#[cfg(not(target_os = "macos"))]
703+
#[cfg(target_os = "linux")]
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;
@@ -737,7 +737,7 @@ impl<F: FileSystem + Sync> Server<F> {
737737
if enabled.contains(FsOptions::BIG_WRITES) {
738738
out.max_write = MAX_REQ_PAGES as u32 * pagesize() as u32;
739739
}
740-
#[cfg(not(target_os = "macos"))]
740+
#[cfg(target_os = "linux")]
741741
if enabled.contains(FsOptions::MAX_PAGES) {
742742
out.max_pages = MAX_REQ_PAGES;
743743
out.max_write = MAX_REQ_PAGES as u32 * pagesize() as u32; // 1MB
@@ -856,7 +856,7 @@ impl<F: FileSystem + Sync> Server<F> {
856856
self.do_readdir(ctx, false)
857857
}
858858

859-
#[cfg(not(target_os = "macos"))]
859+
#[cfg(target_os = "linux")]
860860
pub(super) fn readdirplus<S: BitmapSlice>(&self, ctx: SrvContext<'_, F, S>) -> Result<usize> {
861861
self.do_readdir(ctx, true)
862862
}
@@ -1151,7 +1151,7 @@ impl<F: FileSystem + Sync> Server<F> {
11511151
}
11521152
}
11531153

1154-
#[cfg(not(target_os = "macos"))]
1154+
#[cfg(target_os = "linux")]
11551155
pub(super) fn lseek<S: BitmapSlice>(&self, mut ctx: SrvContext<'_, F, S>) -> Result<usize> {
11561156
let LseekIn {
11571157
fh, offset, whence, ..

src/api/vfs/mod.rs

+47-21
Original file line numberDiff line numberDiff line change
@@ -242,20 +242,20 @@ pub struct VfsOptions {
242242

243243
/// Disable fuse open request handling. When enabled, fuse open
244244
/// requests are always replied with ENOSYS.
245-
#[cfg(not(target_os = "macos"))]
245+
#[cfg(target_os = "linux")]
246246
pub no_open: bool,
247247
/// Disable fuse opendir request handling. When enabled, fuse opendir
248248
/// requests are always replied with ENOSYS.
249-
#[cfg(not(target_os = "macos"))]
249+
#[cfg(target_os = "linux")]
250250
pub no_opendir: bool,
251251
/// Disable fuse WRITEBACK_CACHE option so that kernel will not cache
252252
/// buffer writes.
253-
#[cfg(not(target_os = "macos"))]
253+
#[cfg(target_os = "linux")]
254254
pub no_writeback: bool,
255255
/// Enable fuse killpriv_v2 support. When enabled, fuse file system makes sure
256256
/// to remove security.capability xattr and setuid/setgid bits. See details in
257257
/// comments for HANDLE_KILLPRIV_V2
258-
#[cfg(not(target_os = "macos"))]
258+
#[cfg(target_os = "linux")]
259259
pub killpriv_v2: bool,
260260
}
261261

@@ -266,7 +266,7 @@ impl VfsOptions {
266266
}
267267

268268
impl Default for VfsOptions {
269-
#[cfg(not(target_os = "macos"))]
269+
#[cfg(target_os = "linux")]
270270
fn default() -> Self {
271271
let out_opts = FsOptions::ASYNC_READ
272272
| FsOptions::PARALLEL_DIROPS
@@ -723,44 +723,70 @@ pub mod persist {
723723

724724
#[derive(Versionize, Debug, Default)]
725725
struct VfsOptionsState {
726-
no_open: bool,
727-
no_opendir: bool,
728-
no_writeback: bool,
729726
in_opts: u64,
730727
out_opts: u64,
731-
killpriv_v2: bool,
732728
no_readdir: bool,
733729
seal_size: bool,
730+
id_mapping_internal: u32,
731+
id_mapping_external: u32,
732+
id_mapping_range: u32,
733+
734+
#[cfg(target_os = "linux")]
735+
no_open: bool,
736+
#[cfg(target_os = "linux")]
737+
no_opendir: bool,
738+
#[cfg(target_os = "linux")]
739+
no_writeback: bool,
740+
#[cfg(target_os = "linux")]
741+
killpriv_v2: bool,
734742
}
735743

736744
impl VfsOptions {
737745
fn save(&self) -> VfsOptionsState {
738746
VfsOptionsState {
739-
no_open: self.no_open,
740-
no_opendir: self.no_opendir,
741-
no_writeback: self.no_writeback,
742747
in_opts: self.in_opts.bits(),
743748
out_opts: self.out_opts.bits(),
744-
killpriv_v2: self.killpriv_v2,
745749
no_readdir: self.no_readdir,
746750
seal_size: self.seal_size,
751+
id_mapping_internal: self.id_mapping.0,
752+
id_mapping_external: self.id_mapping.1,
753+
id_mapping_range: self.id_mapping.2,
754+
755+
#[cfg(target_os = "linux")]
756+
no_open: self.no_open,
757+
#[cfg(target_os = "linux")]
758+
no_opendir: self.no_opendir,
759+
#[cfg(target_os = "linux")]
760+
no_writeback: self.no_writeback,
761+
#[cfg(target_os = "linux")]
762+
killpriv_v2: self.killpriv_v2,
747763
}
748764
}
749765

750766
fn restore(state: &VfsOptionsState) -> VfsResult<VfsOptions> {
751767
Ok(VfsOptions {
752-
no_open: state.no_open,
753-
no_opendir: state.no_opendir,
754-
no_writeback: state.no_writeback,
755768
in_opts: FsOptions::from_bits(state.in_opts).ok_or(VfsError::Persist(
756769
"Failed to restore VfsOptions.in_opts".to_owned(),
757770
))?,
758771
out_opts: FsOptions::from_bits(state.out_opts).ok_or(VfsError::Persist(
759772
"Failed to restore VfsOptions.out_opts".to_owned(),
760773
))?,
761-
killpriv_v2: state.killpriv_v2,
762774
no_readdir: state.no_readdir,
763775
seal_size: state.seal_size,
776+
id_mapping: (
777+
state.id_mapping_internal,
778+
state.id_mapping_external,
779+
state.id_mapping_range,
780+
),
781+
782+
#[cfg(target_os = "linux")]
783+
no_open: state.no_open,
784+
#[cfg(target_os = "linux")]
785+
no_opendir: state.no_opendir,
786+
#[cfg(target_os = "linux")]
787+
no_writeback: state.no_writeback,
788+
#[cfg(target_os = "linux")]
789+
killpriv_v2: state.killpriv_v2,
764790
})
765791
}
766792
}
@@ -1431,7 +1457,7 @@ mod tests {
14311457
let opts = vfs.opts.load();
14321458
let out_opts = opts.out_opts;
14331459

1434-
#[cfg(not(target_os = "macos"))]
1460+
#[cfg(target_os = "linux")]
14351461
{
14361462
assert_eq!(opts.no_open, true);
14371463
assert_eq!(opts.no_opendir, true);
@@ -1446,7 +1472,7 @@ mod tests {
14461472
assert_eq!(vfs.initialized(), true);
14471473

14481474
let opts = vfs.opts.load();
1449-
#[cfg(not(target_os = "macos"))]
1475+
#[cfg(target_os = "linux")]
14501476
{
14511477
assert_eq!(opts.no_open, false);
14521478
assert_eq!(opts.no_opendir, false);
@@ -1460,14 +1486,14 @@ mod tests {
14601486
assert_eq!(vfs.initialized(), false);
14611487

14621488
let vfs = Vfs::default();
1463-
#[cfg(not(target_os = "macos"))]
1489+
#[cfg(target_os = "linux")]
14641490
let in_opts =
14651491
FsOptions::ASYNC_READ | FsOptions::ZERO_MESSAGE_OPEN | FsOptions::ZERO_MESSAGE_OPENDIR;
14661492
#[cfg(target_os = "macos")]
14671493
let in_opts = FsOptions::ASYNC_READ;
14681494
vfs.init(in_opts).unwrap();
14691495
let opts = vfs.opts.load();
1470-
#[cfg(not(target_os = "macos"))]
1496+
#[cfg(target_os = "linux")]
14711497
{
14721498
assert_eq!(opts.no_open, true);
14731499
assert_eq!(opts.no_opendir, true);

src/api/vfs/sync_io.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl FileSystem for Vfs {
2020
return Err(Error::from_raw_os_error(libc::EINVAL));
2121
}
2222
let mut n_opts = *self.opts.load().deref().deref();
23-
#[cfg(not(target_os = "macos"))]
23+
#[cfg(target_os = "linux")]
2424
{
2525
if n_opts.no_open {
2626
n_opts.no_open = !(opts & FsOptions::ZERO_MESSAGE_OPEN).is_empty();
@@ -300,7 +300,7 @@ impl FileSystem for Vfs {
300300
flags: u32,
301301
fuse_flags: u32,
302302
) -> Result<(Option<u64>, OpenOptions)> {
303-
#[cfg(not(target_os = "macos"))]
303+
#[cfg(target_os = "linux")]
304304
if self.opts.load().no_open {
305305
return Err(Error::from_raw_os_error(libc::ENOSYS));
306306
}
@@ -516,7 +516,7 @@ impl FileSystem for Vfs {
516516
inode: VfsInode,
517517
flags: u32,
518518
) -> Result<(Option<VfsHandle>, OpenOptions)> {
519-
#[cfg(not(target_os = "macos"))]
519+
#[cfg(target_os = "linux")]
520520
if self.opts.load().no_opendir {
521521
return Err(Error::from_raw_os_error(libc::ENOSYS));
522522
}

0 commit comments

Comments
 (0)