• Home
  • Raw
  • Download

Lines Matching full:libc

79 use libc::c_int;
80 use libc::c_long;
81 use libc::fcntl;
82 use libc::pipe2;
83 use libc::syscall;
84 use libc::sysconf;
85 use libc::waitpid;
86 use libc::SYS_getpid;
87 use libc::SYS_getppid;
88 use libc::SYS_gettid;
89 use libc::EINVAL;
90 use libc::F_GETFL;
91 use libc::F_SETFL;
92 use libc::O_CLOEXEC;
93 pub(crate) use libc::PROT_READ;
94 pub(crate) use libc::PROT_WRITE;
95 use libc::SIGKILL;
96 use libc::WNOHANG;
97 use libc::_SC_IOV_MAX;
98 use libc::_SC_PAGESIZE;
130 /// Re-export libc types that are part of the API.
131 pub type Pid = libc::pid_t;
132 pub type Uid = libc::uid_t;
133 pub type Gid = libc::gid_t;
134 pub type Mode = libc::mode_t;
168 /// This bypasses `libc`'s caching `getpid(2)` wrapper which can be invalid if a raw clone was used
192 syscall!(unsafe { libc::getsid(pid.unwrap_or(0)) } as Pid) in getsid()
198 syscall!(unsafe { libc::setsid() as Pid }) in setsid()
205 unsafe { libc::geteuid() } in geteuid()
212 unsafe { libc::getegid() } in getegid()
219 syscall!(unsafe { libc::chown(path.as_ptr(), uid, gid) }).map(|_| ()) in chown()
226 syscall!(unsafe { libc::fchmod(fd.as_raw_fd(), mode) }).map(|_| ()) in fchmod()
233 syscall!(unsafe { libc::fchown(fd.as_raw_fd(), uid, gid) }).map(|_| ()) in fchown()
248 FlockOperation::LockShared => libc::LOCK_SH, in flock()
249 FlockOperation::LockExclusive => libc::LOCK_EX, in flock()
250 FlockOperation::Unlock => libc::LOCK_UN, in flock()
254 operation |= libc::LOCK_NB; in flock()
258 syscall!(unsafe { libc::flock(file.as_raw_fd(), operation) }).map(|_| ()) in flock()
276 let offset = if offset > libc::off64_t::max_value() as u64 { in fallocate()
277 return Err(Error::new(libc::EINVAL)); in fallocate()
279 offset as libc::off64_t in fallocate()
282 let len = if len > libc::off64_t::max_value() as u64 { in fallocate()
283 return Err(Error::new(libc::EINVAL)); in fallocate()
285 len as libc::off64_t in fallocate()
289 FallocateMode::PunchHole => libc::FALLOC_FL_PUNCH_HOLE, in fallocate()
290 FallocateMode::ZeroRange => libc::FALLOC_FL_ZERO_RANGE, in fallocate()
295 mode |= libc::FALLOC_FL_KEEP_SIZE; in fallocate()
300 syscall!(unsafe { libc::fallocate64(file.as_raw_fd(), mode, offset, len) }).map(|_| ()) in fallocate()
323 /// The second returned value is the ExitStatus from the libc::waitpid() call.
325 /// Note: this can block if libc::WNOHANG is not set and EINTR is not handled internally.
330 let ret = unsafe { libc::waitpid(pid, &mut status, options) }; in wait_for_pid()
358 /// Err(e) if e.errno() == libc::ECHILD => println!("no children left"),
413 syscall!(unsafe { fcntl(fd, libc::F_SETPIPE_SZ, size as c_int) }).map(|ret| ret as usize) in set_pipe_size()
493 let flags = unsafe { libc::fcntl(raw_fd, libc::F_GETFD) }; in validate_raw_fd()
494 if flags < 0 || (flags & libc::FD_CLOEXEC) != 0 { in validate_raw_fd()
495 return Err(Error::new(libc::EBADF)); in validate_raw_fd()
501 let dup_fd = unsafe { libc::fcntl(raw_fd, libc::F_DUPFD_CLOEXEC, 0) }; in validate_raw_fd()
513 let mut fds = libc::pollfd { in poll_in()
515 events: libc::POLLIN, in poll_in()
519 let ret = unsafe { libc::poll(&mut fds, 1, 0) }; in poll_in()
526 fds.revents & libc::POLLIN != 0 in poll_in()
565 pub fn duration_to_timespec(duration: Duration) -> libc::timespec { in duration_to_timespec()
568 libc::timespec { in duration_to_timespec()
569 tv_sec: duration.as_secs() as libc::time_t, in duration_to_timespec()
574 /// Return the maximum Duration that can be used with libc::timespec.
576 Duration::new(libc::time_t::max_value() as u64, 999999999) in max_timeout()
617 let mut buf = mem::MaybeUninit::<libc::rlimit64>::zeroed(); in get_max_open_files()
620 let res = unsafe { libc::prlimit64(0, libc::RLIMIT_NOFILE, ptr::null(), buf.as_mut_ptr()) }; in get_max_open_files()
633 Ok(unsafe { libc::sysconf(libc::_SC_NPROCESSORS_CONF) } as usize) in number_of_logical_cores()
667 add_fd_flags(tx.as_raw_fd(), libc::O_NONBLOCK).expect("Failed to set tx non blocking"); in pipe_size_and_fill()