-
-
Notifications
You must be signed in to change notification settings - Fork 660
Display the right major and minor device IDs when encountering block or char devices #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems that I found the reason, pub struct DeviceIDs {
pub major: u8,
pub minor: u8,
}
|
For someone who is interested in implementing this, you need The impl is basically something like this: f::Size::DeviceIDs(f::DeviceIDs {
major: unsafe{major(device_ids as dev_t)},
minor: unsafe{minor(device_ids as dev_t)},
}) #[derive(Copy, Clone)]
pub struct DeviceIDs {
pub major: u32,
pub minor: u32,
} What you need to fight is the difference between Linux's major()/minor()` definitions and the macOS one: # Linux
pub type dev_t = u64;
pub fn major(dev: ::dev_t) -> ::c_uint;
pub fn minor(dev: ::dev_t) -> ::c_uint;
# macOS
pub type dev_t = i32;
pub fn major(dev: dev_t) -> i32;
pub fn minor(dev: dev_t) -> i32; |
This is meant as the final step in fixing ogham#1126.
This is meant as the final step in fixing ogham#1126. The different build targets of Rust libc's `major()` and `minor()` functions have conflicting return types like `c_uint`, `c_int` and `i32`, so an `i64` should be able to represent all of them.
I noticed that the device ID returned by
exa
is wrong:And this behavior is actually documented in the source code:
https://github.com/ogham/exa/blob/master/src/fs/file.rs#L321~L332
Any reason why it is not correctly decomposed and returned?
The text was updated successfully, but these errors were encountered: