aoe: provide file operations for debugfs files
authorEd Cashin <ecashin@coraid.com>
Wed, 11 Sep 2013 21:25:41 +0000 (14:25 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Sep 2013 22:59:24 +0000 (15:59 -0700)
The place holder in the file contents is filled out in the following
patch.

Signed-off-by: Ed Cashin <ecashin@coraid.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/block/aoe/aoeblk.c

index d76c5cb3c7086152f28f0baafec226a4746f5c9a..0511d38e412df5d8d77bcb04c542bebf2d421e87 100644 (file)
@@ -110,6 +110,24 @@ static ssize_t aoedisk_show_payload(struct device *dev,
        return snprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt);
 }
 
+static int aoedisk_debugfs_show(struct seq_file *s, void *ignored)
+{
+       struct aoedev *d;
+       unsigned long flags;
+
+       d = s->private;
+       spin_lock_irqsave(&d->lock, flags);
+       seq_printf(s, "%s\n", d->gd->disk_name); /* place holder */
+       spin_unlock_irqrestore(&d->lock, flags);
+
+       return 0;
+}
+
+static int aoe_debugfs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, aoedisk_debugfs_show, inode->i_private);
+}
+
 static DEVICE_ATTR(state, S_IRUGO, aoedisk_show_state, NULL);
 static DEVICE_ATTR(mac, S_IRUGO, aoedisk_show_mac, NULL);
 static DEVICE_ATTR(netif, S_IRUGO, aoedisk_show_netif, NULL);
@@ -132,7 +150,12 @@ static const struct attribute_group attr_group = {
        .attrs = aoe_attrs,
 };
 
-static const struct file_operations aoe_debugfs_fops;
+static const struct file_operations aoe_debugfs_fops = {
+       .open = aoe_debugfs_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
 
 static void
 aoedisk_add_debugfs(struct aoedev *d)