Skip to content

Commit fbd70b9

Browse files
committed
refactor: split some logic
Signed-off-by: akitaSummer <[email protected]>
1 parent 28f93e3 commit fbd70b9

10 files changed

+847
-727
lines changed

src/api/server/sync_io.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl<F: FileSystem + Sync> Server<F> {
143143
x if x == Opcode::Rename2 as u32 => self.rename2(ctx),
144144
#[cfg(target_os = "linux")]
145145
x if x == Opcode::Lseek as u32 => self.lseek(ctx),
146-
#[cfg(feature = "virtiofs")]
146+
#[cfg(all(target_os = "linux", feature = "virtiofs"))]
147147
x if x == Opcode::SetupMapping as u32 => self.setupmapping(ctx, vu_req),
148-
#[cfg(feature = "virtiofs")]
148+
#[cfg(all(target_os = "linux", feature = "virtiofs"))]
149149
x if x == Opcode::RemoveMapping as u32 => self.removemapping(ctx, vu_req),
150150
// Group reqeusts don't need reply together
151151
x => match x {

src/passthrough/file_handle.rs

+2
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ impl OpenableFileHandle {
320320
#[cfg(test)]
321321
mod tests {
322322
use super::*;
323+
#[cfg(target_os = "macos")]
323324
use nix::unistd::getuid;
324325
use std::ffi::CString;
326+
#[cfg(target_os = "macos")]
325327
use std::io::Read;
326328

327329
fn generate_c_file_handle(

src/passthrough/inode_store.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::sync::Arc;
77
#[cfg(target_os = "linux")]
88
use super::file_handle::FileHandle;
99
#[cfg(target_os = "macos")]
10-
use super::stat::Stat;
10+
use super::stat::Stat as StatExt;
1111
#[cfg(target_os = "linux")]
1212
use super::statx::StatExt;
1313

@@ -25,24 +25,15 @@ pub struct InodeId {
2525
}
2626

2727
impl InodeId {
28-
#[cfg(target_os = "linux")]
2928
#[inline]
3029
pub(super) fn from_stat(st: &StatExt) -> Self {
3130
InodeId {
3231
ino: st.st.st_ino,
3332
dev: st.st.st_dev,
33+
#[cfg(target_os = "linux")]
3434
mnt: st.mnt_id,
3535
}
3636
}
37-
38-
#[cfg(target_os = "macos")]
39-
#[inline]
40-
pub(super) fn from_stat(st: &Stat) -> Self {
41-
InodeId {
42-
ino: st.st.st_ino,
43-
dev: st.st.st_dev,
44-
}
45-
}
4637
}
4738

4839
#[derive(Default)]
@@ -125,7 +116,9 @@ mod test {
125116
use super::super::*;
126117
use super::*;
127118

119+
#[cfg(target_os = "linux")]
128120
use std::ffi::CStr;
121+
#[cfg(target_os = "linux")]
129122
use std::mem::MaybeUninit;
130123
use std::os::unix::io::AsRawFd;
131124
use std::sync::atomic::Ordering;
@@ -134,6 +127,7 @@ mod test {
134127
#[cfg(target_os = "linux")]
135128
use vmm_sys_util::tempfile::TempFile;
136129

130+
#[cfg(target_os = "macos")]
137131
use stat::stat;
138132

139133
impl PartialEq for InodeData {

0 commit comments

Comments
 (0)