summaryrefslogtreecommitdiff
path: root/src/sys.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2014-08-16 18:45:34 -0700
committerCarl Lerche <me@carllerche.com>2014-08-16 18:45:34 -0700
commit2442e299e80724d813fffa9a11a6fe86227f488b (patch)
tree8e4c167dc6ea15a1845d77fc06830722ab65997d /src/sys.rs
parent78cd78bbdac732bf2114bdfadb564cd4f7232365 (diff)
downloadnix-2442e299e80724d813fffa9a11a6fe86227f488b.zip
Epoll, rename to nix, misc cleanup
Diffstat (limited to 'src/sys.rs')
-rw-r--r--src/sys.rs51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/sys.rs b/src/sys.rs
deleted file mode 100644
index 1aa19534..00000000
--- a/src/sys.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-pub mod stat {
- pub use libc::dev_t;
-
- use std::fmt;
- use std::io::FilePermission;
- use std::path::Path;
- use libc::mode_t;
- use errno::{SysResult, from_ffi};
-
- mod ffi {
- use libc::{c_char, c_int, mode_t, dev_t};
-
- extern {
- pub fn mknod(pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
- pub fn umask(mask: mode_t) -> mode_t;
- }
- }
-
- bitflags!(
- flags SFlag: mode_t {
- static S_IFREG = 0o100000,
- static S_IFCHR = 0o020000,
- static S_IFBLK = 0o060000,
- static S_IFIFO = 0o010000,
- static S_IFSOCK = 0o140000
- }
- )
-
- impl fmt::Show for SFlag {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(fmt, "SFlag {{ bits: {} }}", self.bits())
- }
- }
-
- pub fn mknod(path: &Path, kind: SFlag, perm: FilePermission, dev: dev_t) -> SysResult<()> {
- let res = unsafe { ffi::mknod(path.to_c_str().as_ptr(), kind.bits | perm.bits(), dev) };
- from_ffi(res)
- }
-
- static MINORBITS: uint = 20;
- static MINORMASK: dev_t = ((1 << MINORBITS) - 1);
-
- pub fn mkdev(major: u64, minor: u64) -> dev_t {
- (major << MINORBITS) | minor
- }
-
- pub fn umask(mode: FilePermission) -> FilePermission {
- let prev = unsafe { ffi::umask(mode.bits()) };
- FilePermission::from_bits(prev).expect("[BUG] umask returned invalid FilePermission")
- }
-}