Rename cstr_buf to cstr::buf

This commit is contained in:
topjohnwu
2025-04-22 02:55:53 -07:00
committed by John Wu
parent ab2e5d1e7e
commit e02b5f7868
16 changed files with 65 additions and 63 deletions

View File

@@ -1,7 +1,7 @@
use crate::cxx_extern::readlinkat;
use crate::{
FileAttr, FsPath, FsPathBuilder, LibcReturn, OsError, OsResult, OsResultStatic, Utf8CStr,
Utf8CStrBuf, cstr_buf, errno, fd_path, fd_set_attr,
Utf8CStrBuf, cstr, errno, fd_path, fd_set_attr,
};
use libc::{EEXIST, O_CLOEXEC, O_CREAT, O_RDONLY, O_TRUNC, O_WRONLY, dirent, mode_t};
use std::fs::File;
@@ -247,13 +247,13 @@ impl Directory {
}
pub fn get_attr_at<'a>(&self, name: &'a Utf8CStr) -> OsResult<'a, FileAttr> {
let mut path = cstr_buf::default();
let mut path = cstr::buf::default();
self.path_at(name, &mut path)?;
path.get_attr().map_err(|e| e.set_args(Some(name), None))
}
pub fn set_attr_at<'a>(&self, name: &'a Utf8CStr, attr: &FileAttr) -> OsResult<'a, ()> {
let mut path = cstr_buf::default();
let mut path = cstr::buf::default();
self.path_at(name, &mut path)?;
path.set_attr(attr)
.map_err(|e| e.set_args(Some(name), None))
@@ -264,14 +264,14 @@ impl Directory {
name: &'a Utf8CStr,
con: &mut dyn Utf8CStrBuf,
) -> OsResult<'a, ()> {
let mut path = cstr_buf::default();
let mut path = cstr::buf::default();
self.path_at(name, &mut path)?;
path.get_secontext(con)
.map_err(|e| e.set_args(Some(name), None))
}
pub fn set_secontext_at<'a>(&self, name: &'a Utf8CStr, con: &'a Utf8CStr) -> OsResult<'a, ()> {
let mut path = cstr_buf::default();
let mut path = cstr::buf::default();
self.path_at(name, &mut path)?;
path.set_secontext(con)
.map_err(|e| e.set_args(Some(name), Some(con)))
@@ -344,7 +344,7 @@ impl Directory {
std::io::copy(&mut src, &mut dest)?;
fd_set_attr(dest.as_raw_fd(), &attr)?;
} else if e.is_symlink() {
let mut target = cstr_buf::default();
let mut target = cstr::buf::default();
e.read_link(&mut target)?;
unsafe {
libc::symlinkat(target.as_ptr(), dir.as_raw_fd(), e.d_name.as_ptr())