Skip to content

Commit

Permalink
Make st_mtime etc. signed.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Jan 31, 2025
1 parent 28667f1 commit 7e38794
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/backend/libc/fs/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1862,17 +1862,17 @@ fn stat64_to_stat(s64: c::stat64) -> io::Result<Stat> {
st_size: s64.st_size.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_blksize: s64.st_blksize.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_blocks: s64.st_blocks.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_atime: bitcast!(i64::from(s64.st_atime)),
st_atime: i64::from(s64.st_atime),
st_atime_nsec: s64
.st_atime_nsec
.try_into()
.map_err(|_| io::Errno::OVERFLOW)?,
st_mtime: bitcast!(i64::from(s64.st_mtime)),
st_mtime: i64::from(s64.st_mtime),
st_mtime_nsec: s64
.st_mtime_nsec
.try_into()
.map_err(|_| io::Errno::OVERFLOW)?,
st_ctime: bitcast!(i64::from(s64.st_ctime)),
st_ctime: i64::from(s64.st_ctime),
st_ctime_nsec: s64
.st_ctime_nsec
.try_into()
Expand Down
18 changes: 9 additions & 9 deletions src/backend/linux_raw/fs/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,11 @@ fn statx_to_stat(x: crate::fs::Statx) -> io::Result<Stat> {
st_size: x.stx_size.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_blksize: x.stx_blksize.into(),
st_blocks: x.stx_blocks.into(),
st_atime: bitcast!(i64::from(x.stx_atime.tv_sec)),
st_atime: i64::from(x.stx_atime.tv_sec),
st_atime_nsec: x.stx_atime.tv_nsec.into(),
st_mtime: bitcast!(i64::from(x.stx_mtime.tv_sec)),
st_mtime: i64::from(x.stx_mtime.tv_sec),
st_mtime_nsec: x.stx_mtime.tv_nsec.into(),
st_ctime: bitcast!(i64::from(x.stx_ctime.tv_sec)),
st_ctime: i64::from(x.stx_ctime.tv_sec),
st_ctime_nsec: x.stx_ctime.tv_nsec.into(),
st_ino: x.stx_ino.into(),
})
Expand All @@ -754,17 +754,17 @@ fn stat_to_stat(s64: linux_raw_sys::general::stat64) -> io::Result<Stat> {
st_size: s64.st_size.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_blksize: s64.st_blksize.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_blocks: s64.st_blocks.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_atime: bitcast!(i64::from(s64.st_atime)),
st_atime: i64::from(s64.st_atime),
st_atime_nsec: s64
.st_atime_nsec
.try_into()
.map_err(|_| io::Errno::OVERFLOW)?,
st_mtime: bitcast!(i64::from(s64.st_mtime)),
st_mtime: i64::from(s64.st_mtime),
st_mtime_nsec: s64
.st_mtime_nsec
.try_into()
.map_err(|_| io::Errno::OVERFLOW)?,
st_ctime: bitcast!(i64::from(s64.st_ctime)),
st_ctime: i64::from(s64.st_ctime),
st_ctime_nsec: s64
.st_ctime_nsec
.try_into()
Expand All @@ -786,17 +786,17 @@ fn stat_to_stat(s: linux_raw_sys::general::stat) -> io::Result<Stat> {
st_size: s.st_size.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_blksize: s.st_blksize.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_blocks: s.st_blocks.try_into().map_err(|_| io::Errno::OVERFLOW)?,
st_atime: bitcast!(i64::from(s.st_atime)),
st_atime: i64::from(s.st_atime),
st_atime_nsec: s
.st_atime_nsec
.try_into()
.map_err(|_| io::Errno::OVERFLOW)?,
st_mtime: bitcast!(i64::from(s.st_mtime)),
st_mtime: i64::from(s.st_mtime),
st_mtime_nsec: s
.st_mtime_nsec
.try_into()
.map_err(|_| io::Errno::OVERFLOW)?,
st_ctime: bitcast!(i64::from(s.st_ctime)),
st_ctime: i64::from(s.st_ctime),
st_ctime_nsec: s
.st_ctime_nsec
.try_into()
Expand Down
18 changes: 9 additions & 9 deletions src/backend/linux_raw/fs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,11 @@ pub struct Stat {
pub st_size: ffi::c_long,
pub st_blksize: ffi::c_long,
pub st_blocks: ffi::c_long,
pub st_atime: ffi::c_ulong,
pub st_atime: ffi::c_long,
pub st_atime_nsec: ffi::c_ulong,
pub st_mtime: ffi::c_ulong,
pub st_mtime: ffi::c_long,
pub st_mtime_nsec: ffi::c_ulong,
pub st_ctime: ffi::c_ulong,
pub st_ctime: ffi::c_long,
pub st_ctime_nsec: ffi::c_ulong,
pub(crate) __unused: [ffi::c_long; 3],
}
Expand Down Expand Up @@ -715,11 +715,11 @@ pub struct Stat {
pub st_size: ffi::c_long,
pub st_blksize: ffi::c_ulong,
pub st_blocks: ffi::c_ulong,
pub st_atime: ffi::c_ulong,
pub st_atime: ffi::c_long,
pub st_atime_nsec: ffi::c_ulong,
pub st_mtime: ffi::c_ulong,
pub st_mtime: ffi::c_long,
pub st_mtime_nsec: ffi::c_ulong,
pub st_ctime: ffi::c_ulong,
pub st_ctime: ffi::c_long,
pub st_ctime_nsec: ffi::c_ulong,
pub(crate) __unused4: ffi::c_ulong,
pub(crate) __unused5: ffi::c_ulong,
Expand All @@ -740,11 +740,11 @@ pub struct Stat {
pub(crate) __pad1: ffi::c_uint,
pub st_rdev: ffi::c_ulong,
pub st_size: ffi::c_ulong,
pub st_atime: ffi::c_ulong,
pub st_atime: ffi::c_long,
pub st_atime_nsec: ffi::c_ulong,
pub st_mtime: ffi::c_ulong,
pub st_mtime: ffi::c_long,
pub st_mtime_nsec: ffi::c_ulong,
pub st_ctime: ffi::c_ulong,
pub st_ctime: ffi::c_long,
pub st_ctime_nsec: ffi::c_ulong,
pub st_blksize: ffi::c_ulong,
pub st_blocks: ffi::c_long,
Expand Down

0 comments on commit 7e38794

Please sign in to comment.