mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Fix mmap block device
This commit is contained in:
parent
ff1c56683d
commit
a470ee6f93
@ -6,6 +6,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <linux/fs.h>
|
||||||
#include "misc.hpp"
|
#include "misc.hpp"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -42,6 +43,8 @@ struct mount_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct mmap_data : public byte_data {
|
struct mmap_data : public byte_data {
|
||||||
|
static_assert((sizeof(void *) == 8 && BLKGETSIZE64 == 0x80081272) ||
|
||||||
|
(sizeof(void *) == 4 && BLKGETSIZE64 == 0x80041272));
|
||||||
ALLOW_MOVE_ONLY(mmap_data)
|
ALLOW_MOVE_ONLY(mmap_data)
|
||||||
|
|
||||||
explicit mmap_data(const char *name, bool rw = false);
|
explicit mmap_data(const char *name, bool rw = false);
|
||||||
|
@ -483,8 +483,12 @@ pub(crate) fn map_file(path: &Utf8CStr, rw: bool) -> io::Result<&'static mut [u8
|
|||||||
fn ioctl(fd: RawFd, request: u32, ...) -> i32;
|
fn ioctl(fd: RawFd, request: u32, ...) -> i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_pointer_width = "64")]
|
||||||
const BLKGETSIZE64: u32 = 0x80081272;
|
const BLKGETSIZE64: u32 = 0x80081272;
|
||||||
|
|
||||||
|
#[cfg(target_pointer_width = "32")]
|
||||||
|
const BLKGETSIZE64: u32 = 0x80041272;
|
||||||
|
|
||||||
let flag = if rw { O_RDWR } else { O_RDONLY };
|
let flag = if rw { O_RDWR } else { O_RDONLY };
|
||||||
let f = File::from(open_fd!(path, flag | O_CLOEXEC)?);
|
let f = File::from(open_fd!(path, flag | O_CLOEXEC)?);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user