dma-buf: add show_fdinfo handler
authorGreg Hackmann <ghackmann@google.com>
Thu, 13 Jun 2019 22:34:08 +0000 (15:34 -0700)
committerSumit Semwal <sumit.semwal@linaro.org>
Fri, 14 Jun 2019 09:30:51 +0000 (15:00 +0530)
The show_fdinfo handler exports the same information available through
debugfs on a per-buffer basis.

Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Chenbo Feng <fengc@google.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190613223408.139221-4-fengc@google.com
drivers/dma-buf/dma-buf.c

index ab96410d1dcdae0c20380ea091d68207cd9a4aa4..6c15deb5d4ad8b60212826ea0487fdac12da9cb9 100644 (file)
@@ -401,6 +401,20 @@ static long dma_buf_ioctl(struct file *file,
        }
 }
 
+static void dma_buf_show_fdinfo(struct seq_file *m, struct file *file)
+{
+       struct dma_buf *dmabuf = file->private_data;
+
+       seq_printf(m, "size:\t%zu\n", dmabuf->size);
+       /* Don't count the temporary reference taken inside procfs seq_show */
+       seq_printf(m, "count:\t%ld\n", file_count(dmabuf->file) - 1);
+       seq_printf(m, "exp_name:\t%s\n", dmabuf->exp_name);
+       mutex_lock(&dmabuf->lock);
+       if (dmabuf->name)
+               seq_printf(m, "name:\t%s\n", dmabuf->name);
+       mutex_unlock(&dmabuf->lock);
+}
+
 static const struct file_operations dma_buf_fops = {
        .release        = dma_buf_release,
        .mmap           = dma_buf_mmap_internal,
@@ -410,6 +424,7 @@ static const struct file_operations dma_buf_fops = {
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = dma_buf_ioctl,
 #endif
+       .show_fdinfo    = dma_buf_show_fdinfo,
 };
 
 /*