@@ -75,7 +75,7 @@ struct ATTR_STD_INFO *ni_std(struct ntfs_inode *ni)
75
75
{
76
76
const struct ATTRIB * attr ;
77
77
78
- attr = mi_find_attr (& ni -> mi , NULL , ATTR_STD , NULL , 0 , NULL );
78
+ attr = mi_find_attr (ni , & ni -> mi , NULL , ATTR_STD , NULL , 0 , NULL );
79
79
return attr ? resident_data_ex (attr , sizeof (struct ATTR_STD_INFO )) :
80
80
NULL ;
81
81
}
@@ -89,7 +89,7 @@ struct ATTR_STD_INFO5 *ni_std5(struct ntfs_inode *ni)
89
89
{
90
90
const struct ATTRIB * attr ;
91
91
92
- attr = mi_find_attr (& ni -> mi , NULL , ATTR_STD , NULL , 0 , NULL );
92
+ attr = mi_find_attr (ni , & ni -> mi , NULL , ATTR_STD , NULL , 0 , NULL );
93
93
94
94
return attr ? resident_data_ex (attr , sizeof (struct ATTR_STD_INFO5 )) :
95
95
NULL ;
@@ -148,8 +148,10 @@ int ni_load_mi_ex(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi)
148
148
goto out ;
149
149
150
150
err = mi_get (ni -> mi .sbi , rno , & r );
151
- if (err )
151
+ if (err ) {
152
+ _ntfs_bad_inode (& ni -> vfs_inode );
152
153
return err ;
154
+ }
153
155
154
156
ni_add_mi (ni , r );
155
157
@@ -201,7 +203,8 @@ struct ATTRIB *ni_find_attr(struct ntfs_inode *ni, struct ATTRIB *attr,
201
203
* mi = & ni -> mi ;
202
204
203
205
/* Look for required attribute in primary record. */
204
- return mi_find_attr (& ni -> mi , attr , type , name , name_len , NULL );
206
+ return mi_find_attr (ni , & ni -> mi , attr , type , name , name_len ,
207
+ NULL );
205
208
}
206
209
207
210
/* First look for list entry of required type. */
@@ -217,7 +220,7 @@ struct ATTRIB *ni_find_attr(struct ntfs_inode *ni, struct ATTRIB *attr,
217
220
return NULL ;
218
221
219
222
/* Look for required attribute. */
220
- attr = mi_find_attr (m , NULL , type , name , name_len , & le -> id );
223
+ attr = mi_find_attr (ni , m , NULL , type , name , name_len , & le -> id );
221
224
222
225
if (!attr )
223
226
goto out ;
@@ -238,8 +241,7 @@ struct ATTRIB *ni_find_attr(struct ntfs_inode *ni, struct ATTRIB *attr,
238
241
return attr ;
239
242
240
243
out :
241
- ntfs_inode_err (& ni -> vfs_inode , "failed to parse mft record" );
242
- ntfs_set_state (ni -> mi .sbi , NTFS_DIRTY_ERROR );
244
+ _ntfs_bad_inode (& ni -> vfs_inode );
243
245
return NULL ;
244
246
}
245
247
@@ -259,7 +261,7 @@ struct ATTRIB *ni_enum_attr_ex(struct ntfs_inode *ni, struct ATTRIB *attr,
259
261
if (mi )
260
262
* mi = & ni -> mi ;
261
263
/* Enum attributes in primary record. */
262
- return mi_enum_attr (& ni -> mi , attr );
264
+ return mi_enum_attr (ni , & ni -> mi , attr );
263
265
}
264
266
265
267
/* Get next list entry. */
@@ -275,7 +277,7 @@ struct ATTRIB *ni_enum_attr_ex(struct ntfs_inode *ni, struct ATTRIB *attr,
275
277
* mi = mi2 ;
276
278
277
279
/* Find attribute in loaded record. */
278
- return rec_find_attr_le (mi2 , le2 );
280
+ return rec_find_attr_le (ni , mi2 , le2 );
279
281
}
280
282
281
283
/*
@@ -293,7 +295,8 @@ struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
293
295
if (!ni -> attr_list .size ) {
294
296
if (pmi )
295
297
* pmi = & ni -> mi ;
296
- return mi_find_attr (& ni -> mi , NULL , type , name , name_len , NULL );
298
+ return mi_find_attr (ni , & ni -> mi , NULL , type , name , name_len ,
299
+ NULL );
297
300
}
298
301
299
302
le = al_find_ex (ni , NULL , type , name , name_len , NULL );
@@ -319,7 +322,7 @@ struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
319
322
if (pmi )
320
323
* pmi = mi ;
321
324
322
- attr = mi_find_attr (mi , NULL , type , name , name_len , & le -> id );
325
+ attr = mi_find_attr (ni , mi , NULL , type , name , name_len , & le -> id );
323
326
if (!attr )
324
327
return NULL ;
325
328
@@ -330,6 +333,7 @@ struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
330
333
vcn <= le64_to_cpu (attr -> nres .evcn ))
331
334
return attr ;
332
335
336
+ _ntfs_bad_inode (& ni -> vfs_inode );
333
337
return NULL ;
334
338
}
335
339
@@ -398,7 +402,8 @@ int ni_remove_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
398
402
int diff ;
399
403
400
404
if (base_only || type == ATTR_LIST || !ni -> attr_list .size ) {
401
- attr = mi_find_attr (& ni -> mi , NULL , type , name , name_len , id );
405
+ attr = mi_find_attr (ni , & ni -> mi , NULL , type , name , name_len ,
406
+ id );
402
407
if (!attr )
403
408
return - ENOENT ;
404
409
@@ -437,7 +442,7 @@ int ni_remove_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
437
442
438
443
al_remove_le (ni , le );
439
444
440
- attr = mi_find_attr (mi , NULL , type , name , name_len , id );
445
+ attr = mi_find_attr (ni , mi , NULL , type , name , name_len , id );
441
446
if (!attr )
442
447
return - ENOENT ;
443
448
@@ -485,7 +490,7 @@ ni_ins_new_attr(struct ntfs_inode *ni, struct mft_inode *mi,
485
490
name = le -> name ;
486
491
}
487
492
488
- attr = mi_insert_attr (mi , type , name , name_len , asize , name_off );
493
+ attr = mi_insert_attr (ni , mi , type , name , name_len , asize , name_off );
489
494
if (!attr ) {
490
495
if (le_added )
491
496
al_remove_le (ni , le );
@@ -673,7 +678,7 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
673
678
if (err )
674
679
return err ;
675
680
676
- attr_list = mi_find_attr (& ni -> mi , NULL , ATTR_LIST , NULL , 0 , NULL );
681
+ attr_list = mi_find_attr (ni , & ni -> mi , NULL , ATTR_LIST , NULL , 0 , NULL );
677
682
if (!attr_list )
678
683
return 0 ;
679
684
@@ -695,7 +700,7 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
695
700
if (!mi )
696
701
return 0 ;
697
702
698
- attr = mi_find_attr (mi , NULL , le -> type , le_name (le ),
703
+ attr = mi_find_attr (ni , mi , NULL , le -> type , le_name (le ),
699
704
le -> name_len , & le -> id );
700
705
if (!attr )
701
706
return 0 ;
@@ -731,7 +736,7 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
731
736
goto out ;
732
737
}
733
738
734
- attr = mi_find_attr (mi , NULL , le -> type , le_name (le ),
739
+ attr = mi_find_attr (ni , mi , NULL , le -> type , le_name (le ),
735
740
le -> name_len , & le -> id );
736
741
if (!attr ) {
737
742
/* Should never happened, 'cause already checked. */
@@ -740,7 +745,7 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
740
745
asize = le32_to_cpu (attr -> size );
741
746
742
747
/* Insert into primary record. */
743
- attr_ins = mi_insert_attr (& ni -> mi , le -> type , le_name (le ),
748
+ attr_ins = mi_insert_attr (ni , & ni -> mi , le -> type , le_name (le ),
744
749
le -> name_len , asize ,
745
750
le16_to_cpu (attr -> name_off ));
746
751
if (!attr_ins ) {
@@ -768,7 +773,7 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
768
773
if (!mi )
769
774
continue ;
770
775
771
- attr = mi_find_attr (mi , NULL , le -> type , le_name (le ),
776
+ attr = mi_find_attr (ni , mi , NULL , le -> type , le_name (le ),
772
777
le -> name_len , & le -> id );
773
778
if (!attr )
774
779
continue ;
@@ -831,7 +836,7 @@ int ni_create_attr_list(struct ntfs_inode *ni)
831
836
free_b = 0 ;
832
837
attr = NULL ;
833
838
834
- for (; (attr = mi_enum_attr (& ni -> mi , attr )); le = Add2Ptr (le , sz )) {
839
+ for (; (attr = mi_enum_attr (ni , & ni -> mi , attr )); le = Add2Ptr (le , sz )) {
835
840
sz = le_size (attr -> name_len );
836
841
le -> type = attr -> type ;
837
842
le -> size = cpu_to_le16 (sz );
@@ -886,7 +891,7 @@ int ni_create_attr_list(struct ntfs_inode *ni)
886
891
u32 asize = le32_to_cpu (b -> size );
887
892
u16 name_off = le16_to_cpu (b -> name_off );
888
893
889
- attr = mi_insert_attr (mi , b -> type , Add2Ptr (b , name_off ),
894
+ attr = mi_insert_attr (ni , mi , b -> type , Add2Ptr (b , name_off ),
890
895
b -> name_len , asize , name_off );
891
896
if (!attr )
892
897
goto out ;
@@ -909,7 +914,7 @@ int ni_create_attr_list(struct ntfs_inode *ni)
909
914
goto out ;
910
915
}
911
916
912
- attr = mi_insert_attr (& ni -> mi , ATTR_LIST , NULL , 0 ,
917
+ attr = mi_insert_attr (ni , & ni -> mi , ATTR_LIST , NULL , 0 ,
913
918
lsize + SIZEOF_RESIDENT , SIZEOF_RESIDENT );
914
919
if (!attr )
915
920
goto out ;
@@ -993,13 +998,13 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
993
998
mi = rb_entry (node , struct mft_inode , node );
994
999
995
1000
if (is_mft_data &&
996
- (mi_enum_attr (mi , NULL ) ||
1001
+ (mi_enum_attr (ni , mi , NULL ) ||
997
1002
vbo <= ((u64 )mi -> rno << sbi -> record_bits ))) {
998
1003
/* We can't accept this record 'cause MFT's bootstrapping. */
999
1004
continue ;
1000
1005
}
1001
1006
if (is_mft &&
1002
- mi_find_attr (mi , NULL , ATTR_DATA , NULL , 0 , NULL )) {
1007
+ mi_find_attr (ni , mi , NULL , ATTR_DATA , NULL , 0 , NULL )) {
1003
1008
/*
1004
1009
* This child record already has a ATTR_DATA.
1005
1010
* So it can't accept any other records.
@@ -1008,7 +1013,7 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
1008
1013
}
1009
1014
1010
1015
if ((type != ATTR_NAME || name_len ) &&
1011
- mi_find_attr (mi , NULL , type , name , name_len , NULL )) {
1016
+ mi_find_attr (ni , mi , NULL , type , name , name_len , NULL )) {
1012
1017
/* Only indexed attributes can share same record. */
1013
1018
continue ;
1014
1019
}
@@ -1157,7 +1162,7 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
1157
1162
/* Estimate the result of moving all possible attributes away. */
1158
1163
attr = NULL ;
1159
1164
1160
- while ((attr = mi_enum_attr (& ni -> mi , attr ))) {
1165
+ while ((attr = mi_enum_attr (ni , & ni -> mi , attr ))) {
1161
1166
if (attr -> type == ATTR_STD )
1162
1167
continue ;
1163
1168
if (attr -> type == ATTR_LIST )
@@ -1175,7 +1180,7 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
1175
1180
attr = NULL ;
1176
1181
1177
1182
for (;;) {
1178
- attr = mi_enum_attr (& ni -> mi , attr );
1183
+ attr = mi_enum_attr (ni , & ni -> mi , attr );
1179
1184
if (!attr ) {
1180
1185
/* We should never be here 'cause we have already check this case. */
1181
1186
err = - EINVAL ;
@@ -1259,7 +1264,7 @@ static int ni_expand_mft_list(struct ntfs_inode *ni)
1259
1264
for (node = rb_first (& ni -> mi_tree ); node ; node = rb_next (node )) {
1260
1265
mi = rb_entry (node , struct mft_inode , node );
1261
1266
1262
- attr = mi_enum_attr (mi , NULL );
1267
+ attr = mi_enum_attr (ni , mi , NULL );
1263
1268
1264
1269
if (!attr ) {
1265
1270
mft_min = mi -> rno ;
@@ -1280,7 +1285,7 @@ static int ni_expand_mft_list(struct ntfs_inode *ni)
1280
1285
ni_remove_mi (ni , mi_new );
1281
1286
}
1282
1287
1283
- attr = mi_find_attr (& ni -> mi , NULL , ATTR_DATA , NULL , 0 , NULL );
1288
+ attr = mi_find_attr (ni , & ni -> mi , NULL , ATTR_DATA , NULL , 0 , NULL );
1284
1289
if (!attr ) {
1285
1290
err = - EINVAL ;
1286
1291
goto out ;
@@ -1397,7 +1402,7 @@ int ni_expand_list(struct ntfs_inode *ni)
1397
1402
continue ;
1398
1403
1399
1404
/* Find attribute in primary record. */
1400
- attr = rec_find_attr_le (& ni -> mi , le );
1405
+ attr = rec_find_attr_le (ni , & ni -> mi , le );
1401
1406
if (!attr ) {
1402
1407
err = - EINVAL ;
1403
1408
goto out ;
@@ -1604,8 +1609,8 @@ int ni_delete_all(struct ntfs_inode *ni)
1604
1609
roff = le16_to_cpu (attr -> nres .run_off );
1605
1610
1606
1611
if (roff > asize ) {
1607
- _ntfs_bad_inode ( & ni -> vfs_inode );
1608
- return - EINVAL ;
1612
+ /* ni_enum_attr_ex checks this case. */
1613
+ continue ;
1609
1614
}
1610
1615
1611
1616
/* run==1 means unpack and deallocate. */
@@ -2726,9 +2731,10 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages,
2726
2731
{
2727
2732
int err ;
2728
2733
struct ntfs_sb_info * sbi = ni -> mi .sbi ;
2734
+ struct folio * folio = page_folio (pages [0 ]);
2729
2735
u8 frame_bits = NTFS_LZNT_CUNIT + sbi -> cluster_bits ;
2730
2736
u32 frame_size = sbi -> cluster_size << NTFS_LZNT_CUNIT ;
2731
- u64 frame_vbo = ( u64 ) pages [ 0 ] -> index << PAGE_SHIFT ;
2737
+ u64 frame_vbo = folio_pos ( folio ) ;
2732
2738
CLST frame = frame_vbo >> frame_bits ;
2733
2739
char * frame_ondisk = NULL ;
2734
2740
struct page * * pages_disk = NULL ;
@@ -3343,7 +3349,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
3343
3349
if (!mi -> dirty )
3344
3350
continue ;
3345
3351
3346
- is_empty = !mi_enum_attr (mi , NULL );
3352
+ is_empty = !mi_enum_attr (ni , mi , NULL );
3347
3353
3348
3354
if (is_empty )
3349
3355
clear_rec_inuse (mi -> mrec );
0 commit comments