Skip to content

Commit c3a244b

Browse files
committed
Use Errno::OVERFLOW for y2038 errors.
On platforms where the underlying OS APIs are not y2038-ready, use `OVERFLOW` rather than `INVALID` if a y2038 time value is provided, to indicate that the time cannot be converted into a value that can be passed to the OS. This fixes tests/fs/y2038.rs and tests/time/y2038.re on 32-bit Linux systems which lack `statx`, and is consistent with what libc implementations do.
1 parent 3de3db9 commit c3a244b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/imp/linux_raw/fs/syscalls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ unsafe fn _utimensat_old(
12691269
.last_access
12701270
.tv_sec
12711271
.try_into()
1272-
.map_err(|_| io::Errno::INVAL)?,
1272+
.map_err(|_| io::Errno::OVERFLOW)?,
12731273
tv_nsec: times
12741274
.last_access
12751275
.tv_nsec
@@ -1281,7 +1281,7 @@ unsafe fn _utimensat_old(
12811281
.last_modification
12821282
.tv_sec
12831283
.try_into()
1284-
.map_err(|_| io::Errno::INVAL)?,
1284+
.map_err(|_| io::Errno::OVERFLOW)?,
12851285
tv_nsec: times
12861286
.last_modification
12871287
.tv_nsec

src/imp/linux_raw/time/syscalls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ unsafe fn timerfd_settime_old(
129129
.it_interval
130130
.tv_sec
131131
.try_into()
132-
.map_err(|_| io::Errno::INVAL)?,
132+
.map_err(|_| io::Errno::OVERFLOW)?,
133133
tv_nsec: new_value
134134
.it_interval
135135
.tv_nsec
@@ -141,7 +141,7 @@ unsafe fn timerfd_settime_old(
141141
.it_value
142142
.tv_sec
143143
.try_into()
144-
.map_err(|_| io::Errno::INVAL)?,
144+
.map_err(|_| io::Errno::OVERFLOW)?,
145145
tv_nsec: new_value
146146
.it_value
147147
.tv_nsec

0 commit comments

Comments
 (0)