Description for this pull request:
- Replace memcpy with structure assignment. - Remove unneeded codes and use helper function i_blocksize(). - Fix typos found by codespell. -----BEGIN PGP SIGNATURE----- iQJMBAABCgA2FiEE6NzKS6Uv/XAAGHgyZwv7A1FEIQgFAl+QyhMYHG5hbWphZS5q ZW9uQHNhbXN1bmcuY29tAAoJEGcL+wNRRCEIhHQP/Rfk21jZ0iRzoVG5WXVWpqrG wYCUWZu2xXmuqO+NroZ7vmSloTkj7txOSt2nyEHdbJhABOzWFxyU+pfYRpLcXVC0 uNt0Qk5wrey6JM+93ulwdrAKHqQzd5B4rv/wli4pNQKuh9FQSWUIJSEUw7m3LRvi R9TbXCwBRiMIC0NPZMNrjOtrpjHcqhAWRQHsLIoA+7XCgQ4z8T1t0IlASuCy4HTb nUNkfc7lMzFp0aW19T2EJYr6X7Yle56Ad91kFhHh9qKZEp9ET81Q3kaA5tVSGCMc hCTDdBopOvfXOuwkmDKIYObfMiAauWiGSMlP+WKQ26jfh8fLEc8MT+dInfuqSs76 dL6vtOtId/lzhTk7XjUGP3WDxmyNL9Ri9HqYfHydEUphWdWBusr1pxIMvllc6bAs PLJ9CgJHjAmRMBOpVQELRgqTqqsQgfpX/x5EmA0h4CW1JfwCTH7Y62bSI7G7RgCi sMuW57IzGBGNDw4KyFLRg0G/V8z05aehsXWqDBNfJCYbBGIHvxg0pofGHFcc8sla +HQt5rfjn7XU5RngyN5zf/ZOtuM6/tklGs2mbGNVSgZ1Px2W03k9iXU2tx4PTPIY RRNDodgVbHldB7PPllCLRJwb2m9ungz1GF/H84dNujK2oyZNksTvDCS4Ad7uW8Bf lujSPhSDZB730gYly/Vr =qmM6 -----END PGP SIGNATURE----- Merge tag 'exfat-for-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat Pull exfat updates from Namjae Jeon: - Replace memcpy with structure assignment - Remove unneeded codes and use helper function i_blocksize() - Fix typos found by codespell * tag 'exfat-for-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat: exfat: remove useless check in exfat_move_file() exfat: remove 'rwoffset' in exfat_inode_info exfat: replace memcpy with structure assignment exfat: remove useless directory scan in exfat_add_entry() exfat: eliminate dead code in exfat_find() exfat: use i_blocksize() to get blocksize exfat: fix misspellings using codespell tool
This commit is contained in:
commit
9b06f57b9e
|
@ -59,9 +59,9 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read a directory entry from the opened directory */
|
/* read a directory entry from the opened directory */
|
||||||
static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
|
static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_entry *dir_entry)
|
||||||
{
|
{
|
||||||
int i, dentries_per_clu, dentries_per_clu_bits = 0;
|
int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext;
|
||||||
unsigned int type, clu_offset;
|
unsigned int type, clu_offset;
|
||||||
sector_t sector;
|
sector_t sector;
|
||||||
struct exfat_chain dir, clu;
|
struct exfat_chain dir, clu;
|
||||||
|
@ -70,7 +70,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
||||||
struct exfat_inode_info *ei = EXFAT_I(inode);
|
struct exfat_inode_info *ei = EXFAT_I(inode);
|
||||||
unsigned int dentry = ei->rwoffset & 0xFFFFFFFF;
|
unsigned int dentry = EXFAT_B_TO_DEN(*cpos) & 0xFFFFFFFF;
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
|
|
||||||
/* check if the given file ID is opened */
|
/* check if the given file ID is opened */
|
||||||
|
@ -127,6 +127,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
num_ext = ep->dentry.file.num_ext;
|
||||||
dir_entry->attr = le16_to_cpu(ep->dentry.file.attr);
|
dir_entry->attr = le16_to_cpu(ep->dentry.file.attr);
|
||||||
exfat_get_entry_time(sbi, &dir_entry->crtime,
|
exfat_get_entry_time(sbi, &dir_entry->crtime,
|
||||||
ep->dentry.file.create_tz,
|
ep->dentry.file.create_tz,
|
||||||
|
@ -157,12 +158,13 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
dir_entry->size =
|
dir_entry->size =
|
||||||
le64_to_cpu(ep->dentry.stream.valid_size);
|
le64_to_cpu(ep->dentry.stream.valid_size);
|
||||||
|
dir_entry->entry = dentry;
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
|
|
||||||
ei->hint_bmap.off = dentry >> dentries_per_clu_bits;
|
ei->hint_bmap.off = dentry >> dentries_per_clu_bits;
|
||||||
ei->hint_bmap.clu = clu.dir;
|
ei->hint_bmap.clu = clu.dir;
|
||||||
|
|
||||||
ei->rwoffset = ++dentry;
|
*cpos = EXFAT_DEN_TO_B(dentry + 1 + num_ext);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +180,7 @@ static int exfat_readdir(struct inode *inode, struct exfat_dir_entry *dir_entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_entry->namebuf.lfn[0] = '\0';
|
dir_entry->namebuf.lfn[0] = '\0';
|
||||||
ei->rwoffset = dentry;
|
*cpos = EXFAT_DEN_TO_B(dentry);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,12 +244,10 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx)
|
||||||
if (err)
|
if (err)
|
||||||
goto unlock;
|
goto unlock;
|
||||||
get_new:
|
get_new:
|
||||||
ei->rwoffset = EXFAT_B_TO_DEN(cpos);
|
|
||||||
|
|
||||||
if (cpos >= i_size_read(inode))
|
if (cpos >= i_size_read(inode))
|
||||||
goto end_of_dir;
|
goto end_of_dir;
|
||||||
|
|
||||||
err = exfat_readdir(inode, &de);
|
err = exfat_readdir(inode, &cpos, &de);
|
||||||
if (err) {
|
if (err) {
|
||||||
/*
|
/*
|
||||||
* At least we tried to read a sector. Move cpos to next sector
|
* At least we tried to read a sector. Move cpos to next sector
|
||||||
|
@ -262,13 +262,10 @@ get_new:
|
||||||
goto end_of_dir;
|
goto end_of_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpos = EXFAT_DEN_TO_B(ei->rwoffset);
|
|
||||||
|
|
||||||
if (!nb->lfn[0])
|
if (!nb->lfn[0])
|
||||||
goto end_of_dir;
|
goto end_of_dir;
|
||||||
|
|
||||||
i_pos = ((loff_t)ei->start_clu << 32) |
|
i_pos = ((loff_t)ei->start_clu << 32) | (de.entry & 0xffffffff);
|
||||||
((ei->rwoffset - 1) & 0xffffffff);
|
|
||||||
tmp = exfat_iget(sb, i_pos);
|
tmp = exfat_iget(sb, i_pos);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
inum = tmp->i_ino;
|
inum = tmp->i_ino;
|
||||||
|
@ -911,7 +908,6 @@ enum {
|
||||||
/*
|
/*
|
||||||
* return values:
|
* return values:
|
||||||
* >= 0 : return dir entiry position with the name in dir
|
* >= 0 : return dir entiry position with the name in dir
|
||||||
* -EEXIST : (root dir, ".") it is the root dir itself
|
|
||||||
* -ENOENT : entry with the name does not exist
|
* -ENOENT : entry with the name does not exist
|
||||||
* -EIO : I/O error
|
* -EIO : I/O error
|
||||||
*/
|
*/
|
||||||
|
@ -979,11 +975,8 @@ rewind:
|
||||||
if (ei->hint_femp.eidx ==
|
if (ei->hint_femp.eidx ==
|
||||||
EXFAT_HINT_NONE ||
|
EXFAT_HINT_NONE ||
|
||||||
candi_empty.eidx <=
|
candi_empty.eidx <=
|
||||||
ei->hint_femp.eidx) {
|
ei->hint_femp.eidx)
|
||||||
memcpy(&ei->hint_femp,
|
ei->hint_femp = candi_empty;
|
||||||
&candi_empty,
|
|
||||||
sizeof(candi_empty));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
|
|
|
@ -128,7 +128,7 @@ enum {
|
||||||
|
|
||||||
struct exfat_dentry_namebuf {
|
struct exfat_dentry_namebuf {
|
||||||
char *lfn;
|
char *lfn;
|
||||||
int lfnbuf_len; /* usally MAX_UNINAME_BUF_SIZE */
|
int lfnbuf_len; /* usually MAX_UNINAME_BUF_SIZE */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* unicode name structure */
|
/* unicode name structure */
|
||||||
|
@ -265,8 +265,6 @@ struct exfat_inode_info {
|
||||||
* the validation of hint_stat.
|
* the validation of hint_stat.
|
||||||
*/
|
*/
|
||||||
unsigned int version;
|
unsigned int version;
|
||||||
/* file offset or dentry index for readdir */
|
|
||||||
loff_t rwoffset;
|
|
||||||
|
|
||||||
/* hint for cluster last accessed */
|
/* hint for cluster last accessed */
|
||||||
struct exfat_hint hint_bmap;
|
struct exfat_hint hint_bmap;
|
||||||
|
|
|
@ -208,8 +208,6 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
|
||||||
/* hint information */
|
/* hint information */
|
||||||
ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
|
ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
|
||||||
ei->hint_bmap.clu = EXFAT_EOF_CLUSTER;
|
ei->hint_bmap.clu = EXFAT_EOF_CLUSTER;
|
||||||
if (ei->rwoffset > new_size)
|
|
||||||
ei->rwoffset = new_size;
|
|
||||||
|
|
||||||
/* hint_stat will be used if this is directory. */
|
/* hint_stat will be used if this is directory. */
|
||||||
ei->hint_stat.eidx = 0;
|
ei->hint_stat.eidx = 0;
|
||||||
|
@ -229,7 +227,7 @@ void exfat_truncate(struct inode *inode, loff_t size)
|
||||||
{
|
{
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
||||||
unsigned int blocksize = 1 << inode->i_blkbits;
|
unsigned int blocksize = i_blocksize(inode);
|
||||||
loff_t aligned_size;
|
loff_t aligned_size;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
|
||||||
unsigned int local_clu_offset = clu_offset;
|
unsigned int local_clu_offset = clu_offset;
|
||||||
unsigned int num_to_be_allocated = 0, num_clusters = 0;
|
unsigned int num_to_be_allocated = 0, num_clusters = 0;
|
||||||
|
|
||||||
ei->rwoffset = EXFAT_CLU_TO_B(clu_offset, sbi);
|
|
||||||
|
|
||||||
if (EXFAT_I(inode)->i_size_ondisk > 0)
|
if (EXFAT_I(inode)->i_size_ondisk > 0)
|
||||||
num_clusters =
|
num_clusters =
|
||||||
EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk,
|
EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk,
|
||||||
|
@ -556,7 +554,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
|
||||||
struct exfat_inode_info *ei = EXFAT_I(inode);
|
struct exfat_inode_info *ei = EXFAT_I(inode);
|
||||||
loff_t size = info->size;
|
loff_t size = info->size;
|
||||||
|
|
||||||
memcpy(&ei->dir, &info->dir, sizeof(struct exfat_chain));
|
ei->dir = info->dir;
|
||||||
ei->entry = info->entry;
|
ei->entry = info->entry;
|
||||||
ei->attr = info->attr;
|
ei->attr = info->attr;
|
||||||
ei->start_clu = info->start_clu;
|
ei->start_clu = info->start_clu;
|
||||||
|
@ -567,7 +565,6 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
|
||||||
ei->hint_stat.eidx = 0;
|
ei->hint_stat.eidx = 0;
|
||||||
ei->hint_stat.clu = info->start_clu;
|
ei->hint_stat.clu = info->start_clu;
|
||||||
ei->hint_femp.eidx = EXFAT_HINT_NONE;
|
ei->hint_femp.eidx = EXFAT_HINT_NONE;
|
||||||
ei->rwoffset = 0;
|
|
||||||
ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
|
ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
|
||||||
ei->i_pos = 0;
|
ei->i_pos = 0;
|
||||||
|
|
||||||
|
|
151
fs/exfat/namei.c
151
fs/exfat/namei.c
|
@ -290,7 +290,7 @@ static int exfat_check_max_dentries(struct inode *inode)
|
||||||
{
|
{
|
||||||
if (EXFAT_B_TO_DEN(i_size_read(inode)) >= MAX_EXFAT_DENTRIES) {
|
if (EXFAT_B_TO_DEN(i_size_read(inode)) >= MAX_EXFAT_DENTRIES) {
|
||||||
/*
|
/*
|
||||||
* exFAT spec allows a dir to grow upto 8388608(256MB)
|
* exFAT spec allows a dir to grow up to 8388608(256MB)
|
||||||
* dentries
|
* dentries
|
||||||
*/
|
*/
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
|
@ -318,8 +318,7 @@ static int exfat_find_empty_entry(struct inode *inode,
|
||||||
hint_femp.eidx = EXFAT_HINT_NONE;
|
hint_femp.eidx = EXFAT_HINT_NONE;
|
||||||
|
|
||||||
if (ei->hint_femp.eidx != EXFAT_HINT_NONE) {
|
if (ei->hint_femp.eidx != EXFAT_HINT_NONE) {
|
||||||
memcpy(&hint_femp, &ei->hint_femp,
|
hint_femp = ei->hint_femp;
|
||||||
sizeof(struct exfat_hint_femp));
|
|
||||||
ei->hint_femp.eidx = EXFAT_HINT_NONE;
|
ei->hint_femp.eidx = EXFAT_HINT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +518,7 @@ static int exfat_add_entry(struct inode *inode, const char *path,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
memcpy(&info->dir, p_dir, sizeof(struct exfat_chain));
|
info->dir = *p_dir;
|
||||||
info->entry = dentry;
|
info->entry = dentry;
|
||||||
info->flags = ALLOC_NO_FAT_CHAIN;
|
info->flags = ALLOC_NO_FAT_CHAIN;
|
||||||
info->type = type;
|
info->type = type;
|
||||||
|
@ -530,19 +529,10 @@ static int exfat_add_entry(struct inode *inode, const char *path,
|
||||||
info->size = 0;
|
info->size = 0;
|
||||||
info->num_subdirs = 0;
|
info->num_subdirs = 0;
|
||||||
} else {
|
} else {
|
||||||
int count;
|
|
||||||
struct exfat_chain cdir;
|
|
||||||
|
|
||||||
info->attr = ATTR_SUBDIR;
|
info->attr = ATTR_SUBDIR;
|
||||||
info->start_clu = start_clu;
|
info->start_clu = start_clu;
|
||||||
info->size = clu_size;
|
info->size = clu_size;
|
||||||
|
info->num_subdirs = EXFAT_MIN_SUBDIR;
|
||||||
exfat_chain_set(&cdir, info->start_clu,
|
|
||||||
EXFAT_B_TO_CLU(info->size, sbi), info->flags);
|
|
||||||
count = exfat_count_dir_entries(sb, &cdir);
|
|
||||||
if (count < 0)
|
|
||||||
return -EIO;
|
|
||||||
info->num_subdirs = count + EXFAT_MIN_SUBDIR;
|
|
||||||
}
|
}
|
||||||
memset(&info->crtime, 0, sizeof(info->crtime));
|
memset(&info->crtime, 0, sizeof(info->crtime));
|
||||||
memset(&info->mtime, 0, sizeof(info->mtime));
|
memset(&info->mtime, 0, sizeof(info->mtime));
|
||||||
|
@ -604,6 +594,8 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
|
||||||
struct super_block *sb = dir->i_sb;
|
struct super_block *sb = dir->i_sb;
|
||||||
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
||||||
struct exfat_inode_info *ei = EXFAT_I(dir);
|
struct exfat_inode_info *ei = EXFAT_I(dir);
|
||||||
|
struct exfat_dentry *ep, *ep2;
|
||||||
|
struct exfat_entry_set_cache *es;
|
||||||
|
|
||||||
if (qname->len == 0)
|
if (qname->len == 0)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -629,91 +621,63 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
|
||||||
dentry = exfat_find_dir_entry(sb, ei, &cdir, &uni_name,
|
dentry = exfat_find_dir_entry(sb, ei, &cdir, &uni_name,
|
||||||
num_entries, TYPE_ALL);
|
num_entries, TYPE_ALL);
|
||||||
|
|
||||||
if ((dentry < 0) && (dentry != -EEXIST))
|
if (dentry < 0)
|
||||||
return dentry; /* -error value */
|
return dentry; /* -error value */
|
||||||
|
|
||||||
memcpy(&info->dir, &cdir.dir, sizeof(struct exfat_chain));
|
info->dir = cdir;
|
||||||
info->entry = dentry;
|
info->entry = dentry;
|
||||||
info->num_subdirs = 0;
|
info->num_subdirs = 0;
|
||||||
|
|
||||||
/* root directory itself */
|
es = exfat_get_dentry_set(sb, &cdir, dentry, ES_2_ENTRIES);
|
||||||
if (unlikely(dentry == -EEXIST)) {
|
if (!es)
|
||||||
int num_clu = 0;
|
return -EIO;
|
||||||
|
ep = exfat_get_dentry_cached(es, 0);
|
||||||
|
ep2 = exfat_get_dentry_cached(es, 1);
|
||||||
|
|
||||||
info->type = TYPE_DIR;
|
info->type = exfat_get_entry_type(ep);
|
||||||
info->attr = ATTR_SUBDIR;
|
info->attr = le16_to_cpu(ep->dentry.file.attr);
|
||||||
info->flags = ALLOC_FAT_CHAIN;
|
info->size = le64_to_cpu(ep2->dentry.stream.valid_size);
|
||||||
info->start_clu = sbi->root_dir;
|
if ((info->type == TYPE_FILE) && (info->size == 0)) {
|
||||||
memset(&info->crtime, 0, sizeof(info->crtime));
|
info->flags = ALLOC_NO_FAT_CHAIN;
|
||||||
memset(&info->mtime, 0, sizeof(info->mtime));
|
info->start_clu = EXFAT_EOF_CLUSTER;
|
||||||
memset(&info->atime, 0, sizeof(info->atime));
|
} else {
|
||||||
|
info->flags = ep2->dentry.stream.flags;
|
||||||
|
info->start_clu =
|
||||||
|
le32_to_cpu(ep2->dentry.stream.start_clu);
|
||||||
|
}
|
||||||
|
|
||||||
exfat_chain_set(&cdir, sbi->root_dir, 0, ALLOC_FAT_CHAIN);
|
exfat_get_entry_time(sbi, &info->crtime,
|
||||||
if (exfat_count_num_clusters(sb, &cdir, &num_clu))
|
ep->dentry.file.create_tz,
|
||||||
return -EIO;
|
ep->dentry.file.create_time,
|
||||||
info->size = num_clu << sbi->cluster_size_bits;
|
ep->dentry.file.create_date,
|
||||||
|
ep->dentry.file.create_time_cs);
|
||||||
|
exfat_get_entry_time(sbi, &info->mtime,
|
||||||
|
ep->dentry.file.modify_tz,
|
||||||
|
ep->dentry.file.modify_time,
|
||||||
|
ep->dentry.file.modify_date,
|
||||||
|
ep->dentry.file.modify_time_cs);
|
||||||
|
exfat_get_entry_time(sbi, &info->atime,
|
||||||
|
ep->dentry.file.access_tz,
|
||||||
|
ep->dentry.file.access_time,
|
||||||
|
ep->dentry.file.access_date,
|
||||||
|
0);
|
||||||
|
exfat_free_dentry_set(es, false);
|
||||||
|
|
||||||
|
if (ei->start_clu == EXFAT_FREE_CLUSTER) {
|
||||||
|
exfat_fs_error(sb,
|
||||||
|
"non-zero size file starts with zero cluster (size : %llu, p_dir : %u, entry : 0x%08x)",
|
||||||
|
i_size_read(dir), ei->dir.dir, ei->entry);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->type == TYPE_DIR) {
|
||||||
|
exfat_chain_set(&cdir, info->start_clu,
|
||||||
|
EXFAT_B_TO_CLU(info->size, sbi), info->flags);
|
||||||
count = exfat_count_dir_entries(sb, &cdir);
|
count = exfat_count_dir_entries(sb, &cdir);
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
info->num_subdirs = count;
|
info->num_subdirs = count + EXFAT_MIN_SUBDIR;
|
||||||
} else {
|
|
||||||
struct exfat_dentry *ep, *ep2;
|
|
||||||
struct exfat_entry_set_cache *es;
|
|
||||||
|
|
||||||
es = exfat_get_dentry_set(sb, &cdir, dentry, ES_2_ENTRIES);
|
|
||||||
if (!es)
|
|
||||||
return -EIO;
|
|
||||||
ep = exfat_get_dentry_cached(es, 0);
|
|
||||||
ep2 = exfat_get_dentry_cached(es, 1);
|
|
||||||
|
|
||||||
info->type = exfat_get_entry_type(ep);
|
|
||||||
info->attr = le16_to_cpu(ep->dentry.file.attr);
|
|
||||||
info->size = le64_to_cpu(ep2->dentry.stream.valid_size);
|
|
||||||
if ((info->type == TYPE_FILE) && (info->size == 0)) {
|
|
||||||
info->flags = ALLOC_NO_FAT_CHAIN;
|
|
||||||
info->start_clu = EXFAT_EOF_CLUSTER;
|
|
||||||
} else {
|
|
||||||
info->flags = ep2->dentry.stream.flags;
|
|
||||||
info->start_clu =
|
|
||||||
le32_to_cpu(ep2->dentry.stream.start_clu);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ei->start_clu == EXFAT_FREE_CLUSTER) {
|
|
||||||
exfat_fs_error(sb,
|
|
||||||
"non-zero size file starts with zero cluster (size : %llu, p_dir : %u, entry : 0x%08x)",
|
|
||||||
i_size_read(dir), ei->dir.dir, ei->entry);
|
|
||||||
exfat_free_dentry_set(es, false);
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
exfat_get_entry_time(sbi, &info->crtime,
|
|
||||||
ep->dentry.file.create_tz,
|
|
||||||
ep->dentry.file.create_time,
|
|
||||||
ep->dentry.file.create_date,
|
|
||||||
ep->dentry.file.create_time_cs);
|
|
||||||
exfat_get_entry_time(sbi, &info->mtime,
|
|
||||||
ep->dentry.file.modify_tz,
|
|
||||||
ep->dentry.file.modify_time,
|
|
||||||
ep->dentry.file.modify_date,
|
|
||||||
ep->dentry.file.modify_time_cs);
|
|
||||||
exfat_get_entry_time(sbi, &info->atime,
|
|
||||||
ep->dentry.file.access_tz,
|
|
||||||
ep->dentry.file.access_time,
|
|
||||||
ep->dentry.file.access_date,
|
|
||||||
0);
|
|
||||||
exfat_free_dentry_set(es, false);
|
|
||||||
|
|
||||||
if (info->type == TYPE_DIR) {
|
|
||||||
exfat_chain_set(&cdir, info->start_clu,
|
|
||||||
EXFAT_B_TO_CLU(info->size, sbi), info->flags);
|
|
||||||
count = exfat_count_dir_entries(sb, &cdir);
|
|
||||||
if (count < 0)
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
info->num_subdirs = count + EXFAT_MIN_SUBDIR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1029,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
|
||||||
if (!epnew)
|
if (!epnew)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
memcpy(epnew, epold, DENTRY_SIZE);
|
*epnew = *epold;
|
||||||
if (exfat_get_entry_type(epnew) == TYPE_FILE) {
|
if (exfat_get_entry_type(epnew) == TYPE_FILE) {
|
||||||
epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE);
|
epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE);
|
||||||
ei->attr |= ATTR_ARCHIVE;
|
ei->attr |= ATTR_ARCHIVE;
|
||||||
|
@ -1085,7 +1049,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(epnew, epold, DENTRY_SIZE);
|
*epnew = *epold;
|
||||||
exfat_update_bh(new_bh, sync);
|
exfat_update_bh(new_bh, sync);
|
||||||
brelse(old_bh);
|
brelse(old_bh);
|
||||||
brelse(new_bh);
|
brelse(new_bh);
|
||||||
|
@ -1130,11 +1094,6 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
|
||||||
if (!epmov)
|
if (!epmov)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
/* check if the source and target directory is the same */
|
|
||||||
if (exfat_get_entry_type(epmov) == TYPE_DIR &&
|
|
||||||
le32_to_cpu(epmov->dentry.stream.start_clu) == p_newdir->dir)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
num_old_entries = exfat_count_ext_entries(sb, p_olddir, oldentry,
|
num_old_entries = exfat_count_ext_entries(sb, p_olddir, oldentry,
|
||||||
epmov);
|
epmov);
|
||||||
if (num_old_entries < 0)
|
if (num_old_entries < 0)
|
||||||
|
@ -1153,7 +1112,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
|
||||||
if (!epnew)
|
if (!epnew)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
memcpy(epnew, epmov, DENTRY_SIZE);
|
*epnew = *epmov;
|
||||||
if (exfat_get_entry_type(epnew) == TYPE_FILE) {
|
if (exfat_get_entry_type(epnew) == TYPE_FILE) {
|
||||||
epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE);
|
epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE);
|
||||||
ei->attr |= ATTR_ARCHIVE;
|
ei->attr |= ATTR_ARCHIVE;
|
||||||
|
@ -1173,7 +1132,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(epnew, epmov, DENTRY_SIZE);
|
*epnew = *epmov;
|
||||||
exfat_update_bh(new_bh, IS_DIRSYNC(inode));
|
exfat_update_bh(new_bh, IS_DIRSYNC(inode));
|
||||||
brelse(mov_bh);
|
brelse(mov_bh);
|
||||||
brelse(new_bh);
|
brelse(new_bh);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "exfat_raw.h"
|
#include "exfat_raw.h"
|
||||||
#include "exfat_fs.h"
|
#include "exfat_fs.h"
|
||||||
|
|
||||||
/* Upcase tabel macro */
|
/* Upcase table macro */
|
||||||
#define EXFAT_NUM_UPCASE (2918)
|
#define EXFAT_NUM_UPCASE (2918)
|
||||||
#define UTBL_COUNT (0x10000)
|
#define UTBL_COUNT (0x10000)
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,6 @@ static int exfat_read_root(struct inode *inode)
|
||||||
ei->flags = ALLOC_FAT_CHAIN;
|
ei->flags = ALLOC_FAT_CHAIN;
|
||||||
ei->type = TYPE_DIR;
|
ei->type = TYPE_DIR;
|
||||||
ei->version = 0;
|
ei->version = 0;
|
||||||
ei->rwoffset = 0;
|
|
||||||
ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
|
ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
|
||||||
ei->hint_stat.eidx = 0;
|
ei->hint_stat.eidx = 0;
|
||||||
ei->hint_stat.clu = sbi->root_dir;
|
ei->hint_stat.clu = sbi->root_dir;
|
||||||
|
|
Loading…
Reference in New Issue