clu_offset = EXFAT_DEN_TO_CLU(dentry, sbi);
exfat_chain_dup(&clu, &dir);
- if (clu.flags == ALLOC_NO_FAT_CHAIN) {
- clu.dir += clu_offset;
- clu.size -= clu_offset;
- } else {
+ if (clu.flags == ALLOC_FAT_CHAIN) {
/* hint_information */
if (clu_offset > 0 && ei->hint_bmap.off != EXFAT_EOF_CLUSTER &&
ei->hint_bmap.off > 0 && clu_offset >= ei->hint_bmap.off) {
clu_offset -= ei->hint_bmap.off;
clu.dir = ei->hint_bmap.clu;
- }
-
- while (clu_offset > 0 && clu.dir != EXFAT_EOF_CLUSTER) {
- if (exfat_get_next_cluster(sb, &(clu.dir)))
- return -EIO;
-
- clu_offset--;
+ clu.size -= ei->hint_bmap.off;
}
}
+ if (exfat_chain_advance(sb, &clu, clu_offset))
+ return -EIO;
+
while (clu.dir != EXFAT_EOF_CLUSTER && dentry < max_dentries) {
i = dentry & (dentries_per_clu - 1);
return 0;
}
- if (clu.flags == ALLOC_NO_FAT_CHAIN) {
- if (--clu.size > 0)
- clu.dir++;
- else
- clu.dir = EXFAT_EOF_CLUSTER;
- } else {
- if (exfat_get_next_cluster(sb, &(clu.dir)))
- return -EIO;
- }
+ if (exfat_chain_advance(sb, &clu, 1))
+ return -EIO;
}
out:
step = DIRENT_STEP_FILE;
}
- if (clu.flags == ALLOC_NO_FAT_CHAIN) {
- if (--clu.size > 0)
- clu.dir++;
- else
- clu.dir = EXFAT_EOF_CLUSTER;
- } else {
- if (exfat_get_next_cluster(sb, &clu.dir))
- return -EIO;
+ if (exfat_chain_advance(sb, &clu, 1))
+ return -EIO;
- /* break if the cluster chain includes a loop */
- if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi)))
- goto not_found;
- }
+ /* break if the cluster chain includes a loop */
+ if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi)))
+ goto not_found;
}
not_found:
if (!((dentry + 1) & (dentries_per_clu - 1))) {
int ret = 0;
- if (clu.flags == ALLOC_NO_FAT_CHAIN) {
- if (--clu.size > 0)
- clu.dir++;
- else
- clu.dir = EXFAT_EOF_CLUSTER;
- } else {
- ret = exfat_get_next_cluster(sb, &clu.dir);
- }
+ ret = exfat_chain_advance(sb, &clu, 1);
if (ret || clu.dir == EXFAT_EOF_CLUSTER) {
/* just initialized hint_stat */
count++;
}
- if (clu.flags == ALLOC_NO_FAT_CHAIN) {
- if (--clu.size > 0)
- clu.dir++;
- else
- clu.dir = EXFAT_EOF_CLUSTER;
- } else {
- if (exfat_get_next_cluster(sb, &(clu.dir)))
- return -EIO;
-
- if (unlikely(++clu_count > sbi->used_clusters)) {
- exfat_fs_error(sb, "FAT or bitmap is corrupted");
- return -EIO;
- }
+ if (exfat_chain_advance(sb, &clu, 1))
+ return -EIO;
+ if (unlikely(++clu_count > sbi->used_clusters)) {
+ exfat_fs_error(sb, "FAT or bitmap is corrupted");
+ return -EIO;
}
}
i += ret;
while (i >= dentries_per_clu) {
- if (clu.flags == ALLOC_NO_FAT_CHAIN) {
- if (--clu.size > 0)
- clu.dir++;
- else
- clu.dir = EXFAT_EOF_CLUSTER;
- } else {
- if (exfat_get_next_cluster(sb, &clu.dir))
- return -EIO;
- }
+ if (exfat_chain_advance(sb, &clu, 1))
+ return -EIO;
i -= dentries_per_clu;
}
return -ENOTEMPTY;
}
- if (clu.flags == ALLOC_NO_FAT_CHAIN) {
- if (--clu.size > 0)
- clu.dir++;
- else
- clu.dir = EXFAT_EOF_CLUSTER;
- } else {
- if (exfat_get_next_cluster(sb, &(clu.dir)))
- return -EIO;
+ if (exfat_chain_advance(sb, &clu, 1))
+ return -EIO;
- /* break if the cluster chain includes a loop */
- if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi)))
- break;
- }
+ /* break if the cluster chain includes a loop */
+ if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi)))
+ break;
}
return 0;