Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name = "exa"
ansi_term = "0.12"
glob = "0.3"
lazy_static = "1.3"
libc = "0.2"
libc = "0.2.135"
locale = "0.2"
log = "0.4"
natord = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions src/fs/fields.rs
Original file line number Diff line number Diff line change
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: u8,
pub minor: u8,
pub major: i64,
pub minor: i64,
}


Expand Down
13 changes: 6 additions & 7 deletions src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::os::windows::fs::MetadataExt;
use std::path::{Path, PathBuf};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use libc::{major, minor};
use log::*;

use crate::fs::dir::Dir;
Expand Down Expand Up @@ -333,15 +334,13 @@ impl<'dir> File<'dir> {
f::Size::None
}
else if self.is_char_device() || self.is_block_device() {
let device_ids = self.metadata.rdev().to_be_bytes();
let device_ids = self.metadata.rdev();

// In C-land, getting the major and minor device IDs is done with
// preprocessor macros called `major` and `minor` that depend on
// the size of `dev_t`, but we just take the second-to-last and
// last bytes.
// 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: device_ids[6],
minor: device_ids[7],
major: unsafe { major(device_ids) as i64 },
minor: unsafe { minor(device_ids) as i64 },
})
}
else {
Expand Down