@@ -555,6 +555,40 @@ static const struct proc_ops ntfs3_label_fops = {
555
555
.proc_write = ntfs3_label_write ,
556
556
};
557
557
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 ) {}
558
592
#endif
559
593
560
594
static struct kmem_cache * ntfs_inode_cachep ;
@@ -644,15 +678,7 @@ static void ntfs_put_super(struct super_block *sb)
644
678
{
645
679
struct ntfs_sb_info * sbi = sb -> s_fs_info ;
646
680
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 );
656
682
657
683
/* Mark rw ntfs as clear, if possible. */
658
684
ntfs_set_state (sbi , NTFS_DIRTY_CLEAR );
@@ -1590,20 +1616,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
1590
1616
kfree (boot2 );
1591
1617
}
1592
1618
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 );
1607
1620
1608
1621
if (is_legacy_ntfs (sb ))
1609
1622
sb -> s_flags |= SB_RDONLY ;
0 commit comments