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) {
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;
#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 */