MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / pread

Function pread

src/backend/linux_raw/io/syscalls.rs:47–105  ·  view source on GitHub ↗
(
    fd: BorrowedFd<'_>,
    buf: (*mut u8, usize),
    pos: u64,
)

Source from the content-addressed store, hash-verified

45
46#[inline]
47pub(crate) unsafe fn pread(
48 fd: BorrowedFd<'_>,
49 buf: (*mut u8, usize),
50 pos: u64,
51) -> io::Result<usize> {
52 // <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/kernel/sys32.c?h=v6.13#n70>
53 #[cfg(all(
54 target_pointer_width = "32",
55 any(
56 target_arch = "arm",
57 target_arch = "mips",
58 target_arch = "mips32r6",
59 target_arch = "powerpc"
60 ),
61 ))]
62 let r = ret_usize(syscall!(
63 __NR_pread64,
64 fd,
65 buf.0,
66 pass_usize(buf.1),
67 zero(),
68 hi(pos),
69 lo(pos)
70 ));
71
72 #[cfg(all(
73 target_pointer_width = "32",
74 not(any(
75 target_arch = "arm",
76 target_arch = "mips",
77 target_arch = "mips32r6",
78 target_arch = "powerpc"
79 )),
80 ))]
81 let r = ret_usize(syscall!(
82 __NR_pread64,
83 fd,
84 buf.0,
85 pass_usize(buf.1),
86 hi(pos),
87 lo(pos)
88 ));
89
90 #[cfg(target_pointer_width = "64")]
91 let r = ret_usize(syscall!(
92 __NR_pread64,
93 fd,
94 buf.0,
95 pass_usize(buf.1),
96 loff_t_from_u64(pos)
97 ));
98
99 #[cfg(sanitize_memory)]
100 if let Ok(len) = r {
101 crate::msan::unpoison(buf.0, len);
102 }
103
104 r

Callers

nothing calls this directly

Calls 1

ret_usizeFunction · 0.50

Tested by

no test coverage detected