Commit 188df41f authored by Tetsuhiro Kohada's avatar Tetsuhiro Kohada Committed by Namjae Jeon

exfat: eliminate dead code in exfat_find()

The exfat_find_dir_entry() called by exfat_find() doesn't return -EEXIST.
Therefore, the root-dir information setting is never executed.
Signed-off-by: default avatarTetsuhiro Kohada <kohada.t2@gmail.com>
Acked-by: default avatarSungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
parent 45882a6a
...@@ -911,7 +911,6 @@ enum { ...@@ -911,7 +911,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
*/ */
......
...@@ -604,6 +604,8 @@ static int exfat_find(struct inode *dir, struct qstr *qname, ...@@ -604,6 +604,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 +631,63 @@ static int exfat_find(struct inode *dir, struct qstr *qname, ...@@ -629,91 +631,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)); memcpy(&info->dir, &cdir.dir, sizeof(struct exfat_chain));
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 = 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);
}
info->type = TYPE_DIR; exfat_get_entry_time(sbi, &info->crtime,
info->attr = ATTR_SUBDIR; ep->dentry.file.create_tz,
info->flags = ALLOC_FAT_CHAIN; ep->dentry.file.create_time,
info->start_clu = sbi->root_dir; ep->dentry.file.create_date,
memset(&info->crtime, 0, sizeof(info->crtime)); ep->dentry.file.create_time_cs);
memset(&info->mtime, 0, sizeof(info->mtime)); exfat_get_entry_time(sbi, &info->mtime,
memset(&info->atime, 0, sizeof(info->atime)); ep->dentry.file.modify_tz,
ep->dentry.file.modify_time,
exfat_chain_set(&cdir, sbi->root_dir, 0, ALLOC_FAT_CHAIN); ep->dentry.file.modify_date,
if (exfat_count_num_clusters(sb, &cdir, &num_clu)) ep->dentry.file.modify_time_cs);
return -EIO; exfat_get_entry_time(sbi, &info->atime,
info->size = num_clu << sbi->cluster_size_bits; 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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment