aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhai Zhaoxuan <kxuanobj@gmail.com>2017-12-28 08:56:06 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-01-08 10:37:18 -0500
commita941f70e55471367de8e9c3cc44b47303ba1a87d (patch)
tree8ba1318a43c759e50e5da47826f408850975c1d8
parent6724ed7f28d6e83956a7219a9a02a4d620ef65d8 (diff)
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>
-rw-r--r--drivers/staging/android/ashmem.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 4e8947923904..425c49f9330c 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -808,7 +808,23 @@ static long compat_ashmem_ioctl(struct file *file, unsigned int cmd,
808 return ashmem_ioctl(file, cmd, arg); 808 return ashmem_ioctl(file, cmd, arg);
809} 809}
810#endif 810#endif
811#ifdef CONFIG_PROC_FS
812static void ashmem_show_fdinfo(struct seq_file *m, struct file *file)
813{
814 struct ashmem_area *asma = file->private_data;
815
816 mutex_lock(&ashmem_mutex);
817
818 if (asma->file)
819 seq_printf(m, "inode:\t%ld\n", file_inode(asma->file)->i_ino);
811 820
821 if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0')
822 seq_printf(m, "name:\t%s\n",
823 asma->name + ASHMEM_NAME_PREFIX_LEN);
824
825 mutex_unlock(&ashmem_mutex);
826}
827#endif
812static const struct file_operations ashmem_fops = { 828static const struct file_operations ashmem_fops = {
813 .owner = THIS_MODULE, 829 .owner = THIS_MODULE,
814 .open = ashmem_open, 830 .open = ashmem_open,
@@ -820,6 +836,9 @@ static const struct file_operations ashmem_fops = {
820#ifdef CONFIG_COMPAT 836#ifdef CONFIG_COMPAT
821 .compat_ioctl = compat_ashmem_ioctl, 837 .compat_ioctl = compat_ashmem_ioctl,
822#endif 838#endif
839#ifdef CONFIG_PROC_FS
840 .show_fdinfo = ashmem_show_fdinfo,
841#endif
823}; 842};
824 843
825static struct miscdevice ashmem_misc = { 844static struct miscdevice ashmem_misc = {