Make explicit flags optional for SYS_{READ,WRITE}2.

This commit is contained in:
4lDO2
2024-06-13 17:17:34 +02:00
parent dd8661bcb3
commit 10714a4659
2 changed files with 14 additions and 6 deletions
+2 -2
View File
@@ -71,9 +71,9 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
),
SYS_SENDFD => format!("sendfd({}, {}, {:#0x} {:#0x} {:#0x})", b, c, d, e, f,),
SYS_READ => format!("read({}, {:#X}, {})", b, c, d),
SYS_READ2 => format!("read2({}, {:#X}, {}, {}, {:?})", b, c, d, e, RwFlags::from_bits_retain(f as u32)),
SYS_READ2 => format!("read2({}, {:#X}, {}, {}, {:?})", b, c, d, e, (f != usize::MAX).then_some(RwFlags::from_bits_retain(f as u32))),
SYS_WRITE => format!("write({}, {:#X}, {})", b, c, d),
SYS_WRITE2 => format!("write2({}, {:#X}, {}, {}, {:?})", b, c, d, e, RwFlags::from_bits_retain(f as u32)),
SYS_WRITE2 => format!("write2({}, {:#X}, {}, {}, {:?})", b, c, d, e, (f != usize::MAX).then_some(RwFlags::from_bits_retain(f as u32))),
SYS_LSEEK => format!(
"lseek({}, {}, {} ({}))",
b,
+12 -4
View File
@@ -84,8 +84,12 @@ pub fn syscall(
match a & SYS_ARG {
SYS_ARG_SLICE => match a {
SYS_WRITE2 => file_op_generic_ext(fd, |scheme, _, desc| {
let flags = u32::try_from(f).ok().and_then(RwFlags::from_bits).ok_or(Error::new(EINVAL))?;
scheme.kwriteoff(desc.number, UserSlice::ro(c, d)?, e as u64, desc.rw_flags(flags), desc.flags)
let flags = if f == usize::MAX {
None
} else {
Some(u32::try_from(f).ok().and_then(RwFlags::from_bits).ok_or(Error::new(EINVAL))?)
};
scheme.kwriteoff(desc.number, UserSlice::ro(c, d)?, e as u64, flags.map_or(desc.flags, |f| desc.rw_flags(f)), desc.flags)
}),
SYS_WRITE => sys_write(fd, UserSlice::ro(c, d)?),
SYS_FMAP => {
@@ -108,8 +112,12 @@ pub fn syscall(
},
SYS_ARG_MSLICE => match a {
SYS_READ2 => file_op_generic_ext(fd, |scheme, _, desc| {
let flags = u32::try_from(f).ok().and_then(RwFlags::from_bits).ok_or(Error::new(EINVAL))?;
scheme.kreadoff(desc.number, UserSlice::wo(c, d)?, e as u64, desc.rw_flags(flags), desc.flags)
let flags = if f == usize::MAX {
None
} else {
Some(u32::try_from(f).ok().and_then(RwFlags::from_bits).ok_or(Error::new(EINVAL))?)
};
scheme.kreadoff(desc.number, UserSlice::wo(c, d)?, e as u64, flags.map_or(desc.flags, |f| desc.rw_flags(f)), desc.flags)
}),
SYS_READ => sys_read(fd, UserSlice::wo(c, d)?),
SYS_FPATH => file_op_generic(fd, |scheme, number| {