|
Kmods SIG |
9e3ffb |
From 188df41f212c9282f6cb05b832383ffca3c66893 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
9e3ffb |
From: Tetsuhiro Kohada <kohada.t2@gmail.com>
|
|
Kmods SIG |
9e3ffb |
Date: Wed, 2 Sep 2020 16:53:06 +0900
|
|
Kmods SIG |
9e3ffb |
Subject: [Backport 188df41f212c] exfat: eliminate dead code in exfat_find()
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
The exfat_find_dir_entry() called by exfat_find() doesn't return -EEXIST.
|
|
Kmods SIG |
9e3ffb |
Therefore, the root-dir information setting is never executed.
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com>
|
|
Kmods SIG |
9e3ffb |
Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
|
|
Kmods SIG |
9e3ffb |
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
|
|
Kmods SIG |
9e3ffb |
---
|
|
Kmods SIG |
9e3ffb |
src/dir.c | 1 -
|
|
Kmods SIG |
9e3ffb |
src/namei.c | 120 +++++++++++++++++++----------------------------
|
|
Kmods SIG |
9e3ffb |
2 files changed, 47 insertions(+), 74 deletions(-)
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
diff --git a/src/dir.c b/src/dir.c
|
|
Kmods SIG |
9e3ffb |
index 573659bfbc5542f20d1181e95ef292f341aab0d6..a9b13ae3f325fcbf628657981055b91b5079d5f6 100644
|
|
Kmods SIG |
9e3ffb |
--- a/src/dir.c
|
|
Kmods SIG |
9e3ffb |
+++ b/src/dir.c
|
|
Kmods SIG |
9e3ffb |
@@ -911,7 +911,6 @@ enum {
|
|
Kmods SIG |
9e3ffb |
/*
|
|
Kmods SIG |
9e3ffb |
* return values:
|
|
Kmods SIG |
9e3ffb |
* >= 0 : return dir entiry position with the name in dir
|
|
Kmods SIG |
9e3ffb |
- * -EEXIST : (root dir, ".") it is the root dir itself
|
|
Kmods SIG |
9e3ffb |
* -ENOENT : entry with the name does not exist
|
|
Kmods SIG |
9e3ffb |
* -EIO : I/O error
|
|
Kmods SIG |
9e3ffb |
*/
|
|
Kmods SIG |
9e3ffb |
diff --git a/src/namei.c b/src/namei.c
|
|
Kmods SIG |
9e3ffb |
index 0b12033e15777966a05bdec5492eacd86b262e11..b966b9120c9ca25e8519b05bdacc5e17ced0f9da 100644
|
|
Kmods SIG |
9e3ffb |
--- a/src/namei.c
|
|
Kmods SIG |
9e3ffb |
+++ b/src/namei.c
|
|
Kmods SIG |
9e3ffb |
@@ -604,6 +604,8 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
|
|
Kmods SIG |
9e3ffb |
struct super_block *sb = dir->i_sb;
|
|
Kmods SIG |
9e3ffb |
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
|
Kmods SIG |
9e3ffb |
struct exfat_inode_info *ei = EXFAT_I(dir);
|
|
Kmods SIG |
9e3ffb |
+ struct exfat_dentry *ep, *ep2;
|
|
Kmods SIG |
9e3ffb |
+ struct exfat_entry_set_cache *es;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
if (qname->len == 0)
|
|
Kmods SIG |
9e3ffb |
return -ENOENT;
|
|
Kmods SIG |
9e3ffb |
@@ -629,91 +631,63 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
|
|
Kmods SIG |
9e3ffb |
dentry = exfat_find_dir_entry(sb, ei, &cdir, &uni_name,
|
|
Kmods SIG |
9e3ffb |
num_entries, TYPE_ALL);
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
- if ((dentry < 0) && (dentry != -EEXIST))
|
|
Kmods SIG |
9e3ffb |
+ if (dentry < 0)
|
|
Kmods SIG |
9e3ffb |
return dentry; /* -error value */
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
memcpy(&info->dir, &cdir.dir, sizeof(struct exfat_chain));
|
|
Kmods SIG |
9e3ffb |
info->entry = dentry;
|
|
Kmods SIG |
9e3ffb |
info->num_subdirs = 0;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
- /* root directory itself */
|
|
Kmods SIG |
9e3ffb |
- if (unlikely(dentry == -EEXIST)) {
|
|
Kmods SIG |
9e3ffb |
- int num_clu = 0;
|
|
Kmods SIG |
9e3ffb |
+ es = exfat_get_dentry_set(sb, &cdir, dentry, ES_2_ENTRIES);
|
|
Kmods SIG |
9e3ffb |
+ if (!es)
|
|
Kmods SIG |
9e3ffb |
+ return -EIO;
|
|
Kmods SIG |
9e3ffb |
+ ep = exfat_get_dentry_cached(es, 0);
|
|
Kmods SIG |
9e3ffb |
+ ep2 = exfat_get_dentry_cached(es, 1);
|
|
Kmods SIG |
9e3ffb |
+
|
|
Kmods SIG |
9e3ffb |
+ info->type = exfat_get_entry_type(ep);
|
|
Kmods SIG |
9e3ffb |
+ info->attr = le16_to_cpu(ep->dentry.file.attr);
|
|
Kmods SIG |
9e3ffb |
+ info->size = le64_to_cpu(ep2->dentry.stream.valid_size);
|
|
Kmods SIG |
9e3ffb |
+ if ((info->type == TYPE_FILE) && (info->size == 0)) {
|
|
Kmods SIG |
9e3ffb |
+ info->flags = ALLOC_NO_FAT_CHAIN;
|
|
Kmods SIG |
9e3ffb |
+ info->start_clu = EXFAT_EOF_CLUSTER;
|
|
Kmods SIG |
9e3ffb |
+ } else {
|
|
Kmods SIG |
9e3ffb |
+ info->flags = ep2->dentry.stream.flags;
|
|
Kmods SIG |
9e3ffb |
+ info->start_clu =
|
|
Kmods SIG |
9e3ffb |
+ le32_to_cpu(ep2->dentry.stream.start_clu);
|
|
Kmods SIG |
9e3ffb |
+ }
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
- info->type = TYPE_DIR;
|
|
Kmods SIG |
9e3ffb |
- info->attr = ATTR_SUBDIR;
|
|
Kmods SIG |
9e3ffb |
- info->flags = ALLOC_FAT_CHAIN;
|
|
Kmods SIG |
9e3ffb |
- info->start_clu = sbi->root_dir;
|
|
Kmods SIG |
9e3ffb |
- memset(&info->crtime, 0, sizeof(info->crtime));
|
|
Kmods SIG |
9e3ffb |
- memset(&info->mtime, 0, sizeof(info->mtime));
|
|
Kmods SIG |
9e3ffb |
- memset(&info->atime, 0, sizeof(info->atime));
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
- exfat_chain_set(&cdir, sbi->root_dir, 0, ALLOC_FAT_CHAIN);
|
|
Kmods SIG |
9e3ffb |
- if (exfat_count_num_clusters(sb, &cdir, &num_clu))
|
|
Kmods SIG |
9e3ffb |
- return -EIO;
|
|
Kmods SIG |
9e3ffb |
- info->size = num_clu << sbi->cluster_size_bits;
|
|
Kmods SIG |
9e3ffb |
+ exfat_get_entry_time(sbi, &info->crtime,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.create_tz,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.create_time,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.create_date,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.create_time_cs);
|
|
Kmods SIG |
9e3ffb |
+ exfat_get_entry_time(sbi, &info->mtime,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.modify_tz,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.modify_time,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.modify_date,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.modify_time_cs);
|
|
Kmods SIG |
9e3ffb |
+ exfat_get_entry_time(sbi, &info->atime,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.access_tz,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.access_time,
|
|
Kmods SIG |
9e3ffb |
+ ep->dentry.file.access_date,
|
|
Kmods SIG |
9e3ffb |
+ 0);
|
|
Kmods SIG |
9e3ffb |
+ exfat_free_dentry_set(es, false);
|
|
Kmods SIG |
9e3ffb |
+
|
|
Kmods SIG |
9e3ffb |
+ if (ei->start_clu == EXFAT_FREE_CLUSTER) {
|
|
Kmods SIG |
9e3ffb |
+ exfat_fs_error(sb,
|
|
Kmods SIG |
9e3ffb |
+ "non-zero size file starts with zero cluster (size : %llu, p_dir : %u, entry : 0x%08x)",
|
|
Kmods SIG |
9e3ffb |
+ i_size_read(dir), ei->dir.dir, ei->entry);
|
|
Kmods SIG |
9e3ffb |
+ return -EIO;
|
|
Kmods SIG |
9e3ffb |
+ }
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
+ if (info->type == TYPE_DIR) {
|
|
Kmods SIG |
9e3ffb |
+ exfat_chain_set(&cdir, info->start_clu,
|
|
Kmods SIG |
9e3ffb |
+ EXFAT_B_TO_CLU(info->size, sbi), info->flags);
|
|
Kmods SIG |
9e3ffb |
count = exfat_count_dir_entries(sb, &cdir);
|
|
Kmods SIG |
9e3ffb |
if (count < 0)
|
|
Kmods SIG |
9e3ffb |
return -EIO;
|
|
Kmods SIG |
9e3ffb |
|
|
Kmods SIG |
9e3ffb |
- info->num_subdirs = count;
|
|
Kmods SIG |
9e3ffb |
- } else {
|
|
Kmods SIG |
9e3ffb |
- struct exfat_dentry *ep, *ep2;
|
|
Kmods SIG |
9e3ffb |
- struct exfat_entry_set_cache *es;
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
- es = exfat_get_dentry_set(sb, &cdir, dentry, ES_2_ENTRIES);
|
|
Kmods SIG |
9e3ffb |
- if (!es)
|
|
Kmods SIG |
9e3ffb |
- return -EIO;
|
|
Kmods SIG |
9e3ffb |
- ep = exfat_get_dentry_cached(es, 0);
|
|
Kmods SIG |
9e3ffb |
- ep2 = exfat_get_dentry_cached(es, 1);
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
- info->type = exfat_get_entry_type(ep);
|
|
Kmods SIG |
9e3ffb |
- info->attr = le16_to_cpu(ep->dentry.file.attr);
|
|
Kmods SIG |
9e3ffb |
- info->size = le64_to_cpu(ep2->dentry.stream.valid_size);
|
|
Kmods SIG |
9e3ffb |
- if ((info->type == TYPE_FILE) && (info->size == 0)) {
|
|
Kmods SIG |
9e3ffb |
- info->flags = ALLOC_NO_FAT_CHAIN;
|
|
Kmods SIG |
9e3ffb |
- info->start_clu = EXFAT_EOF_CLUSTER;
|
|
Kmods SIG |
9e3ffb |
- } else {
|
|
Kmods SIG |
9e3ffb |
- info->flags = ep2->dentry.stream.flags;
|
|
Kmods SIG |
9e3ffb |
- info->start_clu =
|
|
Kmods SIG |
9e3ffb |
- le32_to_cpu(ep2->dentry.stream.start_clu);
|
|
Kmods SIG |
9e3ffb |
- }
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
- if (ei->start_clu == EXFAT_FREE_CLUSTER) {
|
|
Kmods SIG |
9e3ffb |
- exfat_fs_error(sb,
|
|
Kmods SIG |
9e3ffb |
- "non-zero size file starts with zero cluster (size : %llu, p_dir : %u, entry : 0x%08x)",
|
|
Kmods SIG |
9e3ffb |
- i_size_read(dir), ei->dir.dir, ei->entry);
|
|
Kmods SIG |
9e3ffb |
- exfat_free_dentry_set(es, false);
|
|
Kmods SIG |
9e3ffb |
- return -EIO;
|
|
Kmods SIG |
9e3ffb |
- }
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
- exfat_get_entry_time(sbi, &info->crtime,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.create_tz,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.create_time,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.create_date,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.create_time_cs);
|
|
Kmods SIG |
9e3ffb |
- exfat_get_entry_time(sbi, &info->mtime,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.modify_tz,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.modify_time,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.modify_date,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.modify_time_cs);
|
|
Kmods SIG |
9e3ffb |
- exfat_get_entry_time(sbi, &info->atime,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.access_tz,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.access_time,
|
|
Kmods SIG |
9e3ffb |
- ep->dentry.file.access_date,
|
|
Kmods SIG |
9e3ffb |
- 0);
|
|
Kmods SIG |
9e3ffb |
- exfat_free_dentry_set(es, false);
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
- if (info->type == TYPE_DIR) {
|
|
Kmods SIG |
9e3ffb |
- exfat_chain_set(&cdir, info->start_clu,
|
|
Kmods SIG |
9e3ffb |
- EXFAT_B_TO_CLU(info->size, sbi), info->flags);
|
|
Kmods SIG |
9e3ffb |
- count = exfat_count_dir_entries(sb, &cdir);
|
|
Kmods SIG |
9e3ffb |
- if (count < 0)
|
|
Kmods SIG |
9e3ffb |
- return -EIO;
|
|
Kmods SIG |
9e3ffb |
-
|
|
Kmods SIG |
9e3ffb |
- info->num_subdirs = count + EXFAT_MIN_SUBDIR;
|
|
Kmods SIG |
9e3ffb |
- }
|
|
Kmods SIG |
9e3ffb |
+ info->num_subdirs = count + EXFAT_MIN_SUBDIR;
|
|
Kmods SIG |
9e3ffb |
}
|
|
Kmods SIG |
9e3ffb |
return 0;
|
|
Kmods SIG |
9e3ffb |
}
|
|
Kmods SIG |
9e3ffb |
--
|
|
Kmods SIG |
9e3ffb |
2.31.1
|
|
Kmods SIG |
9e3ffb |
|