mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 20:32:04 +09:00
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:
@@ -816,6 +816,7 @@ out_unlock:
|
|||||||
static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct ashmem_area *asma = file->private_data;
|
struct ashmem_area *asma = file->private_data;
|
||||||
|
unsigned long ino;
|
||||||
long ret = -ENOTTY;
|
long ret = -ENOTTY;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
@@ -859,6 +860,23 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||||||
ashmem_shrink_scan(&ashmem_shrinker, &sc);
|
ashmem_shrink_scan(&ashmem_shrinker, &sc);
|
||||||
}
|
}
|
||||||
break;
|
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;
|
return ret;
|
||||||
|
|||||||
@@ -41,5 +41,6 @@ struct ashmem_pin {
|
|||||||
#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
|
#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
|
||||||
#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
|
#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
|
||||||
#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
|
#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
|
||||||
|
#define ASHMEM_GET_FILE_ID _IOR(__ASHMEMIOC, 11, unsigned long)
|
||||||
|
|
||||||
#endif /* _UAPI_LINUX_ASHMEM_H */
|
#endif /* _UAPI_LINUX_ASHMEM_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user