• Home
  • Raw
  • Download

Lines Matching full:libc

119     ino: libc::ino64_t,
120 dev: libc::dev_t,
130 impl From<libc::mode_t> for FileType {
131 fn from(mode: libc::mode_t) -> Self { in from()
132 match mode & libc::S_IFMT { in from()
133 libc::S_IFREG => FileType::Regular, in from()
134 libc::S_IFDIR => FileType::Directory, in from()
143 file: Mutex<(File, libc::c_int)>,
185 // libc uses signals to ensure that when one thread changes its
195 let res = unsafe { libc::syscall($syscall_nr, -1, val, -1) };
206 let res = unsafe { libc::syscall($syscall_nr, -1, self.old, -1) };
219 scoped_cred!(ScopedUid, libc::uid_t, libc::SYS_setresuid);
221 scoped_cred!(ScopedUid, libc::uid_t, libc::SYS_setresuid32);
224 scoped_cred!(ScopedGid, libc::gid_t, libc::SYS_setresgid);
226 scoped_cred!(ScopedGid, libc::gid_t, libc::SYS_setresgid32);
229 const SYS_GETEUID: libc::c_long = libc::SYS_geteuid;
231 const SYS_GETEUID: libc::c_long = libc::SYS_geteuid32;
234 const SYS_GETEGID: libc::c_long = libc::SYS_getegid;
236 const SYS_GETEGID: libc::c_long = libc::SYS_getegid32;
241 static THREAD_EUID: libc::uid_t = unsafe { libc::syscall(SYS_GETEUID) as libc::uid_t };
242 static THREAD_EGID: libc::gid_t = unsafe { libc::syscall(SYS_GETEGID) as libc::gid_t };
246 uid: libc::uid_t, in set_creds()
247 gid: libc::gid_t, in set_creds()
258 old: libc::mode_t,
259 mask: libc::mode_t,
266 let previous = unsafe { libc::umask(self.old) }; in drop()
277 fn set(&mut self, mask: libc::mode_t) -> ScopedUmask { in set()
280 old: unsafe { libc::umask(mask) }, in set()
314 io::Error::from_raw_os_error(libc::EBADF) in ebadf()
317 fn stat<F: AsRawDescriptor>(f: &F) -> io::Result<libc::stat64> { in stat()
318 let mut st = MaybeUninit::<libc::stat64>::zeroed(); in stat()
326 libc::fstatat64( in stat()
330 libc::AT_EMPTY_PATH | libc::AT_SYMLINK_NOFOLLOW, in stat()
341 fn statat<D: AsRawDescriptor>(dir: &D, name: &CStr) -> io::Result<libc::stat64> { in statat()
342 let mut st = MaybeUninit::<libc::stat64>::zeroed(); in statat()
347 libc::fstatat64( in statat()
351 libc::AT_SYMLINK_NOFOLLOW, in statat()
515 libc::openat( in new()
516 libc::AT_FDCWD, in new()
518 libc::O_PATH | libc::O_NOFOLLOW | libc::O_CLOEXEC, in new()
596 libc::openat( in open_fd()
599 (flags | libc::O_CLOEXEC) & !(libc::O_NOFOLLOW | libc::O_DIRECT), in open_fd()
615 if writeback && flags & libc::O_ACCMODE == libc::O_WRONLY { in open_inode()
616 flags &= !libc::O_ACCMODE; in open_inode()
617 flags |= libc::O_RDWR; in open_inode()
626 if writeback && flags & libc::O_APPEND != 0 { in open_inode()
627 flags &= !libc::O_APPEND; in open_inode()
634 fn add_entry(&self, f: File, st: libc::stat64, open_flags: libc::c_int) -> Entry { in add_entry()
687 offset = entry.offset as libc::off64_t; in ascii_casefold_lookup()
693 Err(io::Error::from_raw_os_error(libc::ENOENT)) in ascii_casefold_lookup()
699 let mut flags = libc::O_RDONLY | libc::O_NOFOLLOW | libc::O_CLOEXEC; in do_lookup()
702 FileType::Directory => flags |= libc::O_DIRECTORY, in do_lookup()
703 FileType::Other => flags |= libc::O_PATH, in do_lookup()
707 let fd = unsafe { libc::openat(parent.as_raw_descriptor(), name.as_ptr(), flags) }; in do_lookup()
733 flags & (libc::O_DIRECTORY as u32) == 0, in do_open()
736 opts |= if flags & (libc::O_DIRECTORY as u32) == 0 { in do_open()
763 fn do_getattr(&self, inode: &InodeData) -> io::Result<(libc::stat64, Duration)> { in do_getattr()
769 fn do_unlink(&self, parent: &InodeData, name: &CStr, flags: libc::c_int) -> io::Result<()> { in do_unlink()
771 let res = unsafe { libc::unlinkat(parent.as_raw_descriptor(), name.as_ptr(), flags) }; in do_unlink()
783 libc::fdatasync(file.as_raw_descriptor()) in do_fsync()
785 libc::fsync(file.as_raw_descriptor()) in do_fsync()
809 let proc_cwd = unsafe { libc::fchdir(self.proc.as_raw_descriptor()) }; in with_proc_chdir()
821 let root_cwd = unsafe { libc::fchdir(root.as_raw_descriptor()) }; in with_proc_chdir()
843 libc::getxattr( in do_getxattr()
846 value.as_mut_ptr() as *mut libc::c_void, in do_getxattr()
847 value.len() as libc::size_t, in do_getxattr()
854 libc::fgetxattr( in do_getxattr()
857 value.as_mut_ptr() as *mut libc::c_void, in do_getxattr()
858 value.len() as libc::size_t, in do_getxattr()
1058 let flags = libc::O_DIRECTORY | libc::O_NOFOLLOW | libc::O_CLOEXEC; in init()
1060 let raw_descriptor = unsafe { libc::openat(libc::AT_FDCWD, root.as_ptr(), flags) }; in init()
1073 unsafe { libc::umask(0o000) }; in init()
1119 fn statfs(&self, _ctx: Context, inode: Inode) -> io::Result<libc::statvfs64> { in statfs()
1122 let mut out = MaybeUninit::<libc::statvfs64>::zeroed(); in statfs()
1125 let res = unsafe { libc::fstatvfs64(data.as_raw_descriptor(), out.as_mut_ptr()) }; in statfs()
1166 Err(io::Error::from_raw_os_error(libc::ENOSYS)) in opendir()
1168 self.do_open(inode, flags | (libc::O_DIRECTORY as u32)) in opendir()
1202 unsafe { libc::mkdirat(data.as_raw_descriptor(), name.as_ptr(), mode) } in mkdir()
1213 self.do_unlink(&data, name, libc::AT_REMOVEDIR) in rmdir()
1228 ReadDir::new(&*data, offset as libc::off64_t, buf) in readdir()
1234 ReadDir::new(&*dir, offset as libc::off64_t, buf) in readdir()
1245 Err(io::Error::from_raw_os_error(libc::ENOSYS)) in open()
1279 let tmpflags = libc::O_RDWR | libc::O_TMPFILE | libc::O_CLOEXEC | libc::O_NOFOLLOW; in chromeos_tmpfile()
1290 libc::openat( in chromeos_tmpfile()
1323 (flags as i32 | libc::O_CREAT | libc::O_CLOEXEC | libc::O_NOFOLLOW) & !libc::O_DIRECT; in create()
1332 unsafe { libc::openat(data.as_raw_descriptor(), name.as_ptr(), create_flags, mode) } in create()
1349 flags & !((libc::O_CREAT | libc::O_EXCL | libc::O_NOCTTY) as u32), in create()
1382 match flags & libc::O_ACCMODE { in read()
1383 libc::O_WRONLY => { in read()
1384 flags &= !libc::O_WRONLY; in read()
1385 flags |= libc::O_RDWR; in read()
1388 let newfile = self.open_fd(file.0.as_raw_descriptor(), libc::O_RDWR)?; in read()
1391 libc::O_RDONLY | libc::O_RDWR => {} in read()
1429 match flags & libc::O_ACCMODE { in write()
1430 libc::O_RDONLY => { in write()
1431 flags &= !libc::O_RDONLY; in write()
1432 flags |= libc::O_RDWR; in write()
1435 let newfile = self.open_fd(file.0.as_raw_descriptor(), libc::O_RDWR)?; in write()
1438 libc::O_WRONLY | libc::O_RDWR => {} in write()
1456 ) -> io::Result<(libc::stat64, Duration)> { in getattr()
1465 attr: libc::stat64, in setattr()
1468 ) -> io::Result<(libc::stat64, Duration)> { in setattr()
1492 Data::Handle(_, fd) => libc::fchmod(fd, attr.st_mode), in setattr()
1494 libc::fchmodat(self.proc.as_raw_descriptor(), p.as_ptr(), attr.st_mode, 0) in setattr()
1522 libc::fchownat( in setattr()
1527 libc::AT_EMPTY_PATH | libc::AT_SYMLINK_NOFOLLOW, in setattr()
1538 Data::Handle(_, fd) => unsafe { libc::ftruncate64(fd, attr.st_size) }, in setattr()
1541 let f = self.open_inode(&inode_data, libc::O_NONBLOCK | libc::O_RDWR)?; in setattr()
1542 unsafe { libc::ftruncate64(f.as_raw_descriptor(), attr.st_size) } in setattr()
1552 libc::timespec { in setattr()
1554 tv_nsec: libc::UTIME_OMIT, in setattr()
1556 libc::timespec { in setattr()
1558 tv_nsec: libc::UTIME_OMIT, in setattr()
1563 tvs[0].tv_nsec = libc::UTIME_NOW; in setattr()
1570 tvs[1].tv_nsec = libc::UTIME_NOW; in setattr()
1578 Data::Handle(_, fd) => unsafe { libc::futimens(fd, tvs.as_ptr()) }, in setattr()
1580 libc::utimensat(self.proc.as_raw_descriptor(), p.as_ptr(), tvs.as_ptr(), 0) in setattr()
1604 // TODO: Switch to libc::renameat2 once https://github.com/rust-lang/libc/pull/1508 lands in rename()
1607 libc::syscall( in rename()
1608 libc::SYS_renameat2, in rename()
1642 libc::mknodat( in mknod()
1645 mode as libc::mode_t, in mknod()
1646 rdev as libc::dev_t, in mknod()
1673 libc::linkat( in link()
1678 libc::AT_SYMLINK_FOLLOW, in link()
1701 unsafe { libc::symlinkat(linkname.as_ptr(), data.as_raw_descriptor(), name.as_ptr()) }; in symlink()
1712 let mut buf = vec![0; libc::PATH_MAX as usize]; in readlink()
1719 libc::readlinkat( in readlink()
1722 buf.as_mut_ptr() as *mut libc::c_char, in readlink()
1751 let newfd = libc::fcntl(data.as_raw_descriptor(), libc::F_DUPFD_CLOEXEC, 0); in flush()
1757 if libc::close(newfd) < 0 { in flush()
1799 let mode = mask as i32 & (libc::R_OK | libc::W_OK | libc::X_OK); in access()
1801 if mode == libc::F_OK { in access()
1806 if (mode & libc::R_OK) != 0 { in access()
1812 return Err(io::Error::from_raw_os_error(libc::EACCES)); in access()
1816 if (mode & libc::W_OK) != 0 { in access()
1822 return Err(io::Error::from_raw_os_error(libc::EACCES)); in access()
1828 if (mode & libc::X_OK) != 0 { in access()
1834 return Err(io::Error::from_raw_os_error(libc::EACCES)); in access()
1852 return Err(io::Error::from_raw_os_error(libc::EPERM)); in setxattr()
1867 libc::setxattr( in setxattr()
1870 value.as_ptr() as *const libc::c_void, in setxattr() constant
1871 value.len() as libc::size_t, in setxattr()
1879 libc::fsetxattr( in setxattr()
1882 value.as_ptr() as *const libc::c_void, in setxattr() constant
1883 value.len() as libc::size_t, in setxattr()
1906 return Err(io::Error::from_raw_os_error(libc::ENODATA)); in getxattr()
1937 libc::listxattr( in listxattr()
1939 buf.as_mut_ptr() as *mut libc::c_char, in listxattr()
1940 buf.len() as libc::size_t, in listxattr()
1947 libc::flistxattr( in listxattr()
1949 buf.as_mut_ptr() as *mut libc::c_char, in listxattr()
1950 buf.len() as libc::size_t, in listxattr()
1975 return Err(io::Error::from_raw_os_error(libc::ENODATA)); in removexattr()
1989 self.with_proc_chdir(|| unsafe { libc::removexattr(path.as_ptr(), name.as_ptr()) }) in removexattr()
1993 unsafe { libc::fremovexattr(data.as_raw_descriptor(), name.as_ptr()) } in removexattr()
2019 match flags & libc::O_ACCMODE { in fallocate()
2020 libc::O_RDONLY => { in fallocate()
2021 flags &= !libc::O_RDONLY; in fallocate()
2022 flags |= libc::O_RDWR; in fallocate()
2025 let newfile = self.open_fd(file.0.as_raw_descriptor(), libc::O_RDWR)?; in fallocate()
2028 libc::O_WRONLY | libc::O_RDWR => {} in fallocate()
2041 libc::fallocate64( in fallocate()
2043 mode as libc::c_int, in fallocate()
2044 offset as libc::off64_t, in fallocate()
2045 length as libc::off64_t, in fallocate()
2079 Err(io::Error::from_raw_os_error(libc::ENOMEM)) in ioctl()
2086 Err(io::Error::from_raw_os_error(libc::EINVAL)) in ioctl()
2093 Err(io::Error::from_raw_os_error(libc::ENOMEM)) in ioctl()
2100 Err(io::Error::from_raw_os_error(libc::ENOMEM)) in ioctl()
2105 _ => Err(io::Error::from_raw_os_error(libc::ENOTTY)), in ioctl()
2138 libc::syscall( in copy_file_range()
2139 libc::SYS_copy_file_range, in copy_file_range()
2167 let read = prot & libc::PROT_READ as u32 != 0; in set_up_mapping()
2168 let write = prot & libc::PROT_WRITE as u32 != 0; in set_up_mapping()
2170 (true, true) => libc::O_RDWR, in set_up_mapping()
2171 (true, false) => libc::O_RDONLY, in set_up_mapping()
2172 (false, true) => libc::O_RDWR, // mmap always requires an fd opened for reading. in set_up_mapping()
2173 (false, false) => return Err(io::Error::from_raw_os_error(libc::EINVAL)), in set_up_mapping()
2181 match (mmap_flags, open_flags & libc::O_ACCMODE) { in set_up_mapping()
2182 (libc::O_RDONLY, libc::O_WRONLY) in set_up_mapping()
2183 | (libc::O_RDWR, libc::O_RDONLY) in set_up_mapping()
2184 | (libc::O_RDWR, libc::O_WRONLY) => { in set_up_mapping()
2186 open_flags &= !libc::O_ACCMODE; in set_up_mapping()
2187 open_flags |= libc::O_RDWR; in set_up_mapping()
2189 let newfile = self.open_fd(file.0.as_raw_descriptor(), libc::O_RDWR)?; in set_up_mapping()
2192 (libc::O_RDONLY, libc::O_RDONLY) in set_up_mapping()
2193 | (libc::O_RDONLY, libc::O_RDWR) in set_up_mapping()
2194 | (libc::O_RDWR, libc::O_RDWR) => {} in set_up_mapping()
2202 let file = self.open_inode(&data, mmap_flags | libc::O_NONBLOCK)?; in set_up_mapping()