mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 14:48:29 +00:00
Support Linux < 3.6
This commit is contained in:
parent
916e373edb
commit
616adc22e1
@ -82,19 +82,19 @@ pub fn realpath(path: &CStr, buf: &mut [u8]) -> isize {
|
|||||||
if let Some(fd) = open_fd!(path, O_PATH | O_CLOEXEC) {
|
if let Some(fd) = open_fd!(path, O_PATH | O_CLOEXEC) {
|
||||||
let mut st1: libc::stat;
|
let mut st1: libc::stat;
|
||||||
let mut st2: libc::stat;
|
let mut st2: libc::stat;
|
||||||
|
let mut skip_check = false;
|
||||||
unsafe {
|
unsafe {
|
||||||
st1 = std::mem::zeroed();
|
st1 = std::mem::zeroed();
|
||||||
if libc::fstat(fd.as_raw_fd(), &mut st1) < 0 {
|
if libc::fstat(fd.as_raw_fd(), &mut st1) < 0 {
|
||||||
*errno() = ENOENT;
|
// This shall only fail on Linux < 3.6
|
||||||
return -1;
|
skip_check = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let len = fd_path(fd.as_raw_fd(), buf);
|
let len = fd_path(fd.as_raw_fd(), buf);
|
||||||
unsafe {
|
unsafe {
|
||||||
st2 = std::mem::zeroed();
|
st2 = std::mem::zeroed();
|
||||||
if libc::stat(buf.as_ptr().cast(), &mut st2) < 0
|
if libc::stat(buf.as_ptr().cast(), &mut st2) < 0
|
||||||
|| st2.st_dev != st1.st_dev
|
|| (!skip_check && (st2.st_dev != st1.st_dev || st2.st_ino != st1.st_ino))
|
||||||
|| st2.st_ino != st1.st_ino
|
|
||||||
{
|
{
|
||||||
*errno() = ENOENT;
|
*errno() = ENOENT;
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user