@@ -775,7 +775,6 @@ struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
775
775
}
776
776
777
777
enum exfat_validate_dentry_mode {
778
- ES_MODE_STARTED ,
779
778
ES_MODE_GET_FILE_ENTRY ,
780
779
ES_MODE_GET_STRM_ENTRY ,
781
780
ES_MODE_GET_NAME_ENTRY ,
@@ -790,11 +789,6 @@ static bool exfat_validate_entry(unsigned int type,
790
789
return false;
791
790
792
791
switch (* mode ) {
793
- case ES_MODE_STARTED :
794
- if (type != TYPE_FILE && type != TYPE_DIR )
795
- return false;
796
- * mode = ES_MODE_GET_FILE_ENTRY ;
797
- break ;
798
792
case ES_MODE_GET_FILE_ENTRY :
799
793
if (type != TYPE_STREAM )
800
794
return false;
@@ -834,30 +828,32 @@ struct exfat_dentry *exfat_get_dentry_cached(
834
828
}
835
829
836
830
/*
837
- * Returns a set of dentries for a file or dir .
831
+ * Returns a set of dentries.
838
832
*
839
833
* Note It provides a direct pointer to bh->data via exfat_get_dentry_cached().
840
834
* User should call exfat_get_dentry_set() after setting 'modified' to apply
841
835
* changes made in this entry set to the real device.
842
836
*
843
837
* in:
844
838
* sb+p_dir+entry: indicates a file/dir
845
- * type: specifies how many dentries should be included.
839
+ * num_entries: specifies how many dentries should be included.
840
+ * It will be set to es->num_entries if it is not 0.
841
+ * If num_entries is 0, es->num_entries will be obtained
842
+ * from the first dentry.
843
+ * out:
844
+ * es: pointer of entry set on success.
846
845
* return:
847
- * pointer of entry set on success,
848
- * NULL on failure.
846
+ * 0 on success
847
+ * -error code on failure
849
848
*/
850
- int exfat_get_dentry_set (struct exfat_entry_set_cache * es ,
849
+ static int __exfat_get_dentry_set (struct exfat_entry_set_cache * es ,
851
850
struct super_block * sb , struct exfat_chain * p_dir , int entry ,
852
- unsigned int type )
851
+ unsigned int num_entries )
853
852
{
854
853
int ret , i , num_bh ;
855
854
unsigned int off ;
856
855
sector_t sec ;
857
856
struct exfat_sb_info * sbi = EXFAT_SB (sb );
858
- struct exfat_dentry * ep ;
859
- int num_entries ;
860
- enum exfat_validate_dentry_mode mode = ES_MODE_STARTED ;
861
857
struct buffer_head * bh ;
862
858
863
859
if (p_dir -> dir == DIR_DELETED ) {
@@ -880,12 +876,18 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
880
876
return - EIO ;
881
877
es -> bh [es -> num_bh ++ ] = bh ;
882
878
883
- ep = exfat_get_dentry_cached (es , ES_IDX_FILE );
884
- if (!exfat_validate_entry (exfat_get_entry_type (ep ), & mode ))
885
- goto put_es ;
879
+ if (num_entries == ES_ALL_ENTRIES ) {
880
+ struct exfat_dentry * ep ;
881
+
882
+ ep = exfat_get_dentry_cached (es , ES_IDX_FILE );
883
+ if (ep -> type != EXFAT_FILE ) {
884
+ brelse (bh );
885
+ return - EIO ;
886
+ }
887
+
888
+ num_entries = ep -> dentry .file .num_ext + 1 ;
889
+ }
886
890
887
- num_entries = type == ES_ALL_ENTRIES ?
888
- ep -> dentry .file .num_ext + 1 : type ;
889
891
es -> num_entries = num_entries ;
890
892
891
893
num_bh = EXFAT_B_TO_BLK_ROUND_UP (off + num_entries * DENTRY_SIZE , sb );
@@ -918,8 +920,27 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
918
920
es -> bh [es -> num_bh ++ ] = bh ;
919
921
}
920
922
923
+ return 0 ;
924
+
925
+ put_es :
926
+ exfat_put_dentry_set (es , false);
927
+ return - EIO ;
928
+ }
929
+
930
+ int exfat_get_dentry_set (struct exfat_entry_set_cache * es ,
931
+ struct super_block * sb , struct exfat_chain * p_dir ,
932
+ int entry , unsigned int num_entries )
933
+ {
934
+ int ret , i ;
935
+ struct exfat_dentry * ep ;
936
+ enum exfat_validate_dentry_mode mode = ES_MODE_GET_FILE_ENTRY ;
937
+
938
+ ret = __exfat_get_dentry_set (es , sb , p_dir , entry , num_entries );
939
+ if (ret < 0 )
940
+ return ret ;
941
+
921
942
/* validate cached dentries */
922
- for (i = ES_IDX_STREAM ; i < num_entries ; i ++ ) {
943
+ for (i = ES_IDX_STREAM ; i < es -> num_entries ; i ++ ) {
923
944
ep = exfat_get_dentry_cached (es , i );
924
945
if (!exfat_validate_entry (exfat_get_entry_type (ep ), & mode ))
925
946
goto put_es ;
0 commit comments