瀏覽代碼

Add pathconf variables

Jeremy Soller 6 年之前
父節點
當前提交
99fa77535a
共有 4 個文件被更改,包括 46 次插入17 次删除
  1. 2 0
      include/limits.h
  2. 4 3
      src/unistd/src/getopt.rs
  3. 7 14
      src/unistd/src/lib.rs
  4. 33 0
      src/unistd/src/pathconf.rs

+ 2 - 0
include/limits.h

@@ -23,3 +23,5 @@
 #define ULONG_MAX ((1 << 64) - 1)
 #define USHRT_MAX ((1 << 16) - 1)
 #define WORD_BIT 32
+
+#define PATH_MAX 4096

+ 4 - 3
src/unistd/src/getopt.rs

@@ -1,10 +1,11 @@
 //! getopt implementation for Redox, following http://pubs.opengroup.org/onlinepubs/009695399/functions/getopt.html
 
-use super::platform::types::*;
-use super::stdio;
-use super::string;
 use core::ptr;
 
+use platform::types::*;
+use stdio;
+use string;
+
 #[allow(non_upper_case_globals)]
 #[no_mangle]
 pub static mut optarg: *mut c_char = ptr::null_mut();

+ 7 - 14
src/unistd/src/lib.rs

@@ -11,14 +11,17 @@ extern crate stdio;
 extern crate string;
 extern crate sys_utsname;
 
+use core::ptr;
+
+use platform::types::*;
+
 pub use brk::*;
 pub use getopt::*;
-pub use platform::types::*;
-
-use core::ptr;
+pub use pathconf::*;
 
 mod brk;
 mod getopt;
+mod pathconf;
 
 pub const R_OK: c_int = 1;
 pub const W_OK: c_int = 2;
@@ -39,7 +42,7 @@ pub const STDOUT_FILENO: c_int = 1;
 pub const STDERR_FILENO: c_int = 2;
 
 #[no_mangle]
-pub static mut environ: *const *mut c_char = ptr::null();
+pub static mut environ: *mut *mut c_char = ptr::null();
 
 #[no_mangle]
 pub extern "C" fn _exit(status: c_int) {
@@ -159,11 +162,6 @@ pub extern "C" fn fork() -> pid_t {
     platform::fork()
 }
 
-#[no_mangle]
-pub extern "C" fn fpathconf(fildes: c_int, name: c_int) -> c_long {
-    unimplemented!();
-}
-
 #[no_mangle]
 pub extern "C" fn fsync(fildes: c_int) -> c_int {
     platform::fsync(fildes)
@@ -346,11 +344,6 @@ pub extern "C" fn nice(incr: c_int) -> c_int {
     unimplemented!();
 }
 
-#[no_mangle]
-pub extern "C" fn pathconf(path: *const c_char, name: c_int) -> c_long {
-    unimplemented!();
-}
-
 #[no_mangle]
 pub extern "C" fn pause() -> c_int {
     unimplemented!();

+ 33 - 0
src/unistd/src/pathconf.rs

@@ -0,0 +1,33 @@
+use platform::types::*;
+
+pub const _PC_LINK_MAX: c_int = 0;
+pub const _PC_MAX_CANON: c_int = 1;
+pub const _PC_MAX_INPUT: c_int = 2;
+pub const _PC_NAME_MAX: c_int = 3;
+pub const _PC_PATH_MAX: c_int = 4;
+pub const _PC_PIPE_BUF: c_int = 5;
+pub const _PC_CHOWN_RESTRICTED: c_int = 6;
+pub const _PC_NO_TRUNC: c_int = 7;
+pub const _PC_VDISABLE: c_int = 8;
+pub const _PC_SYNC_IO: c_int = 9;
+pub const _PC_ASYNC_IO: c_int = 10;
+pub const _PC_PRIO_IO: c_int = 11;
+pub const _PC_SOCK_MAXBUF: c_int = 12;
+pub const _PC_FILESIZEBITS: c_int = 13;
+pub const _PC_REC_INCR_XFER_SIZE: c_int = 14;
+pub const _PC_REC_MAX_XFER_SIZE: c_int = 15;
+pub const _PC_REC_MIN_XFER_SIZE: c_int = 16;
+pub const _PC_REC_XFER_ALIGN: c_int = 17;
+pub const _PC_ALLOC_SIZE_MIN: c_int = 18;
+pub const _PC_SYMLINK_MAX: c_int = 19;
+pub const _PC_2_SYMLINKS: c_int = 20;
+
+#[no_mangle]
+pub extern "C" fn fpathconf(fildes: c_int, name: c_int) -> c_long {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn pathconf(path: *const c_char, name: c_int) -> c_long {
+    unimplemented!();
+}