mod.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //! fcntl implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html
  2. use platform::types::*;
  3. use platform::{Pal, Sys};
  4. pub use self::sys::*;
  5. #[cfg(target_os = "linux")]
  6. #[path = "linux.rs"]
  7. pub mod sys;
  8. #[cfg(target_os = "redox")]
  9. #[path = "redox.rs"]
  10. pub mod sys;
  11. pub const F_DUPFD: c_int = 0;
  12. pub const F_GETFD: c_int = 1;
  13. pub const F_SETFD: c_int = 2;
  14. pub const F_GETFL: c_int = 3;
  15. pub const F_SETFL: c_int = 4;
  16. pub const F_GETLK: c_int = 5;
  17. pub const F_SETLK: c_int = 6;
  18. pub const F_SETLKW: c_int = 7;
  19. pub const FD_CLOEXEC: c_int = 0x0100_0000;
  20. pub const F_RDLCK: c_int = 0;
  21. pub const F_WRLCK: c_int = 1;
  22. pub const F_UNLCK: c_int = 2;
  23. #[no_mangle]
  24. pub extern "C" fn creat(path: *const c_char, mode: mode_t) -> c_int {
  25. sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)
  26. }
  27. #[no_mangle]
  28. pub extern "C" fn sys_fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int {
  29. Sys::fcntl(fildes, cmd, arg)
  30. }
  31. #[no_mangle]
  32. pub extern "C" fn sys_open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
  33. Sys::open(path, oflag, mode)
  34. }