@@ -524,65 +524,50 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark,
524
524
return mask & oldmask ;
525
525
}
526
526
527
- static int fanotify_remove_vfsmount_mark (struct fsnotify_group * group ,
528
- struct vfsmount * mnt , __u32 mask ,
529
- unsigned int flags )
527
+ static int fanotify_remove_mark (struct fsnotify_group * group ,
528
+ fsnotify_connp_t * connp , __u32 mask ,
529
+ unsigned int flags )
530
530
{
531
531
struct fsnotify_mark * fsn_mark = NULL ;
532
532
__u32 removed ;
533
533
int destroy_mark ;
534
534
535
535
mutex_lock (& group -> mark_mutex );
536
- fsn_mark = fsnotify_find_mark (& real_mount (mnt )-> mnt_fsnotify_marks ,
537
- group );
536
+ fsn_mark = fsnotify_find_mark (connp , group );
538
537
if (!fsn_mark ) {
539
538
mutex_unlock (& group -> mark_mutex );
540
539
return - ENOENT ;
541
540
}
542
541
543
542
removed = fanotify_mark_remove_from_mask (fsn_mark , mask , flags ,
544
543
& destroy_mark );
545
- if (removed & real_mount ( mnt ) -> mnt_fsnotify_mask )
546
- fsnotify_recalc_mask (real_mount ( mnt ) -> mnt_fsnotify_marks );
544
+ if (removed & fsnotify_conn_mask ( fsn_mark -> connector ) )
545
+ fsnotify_recalc_mask (fsn_mark -> connector );
547
546
if (destroy_mark )
548
547
fsnotify_detach_mark (fsn_mark );
549
548
mutex_unlock (& group -> mark_mutex );
550
549
if (destroy_mark )
551
550
fsnotify_free_mark (fsn_mark );
552
551
552
+ /* matches the fsnotify_find_mark() */
553
553
fsnotify_put_mark (fsn_mark );
554
554
return 0 ;
555
555
}
556
556
557
+ static int fanotify_remove_vfsmount_mark (struct fsnotify_group * group ,
558
+ struct vfsmount * mnt , __u32 mask ,
559
+ unsigned int flags )
560
+ {
561
+ return fanotify_remove_mark (group , & real_mount (mnt )-> mnt_fsnotify_marks ,
562
+ mask , flags );
563
+ }
564
+
557
565
static int fanotify_remove_inode_mark (struct fsnotify_group * group ,
558
566
struct inode * inode , __u32 mask ,
559
567
unsigned int flags )
560
568
{
561
- struct fsnotify_mark * fsn_mark = NULL ;
562
- __u32 removed ;
563
- int destroy_mark ;
564
-
565
- mutex_lock (& group -> mark_mutex );
566
- fsn_mark = fsnotify_find_mark (& inode -> i_fsnotify_marks , group );
567
- if (!fsn_mark ) {
568
- mutex_unlock (& group -> mark_mutex );
569
- return - ENOENT ;
570
- }
571
-
572
- removed = fanotify_mark_remove_from_mask (fsn_mark , mask , flags ,
573
- & destroy_mark );
574
- if (removed & inode -> i_fsnotify_mask )
575
- fsnotify_recalc_mask (inode -> i_fsnotify_marks );
576
- if (destroy_mark )
577
- fsnotify_detach_mark (fsn_mark );
578
- mutex_unlock (& group -> mark_mutex );
579
- if (destroy_mark )
580
- fsnotify_free_mark (fsn_mark );
581
-
582
- /* matches the fsnotify_find_mark() */
583
- fsnotify_put_mark (fsn_mark );
584
-
585
- return 0 ;
569
+ return fanotify_remove_mark (group , & inode -> i_fsnotify_marks , mask ,
570
+ flags );
586
571
}
587
572
588
573
static __u32 fanotify_mark_add_to_mask (struct fsnotify_mark * fsn_mark ,
@@ -615,8 +600,8 @@ static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark,
615
600
}
616
601
617
602
static struct fsnotify_mark * fanotify_add_new_mark (struct fsnotify_group * group ,
618
- struct inode * inode ,
619
- struct vfsmount * mnt )
603
+ fsnotify_connp_t * connp ,
604
+ unsigned int type )
620
605
{
621
606
struct fsnotify_mark * mark ;
622
607
int ret ;
@@ -629,7 +614,7 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
629
614
return ERR_PTR (- ENOMEM );
630
615
631
616
fsnotify_init_mark (mark , group );
632
- ret = fsnotify_add_mark_locked (mark , inode , mnt , 0 );
617
+ ret = fsnotify_add_mark_locked (mark , connp , type , 0 );
633
618
if (ret ) {
634
619
fsnotify_put_mark (mark );
635
620
return ERR_PTR (ret );
@@ -639,39 +624,43 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
639
624
}
640
625
641
626
642
- static int fanotify_add_vfsmount_mark (struct fsnotify_group * group ,
643
- struct vfsmount * mnt , __u32 mask ,
644
- unsigned int flags )
627
+ static int fanotify_add_mark (struct fsnotify_group * group ,
628
+ fsnotify_connp_t * connp , unsigned int type ,
629
+ __u32 mask , unsigned int flags )
645
630
{
646
631
struct fsnotify_mark * fsn_mark ;
647
632
__u32 added ;
648
633
649
634
mutex_lock (& group -> mark_mutex );
650
- fsn_mark = fsnotify_find_mark (& real_mount (mnt )-> mnt_fsnotify_marks ,
651
- group );
635
+ fsn_mark = fsnotify_find_mark (connp , group );
652
636
if (!fsn_mark ) {
653
- fsn_mark = fanotify_add_new_mark (group , NULL , mnt );
637
+ fsn_mark = fanotify_add_new_mark (group , connp , type );
654
638
if (IS_ERR (fsn_mark )) {
655
639
mutex_unlock (& group -> mark_mutex );
656
640
return PTR_ERR (fsn_mark );
657
641
}
658
642
}
659
643
added = fanotify_mark_add_to_mask (fsn_mark , mask , flags );
660
- if (added & ~real_mount ( mnt ) -> mnt_fsnotify_mask )
661
- fsnotify_recalc_mask (real_mount ( mnt ) -> mnt_fsnotify_marks );
644
+ if (added & ~fsnotify_conn_mask ( fsn_mark -> connector ) )
645
+ fsnotify_recalc_mask (fsn_mark -> connector );
662
646
mutex_unlock (& group -> mark_mutex );
663
647
664
648
fsnotify_put_mark (fsn_mark );
665
649
return 0 ;
666
650
}
667
651
652
+ static int fanotify_add_vfsmount_mark (struct fsnotify_group * group ,
653
+ struct vfsmount * mnt , __u32 mask ,
654
+ unsigned int flags )
655
+ {
656
+ return fanotify_add_mark (group , & real_mount (mnt )-> mnt_fsnotify_marks ,
657
+ FSNOTIFY_OBJ_TYPE_VFSMOUNT , mask , flags );
658
+ }
659
+
668
660
static int fanotify_add_inode_mark (struct fsnotify_group * group ,
669
661
struct inode * inode , __u32 mask ,
670
662
unsigned int flags )
671
663
{
672
- struct fsnotify_mark * fsn_mark ;
673
- __u32 added ;
674
-
675
664
pr_debug ("%s: group=%p inode=%p\n" , __func__ , group , inode );
676
665
677
666
/*
@@ -684,22 +673,8 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
684
673
(atomic_read (& inode -> i_writecount ) > 0 ))
685
674
return 0 ;
686
675
687
- mutex_lock (& group -> mark_mutex );
688
- fsn_mark = fsnotify_find_mark (& inode -> i_fsnotify_marks , group );
689
- if (!fsn_mark ) {
690
- fsn_mark = fanotify_add_new_mark (group , inode , NULL );
691
- if (IS_ERR (fsn_mark )) {
692
- mutex_unlock (& group -> mark_mutex );
693
- return PTR_ERR (fsn_mark );
694
- }
695
- }
696
- added = fanotify_mark_add_to_mask (fsn_mark , mask , flags );
697
- if (added & ~inode -> i_fsnotify_mask )
698
- fsnotify_recalc_mask (inode -> i_fsnotify_marks );
699
- mutex_unlock (& group -> mark_mutex );
700
-
701
- fsnotify_put_mark (fsn_mark );
702
- return 0 ;
676
+ return fanotify_add_mark (group , & inode -> i_fsnotify_marks ,
677
+ FSNOTIFY_OBJ_TYPE_INODE , mask , flags );
703
678
}
704
679
705
680
/* fanotify syscalls */
0 commit comments