ANDROID: Add ashmem ioctl to return a unique file identifier
This will allow a client program to avoid redundant actions on ashmem buffers which it has already seen. Bug: 244233389 Change-Id: Ica57a8842ff163eae5f9eca8141b439091ec0940 Signed-off-by: Mark Fasheh <mfasheh@google.com>
This commit is contained in:
@@ -817,6 +817,7 @@ out_unlock:
|
||||
static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct ashmem_area *asma = file->private_data;
|
||||
unsigned long ino;
|
||||
long ret = -ENOTTY;
|
||||
|
||||
switch (cmd) {
|
||||
@@ -860,6 +861,23 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
ashmem_shrink_scan(&ashmem_shrinker, &sc);
|
||||
}
|
||||
break;
|
||||
case ASHMEM_GET_FILE_ID:
|
||||
/* Lock around our check to avoid racing with ashmem_mmap(). */
|
||||
mutex_lock(&ashmem_mutex);
|
||||
if (!asma || !asma->file) {
|
||||
mutex_unlock(&ashmem_mutex);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
ino = file_inode(asma->file)->i_ino;
|
||||
mutex_unlock(&ashmem_mutex);
|
||||
|
||||
if (copy_to_user((void __user *)arg, &ino, sizeof(ino))) {
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -39,5 +39,6 @@ struct ashmem_pin {
|
||||
#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
|
||||
#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
|
||||
#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
|
||||
#define ASHMEM_GET_FILE_ID _IOR(__ASHMEMIOC, 11, unsigned long)
|
||||
|
||||
#endif /* _UAPI_LINUX_ASHMEM_H */
|
||||
|
||||
Reference in New Issue
Block a user