Skip to content

Commit e2d74c4

Browse files
Ye Binaalexandrovich
authored andcommitted
fs/ntfs3: Factor out ntfs_{create/remove}_procdir()
Introduce ntfs_create_procdir() and ntfs_remove_procdir() to create/remove "/proc/fs/ntfs3/.." Signed-off-by: Ye Bin <yebin10@huawei.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent 285cec3 commit e2d74c4

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

fs/ntfs3/super.c

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,40 @@ static const struct proc_ops ntfs3_label_fops = {
555555
.proc_write = ntfs3_label_write,
556556
};
557557

558+
static void ntfs_create_procdir(struct super_block *sb)
559+
{
560+
struct proc_dir_entry *e;
561+
562+
if (!proc_info_root)
563+
return;
564+
565+
e = proc_mkdir(sb->s_id, proc_info_root);
566+
if (e) {
567+
struct ntfs_sb_info *sbi = sb->s_fs_info;
568+
569+
proc_create_data("volinfo", 0444, e,
570+
&ntfs3_volinfo_fops, sb);
571+
proc_create_data("label", 0644, e,
572+
&ntfs3_label_fops, sb);
573+
sbi->procdir = e;
574+
}
575+
}
576+
577+
static void ntfs_remove_procdir(struct super_block *sb)
578+
{
579+
struct ntfs_sb_info *sbi = sb->s_fs_info;
580+
581+
if (!sbi->procdir)
582+
return;
583+
584+
remove_proc_entry("label", sbi->procdir);
585+
remove_proc_entry("volinfo", sbi->procdir);
586+
remove_proc_entry(sb->s_id, proc_info_root);
587+
sbi->procdir = NULL;
588+
}
589+
#else
590+
static void ntfs_create_procdir(struct super_block *sb) {}
591+
static void ntfs_remove_procdir(struct super_block *sb) {}
558592
#endif
559593

560594
static struct kmem_cache *ntfs_inode_cachep;
@@ -644,15 +678,7 @@ static void ntfs_put_super(struct super_block *sb)
644678
{
645679
struct ntfs_sb_info *sbi = sb->s_fs_info;
646680

647-
#ifdef CONFIG_PROC_FS
648-
// Remove /proc/fs/ntfs3/..
649-
if (sbi->procdir) {
650-
remove_proc_entry("label", sbi->procdir);
651-
remove_proc_entry("volinfo", sbi->procdir);
652-
remove_proc_entry(sb->s_id, proc_info_root);
653-
sbi->procdir = NULL;
654-
}
655-
#endif
681+
ntfs_remove_procdir(sb);
656682

657683
/* Mark rw ntfs as clear, if possible. */
658684
ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
@@ -1590,20 +1616,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
15901616
kfree(boot2);
15911617
}
15921618

1593-
#ifdef CONFIG_PROC_FS
1594-
/* Create /proc/fs/ntfs3/.. */
1595-
if (proc_info_root) {
1596-
struct proc_dir_entry *e = proc_mkdir(sb->s_id, proc_info_root);
1597-
static_assert((S_IRUGO | S_IWUSR) == 0644);
1598-
if (e) {
1599-
proc_create_data("volinfo", S_IRUGO, e,
1600-
&ntfs3_volinfo_fops, sb);
1601-
proc_create_data("label", S_IRUGO | S_IWUSR, e,
1602-
&ntfs3_label_fops, sb);
1603-
sbi->procdir = e;
1604-
}
1605-
}
1606-
#endif
1619+
ntfs_create_procdir(sb);
16071620

16081621
if (is_legacy_ntfs(sb))
16091622
sb->s_flags |= SB_RDONLY;

0 commit comments

Comments
 (0)