| 1 |
//! Header: `unistd.h` |
| 2 |
|
| 3 |
use super::*; |
| 4 |
pub use crate::new::common::posix::unistd::{ |
| 5 |
STDERR_FILENO, |
| 6 |
STDIN_FILENO, |
| 7 |
STDOUT_FILENO, |
| 8 |
}; |
| 9 |
use crate::prelude::*; |
| 10 |
|
| 11 |
// Access mode constants |
| 12 |
pub const F_OK: c_int = 0; |
| 13 |
pub const X_OK: c_int = 1; |
| 14 |
pub const W_OK: c_int = 2; |
| 15 |
pub const R_OK: c_int = 4; |
| 16 |
|
| 17 |
// Whence constants for lseek |
| 18 |
pub const SEEK_SET: c_int = 0; |
| 19 |
pub const SEEK_CUR: c_int = 1; |
| 20 |
pub const SEEK_END: c_int = 2; |
| 21 |
|
| 22 |
extern "C" { |
| 23 |
// File operations |
| 24 |
pub fn access(pathname: *const c_char, mode: c_int) -> c_int; |
| 25 |
pub fn close(fd: c_int) -> c_int; |
| 26 |
pub fn dup(oldfd: c_int) -> c_int; |
| 27 |
pub fn dup2(oldfd: c_int, newfd: c_int) -> c_int; |
| 28 |
pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; |
| 29 |
pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; |
| 30 |
pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; |
| 31 |
|
| 32 |
// Process operations |
| 33 |
pub fn getpid() -> pid_t; |
| 34 |
pub fn getppid() -> pid_t; |
| 35 |
pub fn getuid() -> uid_t; |
| 36 |
pub fn geteuid() -> uid_t; |
| 37 |
pub fn getgid() -> gid_t; |
| 38 |
pub fn getegid() -> gid_t; |
| 39 |
pub fn getpgid(pid: pid_t) -> pid_t; |
| 40 |
pub fn getpgrp() -> pid_t; |
| 41 |
pub fn setpgrp() -> pid_t; |
| 42 |
pub fn seteuid(uid: uid_t) -> c_int; |
| 43 |
pub fn setuid(uid: uid_t) -> c_int; |
| 44 |
pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; |
| 45 |
pub fn setsid() -> pid_t; |
| 46 |
|
| 47 |
// File synchronization |
| 48 |
pub fn fsync(fd: c_int) -> c_int; |
| 49 |
|
| 50 |
// Sleep functions |
| 51 |
pub fn sleep(seconds: c_uint) -> c_uint; |
| 52 |
pub fn usleep(usec: useconds_t) -> c_int; |
| 53 |
|
| 54 |
// System configuration |
| 55 |
pub fn sysconf(name: c_int) -> c_long; |
| 56 |
pub fn pathconf(path: *const c_char, name: c_int) -> c_long; |
| 57 |
pub fn fpathconf(fd: c_int, name: c_int) -> c_long; |
| 58 |
} |