summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/unix/notbsd/android/mod.rs11
-rw-r--r--src/unix/notbsd/linux/mod.rs25
2 files changed, 36 insertions, 0 deletions
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index 3eace010ad..547d8327db 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -753,6 +753,17 @@ f! {
pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
set1.__bits == set2.__bits
}
+ pub fn major(dev: ::dev_t) -> ::c_int {
+ ((dev >> 8) & 0xfff) as ::c_int
+ }
+ pub fn minor(dev: ::dev_t) -> ::c_int {
+ ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as ::c_int
+ }
+ pub fn makedev(ma: ::c_int, mi: ::c_int) -> ::dev_t {
+ let ma = ma as ::dev_t;
+ let mi = mi as ::dev_t;
+ ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12)
+ }
}
extern {
diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs
index 9774f93f6d..3df6dabf09 100644
--- a/src/unix/notbsd/linux/mod.rs
+++ b/src/unix/notbsd/linux/mod.rs
@@ -722,6 +722,31 @@ f! {
pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
set1.bits == set2.bits
}
+
+ pub fn major(dev: ::dev_t) -> ::c_uint {
+ let mut major = 0;
+ major |= (dev & 0x00000000000fff00) >> 8;
+ major |= (dev & 0xfffff00000000000) >> 32;
+ major as ::c_uint
+ }
+
+ pub fn minor(dev: ::dev_t) -> ::c_uint {
+ let mut minor = 0;
+ minor |= (dev & 0xfffff00000000000) >> 0;
+ minor |= (dev & 0x00000ffffff00000) >> 12;
+ minor as ::c_uint
+ }
+
+ pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
+ let major = major as ::dev_t;
+ let minor = minor as ::dev_t;
+ let mut dev = 0;
+ dev |= (major & 0x00000fff) << 8;
+ dev |= (major & 0xfffff000) << 32;
+ dev |= (minor & 0x000000ff) << 0;
+ dev |= (minor & 0xffffff00) << 12;
+ dev
+ }
}
extern {