Loading include/cutils/ashmem.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ int ashmem_create_region(const char *name, size_t size); int ashmem_set_prot_region(int fd, int prot); int ashmem_pin_region(int fd, size_t offset, size_t len); int ashmem_unpin_region(int fd, size_t offset, size_t len); int ashmem_get_size_region(int fd); #ifdef __cplusplus } Loading libcutils/ashmem-dev.c +5 −0 Original line number Diff line number Diff line Loading @@ -83,3 +83,8 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) struct ashmem_pin pin = { offset, len }; return ioctl(fd, ASHMEM_UNPIN, &pin); } int ashmem_get_size_region(int fd) { return ioctl(fd, ASHMEM_GET_SIZE, NULL); } libcutils/ashmem-host.c +20 −0 Original line number Diff line number Diff line Loading @@ -92,3 +92,23 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) { return ASHMEM_IS_UNPINNED; } int ashmem_get_size_region(int fd) { struct stat buf; int result; result = fstat(fd, &buf); if (result == -1) { return -1; } // Check if this is an "ashmem" region. // TODO: This is very hacky, and can easily break. We need some reliable indicator. if (!(buf.st_nlink == 0 && S_ISREG(buf.st_mode))) { errno = ENOTTY; return -1; } return (int)buf.st_size; // TODO: care about overflow (> 2GB file)? } Loading
include/cutils/ashmem.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ int ashmem_create_region(const char *name, size_t size); int ashmem_set_prot_region(int fd, int prot); int ashmem_pin_region(int fd, size_t offset, size_t len); int ashmem_unpin_region(int fd, size_t offset, size_t len); int ashmem_get_size_region(int fd); #ifdef __cplusplus } Loading
libcutils/ashmem-dev.c +5 −0 Original line number Diff line number Diff line Loading @@ -83,3 +83,8 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) struct ashmem_pin pin = { offset, len }; return ioctl(fd, ASHMEM_UNPIN, &pin); } int ashmem_get_size_region(int fd) { return ioctl(fd, ASHMEM_GET_SIZE, NULL); }
libcutils/ashmem-host.c +20 −0 Original line number Diff line number Diff line Loading @@ -92,3 +92,23 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) { return ASHMEM_IS_UNPINNED; } int ashmem_get_size_region(int fd) { struct stat buf; int result; result = fstat(fd, &buf); if (result == -1) { return -1; } // Check if this is an "ashmem" region. // TODO: This is very hacky, and can easily break. We need some reliable indicator. if (!(buf.st_nlink == 0 && S_ISREG(buf.st_mode))) { errno = ENOTTY; return -1; } return (int)buf.st_size; // TODO: care about overflow (> 2GB file)? }