@@ -1076,15 +1076,15 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark,
1076
1076
}
1077
1077
1078
1078
static int fanotify_remove_mark (struct fsnotify_group * group ,
1079
- fsnotify_connp_t * connp , __u32 mask ,
1079
+ void * obj , unsigned int obj_type , __u32 mask ,
1080
1080
unsigned int flags , __u32 umask )
1081
1081
{
1082
1082
struct fsnotify_mark * fsn_mark = NULL ;
1083
1083
__u32 removed ;
1084
1084
int destroy_mark ;
1085
1085
1086
1086
fsnotify_group_lock (group );
1087
- fsn_mark = fsnotify_find_mark (connp , group );
1087
+ fsn_mark = fsnotify_find_mark (obj , obj_type , group );
1088
1088
if (!fsn_mark ) {
1089
1089
fsnotify_group_unlock (group );
1090
1090
return - ENOENT ;
@@ -1105,30 +1105,6 @@ static int fanotify_remove_mark(struct fsnotify_group *group,
1105
1105
return 0 ;
1106
1106
}
1107
1107
1108
- static int fanotify_remove_vfsmount_mark (struct fsnotify_group * group ,
1109
- struct vfsmount * mnt , __u32 mask ,
1110
- unsigned int flags , __u32 umask )
1111
- {
1112
- return fanotify_remove_mark (group , & real_mount (mnt )-> mnt_fsnotify_marks ,
1113
- mask , flags , umask );
1114
- }
1115
-
1116
- static int fanotify_remove_sb_mark (struct fsnotify_group * group ,
1117
- struct super_block * sb , __u32 mask ,
1118
- unsigned int flags , __u32 umask )
1119
- {
1120
- return fanotify_remove_mark (group , & sb -> s_fsnotify_marks , mask ,
1121
- flags , umask );
1122
- }
1123
-
1124
- static int fanotify_remove_inode_mark (struct fsnotify_group * group ,
1125
- struct inode * inode , __u32 mask ,
1126
- unsigned int flags , __u32 umask )
1127
- {
1128
- return fanotify_remove_mark (group , & inode -> i_fsnotify_marks , mask ,
1129
- flags , umask );
1130
- }
1131
-
1132
1108
static bool fanotify_mark_update_flags (struct fsnotify_mark * fsn_mark ,
1133
1109
unsigned int fan_flags )
1134
1110
{
@@ -1249,7 +1225,7 @@ static int fanotify_set_mark_fsid(struct fsnotify_group *group,
1249
1225
}
1250
1226
1251
1227
static struct fsnotify_mark * fanotify_add_new_mark (struct fsnotify_group * group ,
1252
- fsnotify_connp_t * connp ,
1228
+ void * obj ,
1253
1229
unsigned int obj_type ,
1254
1230
unsigned int fan_flags ,
1255
1231
struct fan_fsid * fsid )
@@ -1288,7 +1264,7 @@ static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
1288
1264
fan_mark -> fsid .val [0 ] = fan_mark -> fsid .val [1 ] = 0 ;
1289
1265
}
1290
1266
1291
- ret = fsnotify_add_mark_locked (mark , connp , obj_type , 0 );
1267
+ ret = fsnotify_add_mark_locked (mark , obj , obj_type , 0 );
1292
1268
if (ret )
1293
1269
goto out_put_mark ;
1294
1270
@@ -1344,7 +1320,7 @@ static int fanotify_may_update_existing_mark(struct fsnotify_mark *fsn_mark,
1344
1320
}
1345
1321
1346
1322
static int fanotify_add_mark (struct fsnotify_group * group ,
1347
- fsnotify_connp_t * connp , unsigned int obj_type ,
1323
+ void * obj , unsigned int obj_type ,
1348
1324
__u32 mask , unsigned int fan_flags ,
1349
1325
struct fan_fsid * fsid )
1350
1326
{
@@ -1353,9 +1329,9 @@ static int fanotify_add_mark(struct fsnotify_group *group,
1353
1329
int ret = 0 ;
1354
1330
1355
1331
fsnotify_group_lock (group );
1356
- fsn_mark = fsnotify_find_mark (connp , group );
1332
+ fsn_mark = fsnotify_find_mark (obj , obj_type , group );
1357
1333
if (!fsn_mark ) {
1358
- fsn_mark = fanotify_add_new_mark (group , connp , obj_type ,
1334
+ fsn_mark = fanotify_add_new_mark (group , obj , obj_type ,
1359
1335
fan_flags , fsid );
1360
1336
if (IS_ERR (fsn_mark )) {
1361
1337
fsnotify_group_unlock (group );
@@ -1392,30 +1368,6 @@ static int fanotify_add_mark(struct fsnotify_group *group,
1392
1368
return ret ;
1393
1369
}
1394
1370
1395
- static int fanotify_add_vfsmount_mark (struct fsnotify_group * group ,
1396
- struct vfsmount * mnt , __u32 mask ,
1397
- unsigned int flags , struct fan_fsid * fsid )
1398
- {
1399
- return fanotify_add_mark (group , & real_mount (mnt )-> mnt_fsnotify_marks ,
1400
- FSNOTIFY_OBJ_TYPE_VFSMOUNT , mask , flags , fsid );
1401
- }
1402
-
1403
- static int fanotify_add_sb_mark (struct fsnotify_group * group ,
1404
- struct super_block * sb , __u32 mask ,
1405
- unsigned int flags , struct fan_fsid * fsid )
1406
- {
1407
- return fanotify_add_mark (group , & sb -> s_fsnotify_marks ,
1408
- FSNOTIFY_OBJ_TYPE_SB , mask , flags , fsid );
1409
- }
1410
-
1411
- static int fanotify_add_inode_mark (struct fsnotify_group * group ,
1412
- struct inode * inode , __u32 mask ,
1413
- unsigned int flags , struct fan_fsid * fsid )
1414
- {
1415
- return fanotify_add_mark (group , & inode -> i_fsnotify_marks ,
1416
- FSNOTIFY_OBJ_TYPE_INODE , mask , flags , fsid );
1417
- }
1418
-
1419
1371
static struct fsnotify_event * fanotify_alloc_overflow_event (void )
1420
1372
{
1421
1373
struct fanotify_event * oevent ;
@@ -1738,6 +1690,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
1738
1690
unsigned int mark_cmd = flags & FANOTIFY_MARK_CMD_BITS ;
1739
1691
unsigned int ignore = flags & FANOTIFY_MARK_IGNORE_BITS ;
1740
1692
unsigned int obj_type , fid_mode ;
1693
+ void * obj ;
1741
1694
u32 umask = 0 ;
1742
1695
int ret ;
1743
1696
@@ -1896,10 +1849,16 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
1896
1849
}
1897
1850
1898
1851
/* inode held in place by reference to path; group by fget on fd */
1899
- if (mark_type == FAN_MARK_INODE )
1852
+ if (mark_type == FAN_MARK_INODE ) {
1900
1853
inode = path .dentry -> d_inode ;
1901
- else
1854
+ obj = inode ;
1855
+ } else {
1902
1856
mnt = path .mnt ;
1857
+ if (mark_type == FAN_MARK_MOUNT )
1858
+ obj = mnt ;
1859
+ else
1860
+ obj = mnt -> mnt_sb ;
1861
+ }
1903
1862
1904
1863
/*
1905
1864
* If some other task has this inode open for write we should not add
@@ -1935,26 +1894,12 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
1935
1894
/* create/update an inode mark */
1936
1895
switch (mark_cmd ) {
1937
1896
case FAN_MARK_ADD :
1938
- if (mark_type == FAN_MARK_MOUNT )
1939
- ret = fanotify_add_vfsmount_mark (group , mnt , mask ,
1940
- flags , fsid );
1941
- else if (mark_type == FAN_MARK_FILESYSTEM )
1942
- ret = fanotify_add_sb_mark (group , mnt -> mnt_sb , mask ,
1943
- flags , fsid );
1944
- else
1945
- ret = fanotify_add_inode_mark (group , inode , mask ,
1946
- flags , fsid );
1897
+ ret = fanotify_add_mark (group , obj , obj_type , mask , flags ,
1898
+ fsid );
1947
1899
break ;
1948
1900
case FAN_MARK_REMOVE :
1949
- if (mark_type == FAN_MARK_MOUNT )
1950
- ret = fanotify_remove_vfsmount_mark (group , mnt , mask ,
1951
- flags , umask );
1952
- else if (mark_type == FAN_MARK_FILESYSTEM )
1953
- ret = fanotify_remove_sb_mark (group , mnt -> mnt_sb , mask ,
1954
- flags , umask );
1955
- else
1956
- ret = fanotify_remove_inode_mark (group , inode , mask ,
1957
- flags , umask );
1901
+ ret = fanotify_remove_mark (group , obj , obj_type , mask , flags ,
1902
+ umask );
1958
1903
break ;
1959
1904
default :
1960
1905
ret = - EINVAL ;
0 commit comments