From 97f3971dcd5708aea419bd86a73a4cf7cbb1b4ae Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 19 Jul 2019 16:16:30 -0700 Subject: [PATCH] scoutfs: add rid sysfs file Add a "rid" file along the "fsid" file in the per-mount sysfs dir that gives the mounts rid. Signed-off-by: Zach Brown --- kmod/src/sysfs.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kmod/src/sysfs.c b/kmod/src/sysfs.c index 2c056c5c..bea667d0 100644 --- a/kmod/src/sysfs.c +++ b/kmod/src/sysfs.c @@ -43,10 +43,20 @@ static ssize_t fsid_show(struct kobject *kobj, struct attribute *attr, struct super_block *sb = KOBJ_TO_SB(kobj, sb_id_kobj); struct scoutfs_super_block *super = &SCOUTFS_SB(sb)->super; - return snprintf(buf, PAGE_SIZE, "%llx\n", le64_to_cpu(super->hdr.fsid)); + return snprintf(buf, PAGE_SIZE, "%016llx\n", + le64_to_cpu(super->hdr.fsid)); } ATTR_FUNCS_RO(fsid); +static ssize_t rid_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct super_block *sb = KOBJ_TO_SB(kobj, sb_id_kobj); + struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); + + return snprintf(buf, PAGE_SIZE, "%016llx\n", sbi->rid); +} +ATTR_FUNCS_RO(rid); + /* * ops are defined per type, not per attribute. To have attributes with * different types that want different funcs we wrap them with a struct @@ -82,6 +92,7 @@ static ssize_t attr_funcs_show(struct kobject *kobj, struct attribute *attr, static struct attribute *sb_id_attrs[] = { &fsid_attr_funcs.attr, + &rid_attr_funcs.attr, NULL, }; KTYPE(sb_id);