Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions cap-primitives/src/rustix/fs/metadata_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ impl ImplMetadataExt {
created: None,

ext: Self {
// The type of `st_dev` is `dev_t` which is signed on some
// platforms and unsigned on other platforms. A `u64` is enough
// to work for all unsigned platforms, and for signed platforms
// perform a sign extension to `i64` and then view that as an
// unsigned 64-bit number instead.
// The type of `st_dev` and `st_rdev` is `dev_t` which is
// signed on some platforms and unsigned on other platforms. A
// `u64` is enough to work for all unsigned platforms, and for
// signed platforms perform a sign extension to `i64` and then
// view that as an unsigned 64-bit number instead.
//
// Note that the `unused_comparisons` is ignored here for
// platforms where it's unsigned since the first branch here
Expand All @@ -168,7 +168,11 @@ impl ImplMetadataExt {
#[cfg(not(target_os = "wasi"))]
gid: stat.st_gid,
#[cfg(not(target_os = "wasi"))]
rdev: u64::try_from(stat.st_rdev).unwrap(),
rdev: if stat.st_rdev < 0 {
i64::try_from(stat.st_rdev).unwrap() as u64
} else {
u64::try_from(stat.st_rdev).unwrap()
},
#[cfg(not(target_os = "wasi"))]
size: u64::try_from(stat.st_size).unwrap(),
#[cfg(not(target_os = "wasi"))]
Expand Down
Loading