Loading include/cutils/ashmem.h +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ extern "C" { #endif int ashmem_valid(int fd); 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); Loading libcutils/ashmem-dev.c +22 −15 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ static int __ashmem_open() } /* Make sure file descriptor references ashmem, negative number means false */ static int __ashmem_is_ashmem(int fd) static int __ashmem_is_ashmem(int fd, int fatal) { dev_t rdev; struct stat st; Loading Loading @@ -117,6 +117,7 @@ static int __ashmem_is_ashmem(int fd) } } if (fatal) { if (rdev) { LOG_ALWAYS_FATAL("illegal fd=%d mode=0%o rdev=%d:%d expected 0%o %d:%d", fd, st.st_mode, major(st.st_rdev), minor(st.st_rdev), Loading @@ -128,11 +129,17 @@ static int __ashmem_is_ashmem(int fd) S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IRGRP); } /* NOTREACHED */ } errno = ENOTTY; return -1; } int ashmem_valid(int fd) { return __ashmem_is_ashmem(fd, 0) >= 0; } /* * ashmem_create_region - creates a new ashmem region and returns the file * descriptor, or <0 on error Loading Loading @@ -175,7 +182,7 @@ error: int ashmem_set_prot_region(int fd, int prot) { int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading @@ -187,7 +194,7 @@ int ashmem_pin_region(int fd, size_t offset, size_t len) { struct ashmem_pin pin = { offset, len }; int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading @@ -199,7 +206,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) { struct ashmem_pin pin = { offset, len }; int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading @@ -209,7 +216,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) int ashmem_get_size_region(int fd) { int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading Loading
include/cutils/ashmem.h +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ extern "C" { #endif int ashmem_valid(int fd); 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); Loading
libcutils/ashmem-dev.c +22 −15 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ static int __ashmem_open() } /* Make sure file descriptor references ashmem, negative number means false */ static int __ashmem_is_ashmem(int fd) static int __ashmem_is_ashmem(int fd, int fatal) { dev_t rdev; struct stat st; Loading Loading @@ -117,6 +117,7 @@ static int __ashmem_is_ashmem(int fd) } } if (fatal) { if (rdev) { LOG_ALWAYS_FATAL("illegal fd=%d mode=0%o rdev=%d:%d expected 0%o %d:%d", fd, st.st_mode, major(st.st_rdev), minor(st.st_rdev), Loading @@ -128,11 +129,17 @@ static int __ashmem_is_ashmem(int fd) S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IRGRP); } /* NOTREACHED */ } errno = ENOTTY; return -1; } int ashmem_valid(int fd) { return __ashmem_is_ashmem(fd, 0) >= 0; } /* * ashmem_create_region - creates a new ashmem region and returns the file * descriptor, or <0 on error Loading Loading @@ -175,7 +182,7 @@ error: int ashmem_set_prot_region(int fd, int prot) { int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading @@ -187,7 +194,7 @@ int ashmem_pin_region(int fd, size_t offset, size_t len) { struct ashmem_pin pin = { offset, len }; int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading @@ -199,7 +206,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) { struct ashmem_pin pin = { offset, len }; int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading @@ -209,7 +216,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) int ashmem_get_size_region(int fd) { int ret = __ashmem_is_ashmem(fd); int ret = __ashmem_is_ashmem(fd, 1); if (ret < 0) { return ret; } Loading