Return-Path: Received: from mx2.suse.de ([195.135.220.15]:36933 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752244AbcD2CBn (ORCPT ); Thu, 28 Apr 2016 22:01:43 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 876E3AC60 for ; Fri, 29 Apr 2016 02:01:41 +0000 (UTC) From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PoC 3/7] Create sysfs files under sb Date: Thu, 28 Apr 2016 21:01:18 -0500 Message-Id: <1461895282-4941-4-git-send-email-rgoldwyn@suse.de> In-Reply-To: <1461895282-4941-1-git-send-email-rgoldwyn@suse.de> References: <1461895282-4941-1-git-send-email-rgoldwyn@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Goldwyn Rodrigues This would create sysfs entries under /sys/fs//. fill_super() must initialize attrs. This may not be the best way to do it. Suggestions? Signed-off-by: Goldwyn Rodrigues --- fs/super.c | 8 ++++---- include/linux/fs.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/super.c b/fs/super.c index 5f5e25d..f6cef10 100644 --- a/fs/super.c +++ b/fs/super.c @@ -179,12 +179,12 @@ static const struct sysfs_ops sb_sysfs_ops = { static int register_kobj(struct super_block *sb) { - struct kobj_type *ktype; - ktype = kzalloc(sizeof(struct kobj_type), GFP_USER); - if (IS_ERR(ktype)) - return PTR_ERR(ktype); + struct kobj_type *ktype = kzalloc(sizeof(struct kobj_type), GFP_USER); + if (!ktype) + return -ENOMEM; ktype->sysfs_ops = &sb_sysfs_ops; ktype->release = release_super; + ktype->default_attrs = sb->s_attr; sb->s_kobj.kset = sb->s_type->kset; return kobject_init_and_add(&sb->s_kobj, ktype, NULL, "%s", sb->s_id); diff --git a/include/linux/fs.h b/include/linux/fs.h index e6b9d89..59b84a8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1441,6 +1441,7 @@ struct super_block { spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp; struct list_head s_inodes; /* all inodes */ struct kobject s_kobj; + struct attribute **s_attr; }; extern struct timespec current_fs_time(struct super_block *sb); -- 2.6.6