aboutsummaryrefslogtreecommitdiffstats
path: root/mm/ashmem.c
diff options
context:
space:
mode:
authorBjorn Bringert <bringert@android.com>2010-04-15 10:04:01 +0100
committerColin Cross <ccross@android.com>2011-06-14 09:09:32 -0700
commit6809f0087c72d4b3eab3563c4b36bab52a9d8e7c (patch)
treecebf18ced5f326220e22b0c4c2f00fc371b6cbe7 /mm/ashmem.c
parentf23ba5021d5c4e35f0973dd0a15aa7dceaea0293 (diff)
downloadkernel_samsung_crespo-6809f0087c72d4b3eab3563c4b36bab52a9d8e7c.zip
kernel_samsung_crespo-6809f0087c72d4b3eab3563c4b36bab52a9d8e7c.tar.gz
kernel_samsung_crespo-6809f0087c72d4b3eab3563c4b36bab52a9d8e7c.tar.bz2
Implement read(2) in ashmem driver
Bug: 2595601 Change-Id: I47c0016f594f9354fb8658ccb26e3d395bcb137b Signed-off-by: Bjorn Bringert <bringert@android.com>
Diffstat (limited to 'mm/ashmem.c')
-rw-r--r--mm/ashmem.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/mm/ashmem.c b/mm/ashmem.c
index 230810f..04e886e 100644
--- a/mm/ashmem.c
+++ b/mm/ashmem.c
@@ -211,6 +211,31 @@ static int ashmem_release(struct inode *ignored, struct file *file)
return 0;
}
+static ssize_t ashmem_read(struct file *file, char __user *buf,
+ size_t len, loff_t *pos)
+{
+ struct ashmem_area *asma = file->private_data;
+ int ret = 0;
+
+ mutex_lock(&ashmem_mutex);
+
+ /* If size is not set, or set to 0, always return EOF. */
+ if (asma->size == 0) {
+ goto out;
+ }
+
+ if (!asma->file) {
+ ret = -EBADF;
+ goto out;
+ }
+
+ ret = asma->file->f_op->read(asma->file, buf, len, pos);
+
+out:
+ mutex_unlock(&ashmem_mutex);
+ return ret;
+}
+
static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
{
struct ashmem_area *asma = file->private_data;
@@ -604,6 +629,7 @@ static struct file_operations ashmem_fops = {
.owner = THIS_MODULE,
.open = ashmem_open,
.release = ashmem_release,
+ .read = ashmem_read,
.mmap = ashmem_mmap,
.unlocked_ioctl = ashmem_ioctl,
.compat_ioctl = ashmem_ioctl,