Skip to content

Commit

Permalink
Use i64 to accomodate for device files' major and minor numbers
Browse files Browse the repository at this point in the history
This is meant as the final step in fixing ogham#1126.
  • Loading branch information
cesarpastorini committed May 4, 2023
1 parent b854e7d commit 58f5936
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/fs/fields.rs
Expand Up @@ -194,8 +194,8 @@ pub enum Size {
/// - <http://www.lanana.org/docs/device-list/devices-2.6+.txt>
#[derive(Copy, Clone)]
pub struct DeviceIDs {
pub major: u32,
pub minor: u32,
pub major: i64,
pub minor: i64,
}


Expand Down
6 changes: 4 additions & 2 deletions src/fs/file.rs
Expand Up @@ -336,9 +336,11 @@ impl<'dir> File<'dir> {
else if self.is_char_device() || self.is_block_device() {
let device_ids = self.metadata.rdev();

// SAFETY: `major()` and `minor()` can return an unsigned integer
// of at most 32bits, so an `i64` is going to accomodate them well
f::Size::DeviceIDs(f::DeviceIDs {
major: unsafe { major(device_ids) },
minor: unsafe { minor(device_ids) },
major: unsafe { major(device_ids) as i64 },
minor: unsafe { minor(device_ids) as i64 },
})
}
else {
Expand Down

0 comments on commit 58f5936

Please sign in to comment.