diff --git a/base/include/ashmem.h b/base/include/ashmem.h
index 78d9304734fa028cce6871a5a6286671bd13d591..910212c0fdbae0b2dacacfa5aa4d6f60ec7bed1a 100644
--- a/base/include/ashmem.h
+++ b/base/include/ashmem.h
@@ -69,6 +69,14 @@ int AshmemSetProt(int fd, int prot);
*/
int AshmemGetSize(int fd);
+/**
+ * @brief Obtains the size of a specific Ashmem region in the kernel.
+ *
+ * @param fd Indicates the file descriptor of an Ashmem region.
+ * @return Returns the size of the Ashmem region.
+ */
+long AshmemGetSizeRaw(int fd);
+
/**
* @brief Provides the Ashmem class implemented in c_utils to
* operate the Anonymous Shared Memory (Ashmem).
diff --git a/base/src/ashmem.cpp b/base/src/ashmem.cpp
index c65ee8a1f29e9550a3885aa6250a48e0ecb68a53..5feea32e33e53b0d7d008d0a3ce913e2df96203f 100644
--- a/base/src/ashmem.cpp
+++ b/base/src/ashmem.cpp
@@ -18,6 +18,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -137,6 +138,11 @@ int AshmemGetSize(int fd)
return TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_GET_SIZE, NULL));
}
+long AshmemGetSizeRaw(int fd)
+{
+ return TEMP_FAILURE_RETRY(syscall(SYS_ioctl, fd, ASHMEM_GET_SIZE, NULL));
+}
+
Ashmem::Ashmem(int fd, int32_t size) : memoryFd_(fd), memorySize_(size), flag_(0), startAddr_(nullptr)
{
}