mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-07-29 22:13:38 +00:00
Avoid throwing error if chmod a symlink
It is possible that we want to clone attributes of a regular file to a symlink. In this case, we don't need to error out if chmod fails. Just skip it.
This commit is contained in:
parent
48d9fc24eb
commit
0b494ed7df
@ -326,11 +326,12 @@ impl Utf8CStr {
|
|||||||
pub fn set_attr<'a>(&'a self, attr: &'a FileAttr) -> OsResult<'a, ()> {
|
pub fn set_attr<'a>(&'a self, attr: &'a FileAttr) -> OsResult<'a, ()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !attr.is_symlink() {
|
if !attr.is_symlink() {
|
||||||
libc::chmod(self.as_ptr(), (attr.st.st_mode & 0o777).as_()).check_os_err(
|
if libc::chmod(self.as_ptr(), (attr.st.st_mode & 0o777).as_()) < 0 {
|
||||||
"chmod",
|
let self_attr = self.get_attr()?;
|
||||||
Some(self),
|
if !self_attr.is_symlink() {
|
||||||
None,
|
return Err(OsError::last_os_error("chmod", Some(self), None));
|
||||||
)?;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
libc::lchown(self.as_ptr(), attr.st.st_uid, attr.st.st_gid).check_os_err(
|
libc::lchown(self.as_ptr(), attr.st.st_uid, attr.st.st_gid).check_os_err(
|
||||||
"lchown",
|
"lchown",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user