summaryrefslogtreecommitdiff
path: root/libcutils/ashmem-dev.c
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-02-03 23:30:29 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-02-03 23:30:29 +0000
commit9c551a1bece6624bdbdfca40badc07b40b28ec1c (patch)
tree9a03008e8d73bd281e7a4f96597163bc074c5ce7 /libcutils/ashmem-dev.c
parent1a84f47794168e80975eae31c665d03367929f66 (diff)
parente37111d7516827489232c6c894e114a58952fe4a (diff)
Merge "libcutils: ashmem print error message for invalid fd"
Diffstat (limited to 'libcutils/ashmem-dev.c')
-rw-r--r--libcutils/ashmem-dev.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libcutils/ashmem-dev.c b/libcutils/ashmem-dev.c
index 77e4d0d97..d6a48c953 100644
--- a/libcutils/ashmem-dev.c
+++ b/libcutils/ashmem-dev.c
@@ -19,6 +19,7 @@
* ashmem-enabled kernel. See ashmem-sim.c for the "fake" tmp-based version,
* used by the simulator.
*/
+#define LOG_TAG "ashmem"
#include <errno.h>
#include <fcntl.h>
@@ -32,6 +33,7 @@
#include <linux/ashmem.h>
#include <cutils/ashmem.h>
+#include <log/log.h>
#define ASHMEM_DEVICE "/dev/ashmem"
@@ -92,6 +94,7 @@ static int __ashmem_is_ashmem(int fd)
return -1;
}
+ rdev = 0; /* Too much complexity to sniff __ashmem_rdev */
if (S_ISCHR(st.st_mode) && st.st_rdev) {
pthread_mutex_lock(&__ashmem_lock);
rdev = __ashmem_rdev;
@@ -114,6 +117,17 @@ static int __ashmem_is_ashmem(int fd)
}
}
+ if (rdev) {
+ ALOGE("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),
+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IRGRP,
+ major(rdev), minor(rdev));
+ } else {
+ ALOGE("illegal fd=%d mode=0%o rdev=%d:%d expected 0%o",
+ fd, st.st_mode, major(st.st_rdev), minor(st.st_rdev),
+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IRGRP);
+ }
+
errno = ENOTTY;
return -1;
}