Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 281405
b: refs/heads/master
c: 5154b93
h: refs/heads/master
i:
  281403: 5adc08d
v: v3
  • Loading branch information
Bjorn Bringert authored and Greg Kroah-Hartman committed Dec 21, 2011
1 parent bf5be4b commit f7b5578
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1d3f8f2da1c28709a3c494f3872b89c871906b2d
refs/heads/master: 5154b93b8eceb57bdab4e77030bf21ead15b42e4
39 changes: 38 additions & 1 deletion trunk/drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int ashmem_open(struct inode *inode, struct file *file)
struct ashmem_area *asma;
int ret;

ret = nonseekable_open(inode, file);
ret = generic_file_open(inode, file);
if (unlikely(ret))
return ret;

Expand Down Expand Up @@ -230,6 +230,42 @@ static ssize_t ashmem_read(struct file *file, char __user *buf,
}

ret = asma->file->f_op->read(asma->file, buf, len, pos);
if (ret < 0) {
goto out;
}

/** Update backing file pos, since f_ops->read() doesn't */
asma->file->f_pos = *pos;

out:
mutex_unlock(&ashmem_mutex);
return ret;
}

static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
{
struct ashmem_area *asma = file->private_data;
int ret;

mutex_lock(&ashmem_mutex);

if (asma->size == 0) {
ret = -EINVAL;
goto out;
}

if (!asma->file) {
ret = -EBADF;
goto out;
}

ret = asma->file->f_op->llseek(asma->file, offset, origin);
if (ret < 0) {
goto out;
}

/** Copy f_pos from backing file, since f_ops->llseek() sets it */
file->f_pos = asma->file->f_pos;

out:
mutex_unlock(&ashmem_mutex);
Expand Down Expand Up @@ -648,6 +684,7 @@ static struct file_operations ashmem_fops = {
.open = ashmem_open,
.release = ashmem_release,
.read = ashmem_read,
.llseek = ashmem_llseek,
.mmap = ashmem_mmap,
.unlocked_ioctl = ashmem_ioctl,
.compat_ioctl = ashmem_ioctl,
Expand Down

0 comments on commit f7b5578

Please sign in to comment.