Skip to content

Commit 7266eb4

Browse files
authored
Mark a few more system calls as readonly. (#912)
Mark the `TIOCSWINSZ` ioctl, `timerfd_create`, and the feature-test call to `statx` as "readonly", since they don't mutate memory.
1 parent f60c7dc commit 7266eb4

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/backend/linux_raw/fs/syscalls.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,10 @@ pub(crate) fn statx(
846846
pub(crate) fn is_statx_available() -> bool {
847847
unsafe {
848848
// Call `statx` with null pointers so that if it fails for any reason
849-
// other than `EFAULT`, we know it's not supported.
849+
// other than `EFAULT`, we know it's not supported. This can use
850+
// "readonly" because we don't pass it a buffer to mutate.
850851
matches!(
851-
ret(syscall!(
852+
ret(syscall_readonly!(
852853
__NR_statx,
853854
raw_fd(AT_FDCWD),
854855
zero(),

src/backend/linux_raw/termios/syscalls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub(crate) fn tcgetsid(fd: BorrowedFd<'_>) -> io::Result<Pid> {
174174
#[inline]
175175
pub(crate) fn tcsetwinsize(fd: BorrowedFd<'_>, winsize: Winsize) -> io::Result<()> {
176176
unsafe {
177-
ret(syscall!(
177+
ret(syscall_readonly!(
178178
__NR_ioctl,
179179
fd,
180180
c_uint(TIOCSWINSZ),

src/backend/linux_raw/time/syscalls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ unsafe fn clock_settime_old(which_clock: ClockId, timespec: Timespec) -> io::Res
104104
#[cfg(feature = "time")]
105105
#[inline]
106106
pub(crate) fn timerfd_create(clockid: TimerfdClockId, flags: TimerfdFlags) -> io::Result<OwnedFd> {
107-
unsafe { ret_owned_fd(syscall!(__NR_timerfd_create, clockid, flags)) }
107+
unsafe { ret_owned_fd(syscall_readonly!(__NR_timerfd_create, clockid, flags)) }
108108
}
109109

110110
#[cfg(feature = "time")]

0 commit comments

Comments
 (0)