Browse Source

Implement fcntl

No tests written yet! See #36
MggMuggins 7 years ago
parent
commit
14c8125108
3 changed files with 9 additions and 1 deletions
  1. 1 1
      src/fcntl/src/lib.rs
  2. 4 0
      src/platform/src/linux/mod.rs
  3. 4 0
      src/platform/src/redox/mod.rs

+ 1 - 1
src/fcntl/src/lib.rs

@@ -38,7 +38,7 @@ pub extern "C" fn creat(path: *const c_char, mode: mode_t) -> c_int {
 
 #[no_mangle]
 pub extern "C" fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int {
-    unimplemented!();
+    platform::fcntl(fildes, cmd, arg)
 }
 
 #[no_mangle]

+ 4 - 0
src/platform/src/linux/mod.rs

@@ -62,6 +62,10 @@ pub fn fchdir(fildes: c_int) -> c_int {
     e(unsafe { syscall!(FCHDIR, fildes) }) as c_int
 }
 
+pub fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int {
+    e(unsafe { syscall!(FCNTL, fildes, cmd, arg) }) as c_int
+}
+
 pub fn fork() -> pid_t {
     e(unsafe { syscall!(FORK) }) as pid_t
 }

+ 4 - 0
src/platform/src/redox/mod.rs

@@ -63,6 +63,10 @@ pub fn fchdir(fd: c_int) -> c_int {
     }
 }
 
+pub fn fcntl(fd: c_int, cmd: c_int, args: c_int) -> c_int {
+    e(syscall::fcntl(fd, cmd, args)) as c_int
+}
+
 pub fn fork() -> pid_t {
     e(unsafe { syscall::clone(0) }) as pid_t
 }