summaryrefslogtreecommitdiff
path: root/fs/exfat/dir.c
diff options
context:
space:
mode:
authorYuezhang Mo <Yuezhang.Mo@sony.com>2023-07-20 09:40:08 +0300
committerNamjae Jeon <linkinjeon@kernel.org>2023-10-31 04:01:45 +0300
commitee785c15b5906a69d4007b4754e8ae40fb41e0b4 (patch)
treed5960f2815f9fa05ae3310aadad0670aebee52a4 /fs/exfat/dir.c
parentdab48b8f2fe7264d51ec9eed0adea0fe3c78830a (diff)
downloadlinux-ee785c15b5906a69d4007b4754e8ae40fb41e0b4.tar.xz
exfat: support create zero-size directory
This commit adds mount option 'zero_size_dir'. If this option enabled, don't allocate a cluster to directory when creating it, and set the directory size to 0. On Windows, a cluster is allocated for a directory when it is created, so the mount option is disabled by default. Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Reviewed-by: Andy Wu <Andy.Wu@sony.com> Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Diffstat (limited to 'fs/exfat/dir.c')
-rw-r--r--fs/exfat/dir.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index fdd46aa466e1..9f9295847a4e 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -418,11 +418,13 @@ static void exfat_set_entry_type(struct exfat_dentry *ep, unsigned int type)
}
static void exfat_init_stream_entry(struct exfat_dentry *ep,
- unsigned char flags, unsigned int start_clu,
- unsigned long long size)
+ unsigned int start_clu, unsigned long long size)
{
exfat_set_entry_type(ep, TYPE_STREAM);
- ep->dentry.stream.flags = flags;
+ if (size == 0)
+ ep->dentry.stream.flags = ALLOC_FAT_CHAIN;
+ else
+ ep->dentry.stream.flags = ALLOC_NO_FAT_CHAIN;
ep->dentry.stream.start_clu = cpu_to_le32(start_clu);
ep->dentry.stream.valid_size = cpu_to_le64(size);
ep->dentry.stream.size = cpu_to_le64(size);
@@ -488,9 +490,7 @@ int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
if (!ep)
return -EIO;
- exfat_init_stream_entry(ep,
- (type == TYPE_FILE) ? ALLOC_FAT_CHAIN : ALLOC_NO_FAT_CHAIN,
- start_clu, size);
+ exfat_init_stream_entry(ep, start_clu, size);
exfat_update_bh(bh, IS_DIRSYNC(inode));
brelse(bh);