ANDROID: ashmem: fix integer declarations

As part of the LTS release, we are importing an improvement to Rust
integer types. This updates ashmem to use with the improved integer type
scheme.

Change-Id: If98954a2e9fcbb37a1f050f3e09a43d9268a8cc3
Fixes: e9cc806c01 ("Linux 6.12.19")
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Alice Ryhl
2025-04-11 13:49:32 +00:00
committed by Treehugger Robot
parent b3fb80bdc6
commit 575c996c3b
3 changed files with 13 additions and 11 deletions
+5 -5
View File
@@ -11,7 +11,6 @@
//! memory units when under memory pressure.
use core::{
ffi::c_int,
pin::Pin,
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
};
@@ -19,6 +18,7 @@ use kernel::{
bindings::{self, ASHMEM_GET_PIN_STATUS, ASHMEM_PIN, ASHMEM_UNPIN},
c_str,
error::Result,
ffi::c_int,
fs::{File, LocalFile},
ioctl::_IOC_SIZE,
miscdevice::{loff_t, IovIter, Kiocb, MiscDevice, MiscDeviceOptions, MiscDeviceRegistration},
@@ -521,17 +521,17 @@ unsafe extern "C" fn ashmem_memfd_ioctl(file: *mut bindings::file, cmd: u32, arg
fn ashmem_memfd_ioctl_inner(file: &File, cmd: u32, arg: usize) -> Result<isize> {
use kernel::bindings::{F_ADD_SEALS, F_GET_SEALS, F_SEAL_FUTURE_WRITE, F_SEAL_WRITE};
const WRITE_SEALS_MASK: u64 = (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE) as u64;
const WRITE_SEALS_MASK: usize = (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE) as usize;
/// # Safety
/// The file must be a memfd file.
unsafe fn get_seals(file: &File) -> Result<u64> {
unsafe fn get_seals(file: &File) -> Result<usize> {
// SAFETY: This is a memfd file.
let seals: i64 = unsafe { bindings::memfd_fcntl(file.as_ptr(), F_GET_SEALS, 0) };
let seals: isize = unsafe { bindings::memfd_fcntl(file.as_ptr(), F_GET_SEALS, 0) };
if seals < 0 {
return Err(Error::from_errno(seals as i32));
}
Ok(seals as u64)
Ok(seals as usize)
}
let size = _IOC_SIZE(cmd);
+7 -5
View File
@@ -7,14 +7,16 @@
//!
//! C header: [`include/linux/shrinker.h`](srctree/include/linux/shrinker.h)
use kernel::{alloc::AllocError, bindings, c_str, str::CStr, types::ForeignOwnable};
use core::{
use kernel::{
alloc::AllocError,
bindings, c_str,
ffi::{c_int, c_long, c_ulong, c_void},
marker::PhantomData,
ptr::NonNull,
str::CStr,
types::ForeignOwnable,
};
use core::{marker::PhantomData, ptr::NonNull};
const SHRINK_STOP: c_ulong = bindings::SHRINK_STOP as c_ulong;
const SHRINK_EMPTY: c_ulong = bindings::SHRINK_EMPTY as c_ulong;
+1 -1
View File
@@ -7,6 +7,7 @@
use kernel::{
bindings,
error::{from_err_ptr, to_result, Result},
ffi::{c_int, c_ulong},
fs::file::{File, LocalFile},
miscdevice::{loff_t, IovIter},
mm::virt::{vm_flags_t, VmAreaNew},
@@ -17,7 +18,6 @@ use kernel::{
use core::{
cell::UnsafeCell,
ffi::{c_int, c_ulong},
ptr::{addr_of_mut, NonNull},
};