staging: android: ashmem: add procfs fdinfo helper
This print the inode number of backing file and the name in /proc/pid/fdinfo/fd. These information helps users to know which processes are sharing the same ashmem. Signed-off-by: Zhai Zhaoxuan <kxuanobj@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6724ed7f28
commit
a941f70e55
@ -808,7 +808,23 @@ static long compat_ashmem_ioctl(struct file *file, unsigned int cmd,
|
|||||||
return ashmem_ioctl(file, cmd, arg);
|
return ashmem_ioctl(file, cmd, arg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_PROC_FS
|
||||||
|
static void ashmem_show_fdinfo(struct seq_file *m, struct file *file)
|
||||||
|
{
|
||||||
|
struct ashmem_area *asma = file->private_data;
|
||||||
|
|
||||||
|
mutex_lock(&ashmem_mutex);
|
||||||
|
|
||||||
|
if (asma->file)
|
||||||
|
seq_printf(m, "inode:\t%ld\n", file_inode(asma->file)->i_ino);
|
||||||
|
|
||||||
|
if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0')
|
||||||
|
seq_printf(m, "name:\t%s\n",
|
||||||
|
asma->name + ASHMEM_NAME_PREFIX_LEN);
|
||||||
|
|
||||||
|
mutex_unlock(&ashmem_mutex);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static const struct file_operations ashmem_fops = {
|
static const struct file_operations ashmem_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = ashmem_open,
|
.open = ashmem_open,
|
||||||
@ -820,6 +836,9 @@ static const struct file_operations ashmem_fops = {
|
|||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
.compat_ioctl = compat_ashmem_ioctl,
|
.compat_ioctl = compat_ashmem_ioctl,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_PROC_FS
|
||||||
|
.show_fdinfo = ashmem_show_fdinfo,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct miscdevice ashmem_misc = {
|
static struct miscdevice ashmem_misc = {
|
||||||
|
Loading…
Reference in New Issue
Block a user