• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

olukowski / celer / 24930865087

25 Apr 2026 12:25PM UTC coverage: 99.677% (-0.3%) from 100.0%
24930865087

Pull #10

github

web-flow
Merge 4671e3217 into ea5776c23
Pull Request #10: feat(syscalls): thin wrappers around raw syscalls

10 of 10 branches covered (100.0%)

Branch coverage included in aggregate %.

1704 of 1712 new or added lines in 118 files covered. (99.53%)

2462 of 2470 relevant lines covered (99.68%)

11.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.23
/system/linux/syscalls/src/vm86.rs
1
use celer_system_linux_ctypes::Vm86Struct;
2

3
use crate::errno::Errno;
4
use crate::helpers::unit_from_ret;
5
use crate::sys;
6

7
/// Errors returned by [`vm86`].
8
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
9
pub enum Vm86Error {
10
    Eperm,
11
    Efault,
12
    Einval,
13
    Enomem,
14
    Enosys,
15
    Other(Errno),
16
}
17

18
impl Vm86Error {
19
    fn from_errno(errno: Errno) -> Self {
6✔
20
        match errno {
6✔
21
            Errno::Eperm => Self::Eperm,
1✔
22
            Errno::Efault => Self::Efault,
1✔
23
            Errno::Einval => Self::Einval,
1✔
24
            Errno::Enomem => Self::Enomem,
1✔
25
            Errno::Enosys => Self::Enosys,
1✔
26
            errno => Self::Other(errno),
1✔
27
        }
28
    }
6✔
29
}
30

31
/// Enter x86 virtual-8086 mode.
32
///
33
/// This wrapper replaces the raw pointer with `&mut Vm86Struct` and maps
34
/// errno-shaped failures into `Result<(), Vm86Error>`.
35
///
36
/// See [`sys::vm86`] for kernel behavior, ABI notes, reachable errors, and
37
/// source references.
38
///
39
/// # Safety
40
/// `v86` must remain valid for the entire vm86 session, and entering vm86 mode
41
/// can transfer control according to the register image stored in `v86`.
42
///
43
/// # Errors
44
/// - [`Vm86Error::Eperm`]: the kernel rejects the caller or nested vm86 state.
45
/// - [`Vm86Error::Efault`]: the kernel could not read the state record.
46
/// - [`Vm86Error::Einval`]: the state record contains rejected flags.
47
/// - [`Vm86Error::Enomem`]: the kernel could not allocate vm86 bookkeeping.
48
/// - [`Vm86Error::Enosys`]: the running kernel was built without vm86 support.
49
/// - [`Vm86Error::Other`]: any other errno reported by the raw ABI.
50
#[cfg(target_arch = "x86")]
NEW
51
pub unsafe fn vm86(v86: &mut Vm86Struct) -> Result<(), Vm86Error> {
×
NEW
52
    let ret = unsafe { sys::vm86(v86) };
×
NEW
53
    unit_from_ret(ret as isize, Vm86Error::from_errno)
×
NEW
54
}
×
55

56
#[cfg(test)]
57
#[cfg_attr(coverage_nightly, coverage(off))]
58
mod tests {
59
    use crate::Errno;
60

61
    use super::Vm86Error;
62

63
    #[test]
64
    fn test_vm86_error_mapping() {
65
        assert_eq!(Vm86Error::from_errno(Errno::Eperm), Vm86Error::Eperm);
66
        assert_eq!(Vm86Error::from_errno(Errno::Efault), Vm86Error::Efault);
67
        assert_eq!(Vm86Error::from_errno(Errno::Einval), Vm86Error::Einval);
68
        assert_eq!(Vm86Error::from_errno(Errno::Enomem), Vm86Error::Enomem);
69
        assert_eq!(Vm86Error::from_errno(Errno::Enosys), Vm86Error::Enosys);
70
        assert_eq!(
71
            Vm86Error::from_errno(Errno::Eio),
72
            Vm86Error::Other(Errno::Eio)
73
        );
74
    }
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc