Skip to content

Commit 227468f

Browse files
Chi Zhilingnamjaejeon
authored andcommitted
exfat: introduce exfat_chain_advance helper
Introduce exfat_chain_advance() to walk a exfat_chain structure by a given step, updating both ->dir and ->size fields atomically. This helper handles both ALLOC_NO_FAT_CHAIN and ALLOC_FAT_CHAIN modes with proper boundary checking. Suggested-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent f764c58 commit 227468f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

fs/exfat/exfat_fs.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,27 @@ int exfat_read_volume_label(struct super_block *sb,
552552
int exfat_write_volume_label(struct super_block *sb,
553553
struct exfat_uni_name *label);
554554

555+
static inline int exfat_chain_advance(struct super_block *sb,
556+
struct exfat_chain *chain, unsigned int step)
557+
{
558+
unsigned int clu = chain->dir;
559+
560+
if (unlikely(chain->size < step))
561+
return -EIO;
562+
563+
if (exfat_cluster_walk(sb, &clu, step, chain->flags))
564+
return -EIO;
565+
566+
chain->size -= step;
567+
568+
if (chain->size == 0 && chain->flags == ALLOC_NO_FAT_CHAIN)
569+
chain->dir = EXFAT_EOF_CLUSTER;
570+
else
571+
chain->dir = clu;
572+
573+
return 0;
574+
}
575+
555576
/* inode.c */
556577
extern const struct inode_operations exfat_file_inode_operations;
557578
void exfat_sync_inode(struct inode *inode);

0 commit comments

Comments
 (0)