Commit 7ed674e2 authored by Tetsuhiro Kohada's avatar Tetsuhiro Kohada Committed by Greg Kroah-Hartman

staging: exfat: remove 'vol_type' variable.

remove 'vol_type' variable.

The following issues are described in exfat's TODO.
> clean up the remaining vol_type checks, which are of two types:
> some are ?: operators with magic numbers, and the rest are places
> where we're doing stuff with '.' and '..'.

The vol_type variable is always set to 'EXFAT'.
The variable checks are unnessesary, so remove unused code.
Signed-off-by: default avatarTetsuhiro Kohada <Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jp>
Reviewed-by: default avatarMori Takahiro <Mori.Takahiro@ab.MitsubishiElectric.co.jp>
Suggested-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200130070614.11999-1-Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jpSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 034280e3
...@@ -518,7 +518,6 @@ struct buf_cache_t { ...@@ -518,7 +518,6 @@ struct buf_cache_t {
struct fs_info_t { struct fs_info_t {
u32 drv; /* drive ID */ u32 drv; /* drive ID */
u32 vol_type; /* volume FAT type */
u32 vol_id; /* volume serial number */ u32 vol_id; /* volume serial number */
u64 num_sectors; /* num of sectors in volume */ u64 num_sectors; /* num of sectors in volume */
......
...@@ -1560,11 +1560,7 @@ static s32 search_deleted_or_unused_entry(struct super_block *sb, ...@@ -1560,11 +1560,7 @@ static s32 search_deleted_or_unused_entry(struct super_block *sb,
if (num_empty >= num_entries) { if (num_empty >= num_entries) {
p_fs->hint_uentry.dir = CLUSTER_32(~0); p_fs->hint_uentry.dir = CLUSTER_32(~0);
p_fs->hint_uentry.entry = -1; p_fs->hint_uentry.entry = -1;
return dentry - (num_entries - 1);
if (p_fs->vol_type == EXFAT)
return dentry - (num_entries - 1);
else
return dentry;
} }
} }
...@@ -1914,7 +1910,7 @@ s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, ...@@ -1914,7 +1910,7 @@ s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir,
bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir) bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir)
{ {
int i, count = 0; int i;
s32 dentries_per_clu; s32 dentries_per_clu;
u32 type; u32 type;
struct chain_t clu; struct chain_t clu;
...@@ -1943,15 +1939,7 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir) ...@@ -1943,15 +1939,7 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir)
if (type == TYPE_UNUSED) if (type == TYPE_UNUSED)
return true; return true;
if ((type != TYPE_FILE) && (type != TYPE_DIR)) if ((type == TYPE_FILE) || (type == TYPE_DIR))
continue;
if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */
return false;
if (p_fs->vol_type == EXFAT)
return false;
if ((p_dir->dir == p_fs->root_dir) || ((++count) > 2))
return false; return false;
} }
...@@ -2128,7 +2116,6 @@ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) ...@@ -2128,7 +2116,6 @@ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr)
p_fs->num_clusters = GET32(p_bpb->clu_count) + 2; p_fs->num_clusters = GET32(p_bpb->clu_count) + 2;
/* because the cluster index starts with 2 */ /* because the cluster index starts with 2 */
p_fs->vol_type = EXFAT;
p_fs->vol_id = GET32(p_bpb->vol_serial); p_fs->vol_id = GET32(p_bpb->vol_serial);
p_fs->root_dir = GET32(p_bpb->root_cluster); p_fs->root_dir = GET32(p_bpb->root_cluster);
...@@ -2165,7 +2152,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, ...@@ -2165,7 +2152,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
clu.dir = CLUSTER_32(~0); clu.dir = CLUSTER_32(~0);
clu.size = 0; clu.size = 0;
clu.flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; clu.flags = 0x03;
/* (1) allocate a cluster */ /* (1) allocate a cluster */
ret = exfat_alloc_cluster(sb, 1, &clu); ret = exfat_alloc_cluster(sb, 1, &clu);
...@@ -2198,7 +2185,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, ...@@ -2198,7 +2185,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
fid->entry = dentry; fid->entry = dentry;
fid->attr = ATTR_SUBDIR; fid->attr = ATTR_SUBDIR;
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = 0x03;
fid->size = size; fid->size = size;
fid->start_clu = clu.dir; fid->start_clu = clu.dir;
...@@ -2215,7 +2202,6 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir, ...@@ -2215,7 +2202,6 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir,
s32 ret, dentry, num_entries; s32 ret, dentry, num_entries;
struct dos_name_t dos_name; struct dos_name_t dos_name;
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
ret = get_num_entries_and_dos_name(sb, p_dir, p_uniname, &num_entries, ret = get_num_entries_and_dos_name(sb, p_dir, p_uniname, &num_entries,
&dos_name); &dos_name);
...@@ -2247,7 +2233,7 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir, ...@@ -2247,7 +2233,7 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir,
fid->entry = dentry; fid->entry = dentry;
fid->attr = ATTR_ARCHIVE | mode; fid->attr = ATTR_ARCHIVE | mode;
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = 0x03;
fid->size = 0; fid->size = 0;
fid->start_clu = CLUSTER_32(~0); fid->start_clu = CLUSTER_32(~0);
......
...@@ -494,7 +494,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info) ...@@ -494,7 +494,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info)
if (p_fs->used_clusters == UINT_MAX) if (p_fs->used_clusters == UINT_MAX)
p_fs->used_clusters = exfat_count_used_clusters(sb); p_fs->used_clusters = exfat_count_used_clusters(sb);
info->FatType = p_fs->vol_type; info->FatType = EXFAT;
info->ClusterSize = p_fs->cluster_size; info->ClusterSize = p_fs->cluster_size;
info->NumClusters = p_fs->num_clusters - 2; /* clu 0 & 1 */ info->NumClusters = p_fs->num_clusters - 2; /* clu 0 & 1 */
info->UsedClusters = p_fs->used_clusters; info->UsedClusters = p_fs->used_clusters;
...@@ -602,7 +602,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) ...@@ -602,7 +602,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid)
fid->size = exfat_get_entry_size(ep2); fid->size = exfat_get_entry_size(ep2);
if ((fid->type == TYPE_FILE) && (fid->size == 0)) { if ((fid->type == TYPE_FILE) && (fid->size == 0)) {
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = 0x03;
fid->start_clu = CLUSTER_32(~0); fid->start_clu = CLUSTER_32(~0);
} else { } else {
fid->flags = exfat_get_entry_flag(ep2); fid->flags = exfat_get_entry_flag(ep2);
...@@ -1095,7 +1095,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) ...@@ -1095,7 +1095,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
fid->size = new_size; fid->size = new_size;
fid->attr |= ATTR_ARCHIVE; fid->attr |= ATTR_ARCHIVE;
if (new_size == 0) { if (new_size == 0) {
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = 0x03;
fid->start_clu = CLUSTER_32(~0); fid->start_clu = CLUSTER_32(~0);
} }
...@@ -1203,14 +1203,6 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, ...@@ -1203,14 +1203,6 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
dentry = fid->entry; dentry = fid->entry;
/* check if the old file is "." or ".." */
if (p_fs->vol_type != EXFAT) {
if ((olddir.dir != p_fs->root_dir) && (dentry < 2)) {
ret = -EPERM;
goto out2;
}
}
ep = get_entry_in_dir(sb, &olddir, dentry, NULL); ep = get_entry_in_dir(sb, &olddir, dentry, NULL);
if (!ep) { if (!ep) {
ret = -ENOENT; ret = -ENOENT;
...@@ -1342,7 +1334,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) ...@@ -1342,7 +1334,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
fid->size = 0; fid->size = 0;
fid->start_clu = CLUSTER_32(~0); fid->start_clu = CLUSTER_32(~0);
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = 0x03;
#ifndef CONFIG_STAGING_EXFAT_DELAYED_SYNC #ifndef CONFIG_STAGING_EXFAT_DELAYED_SYNC
fs_sync(sb, true); fs_sync(sb, true);
...@@ -2020,12 +2012,6 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) ...@@ -2020,12 +2012,6 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
dentry = fid->entry; dentry = fid->entry;
/* check if the file is "." or ".." */
if (p_fs->vol_type != EXFAT) {
if ((dir.dir != p_fs->root_dir) && (dentry < 2))
return -EPERM;
}
/* acquire the lock for file system critical section */ /* acquire the lock for file system critical section */
mutex_lock(&p_fs->v_mutex); mutex_lock(&p_fs->v_mutex);
...@@ -2048,7 +2034,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) ...@@ -2048,7 +2034,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
fid->size = 0; fid->size = 0;
fid->start_clu = CLUSTER_32(~0); fid->start_clu = CLUSTER_32(~0);
fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; fid->flags = 0x03;
#ifndef CONFIG_STAGING_EXFAT_DELAYED_SYNC #ifndef CONFIG_STAGING_EXFAT_DELAYED_SYNC
fs_sync(sb, true); fs_sync(sb, true);
...@@ -2073,8 +2059,6 @@ static int exfat_readdir(struct file *filp, struct dir_context *ctx) ...@@ -2073,8 +2059,6 @@ static int exfat_readdir(struct file *filp, struct dir_context *ctx)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct exfat_sb_info *sbi = EXFAT_SB(sb);
struct fs_info_t *p_fs = &sbi->fs_info;
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
struct dir_entry_t de; struct dir_entry_t de;
unsigned long inum; unsigned long inum;
...@@ -2084,24 +2068,22 @@ static int exfat_readdir(struct file *filp, struct dir_context *ctx) ...@@ -2084,24 +2068,22 @@ static int exfat_readdir(struct file *filp, struct dir_context *ctx)
__lock_super(sb); __lock_super(sb);
cpos = ctx->pos; cpos = ctx->pos;
/* Fake . and .. for the root directory. */ /* Fake . and .. for any directory. */
if ((p_fs->vol_type == EXFAT) || (inode->i_ino == EXFAT_ROOT_INO)) { while (cpos < 2) {
while (cpos < 2) { if (inode->i_ino == EXFAT_ROOT_INO)
if (inode->i_ino == EXFAT_ROOT_INO) inum = EXFAT_ROOT_INO;
inum = EXFAT_ROOT_INO; else if (cpos == 0)
else if (cpos == 0) inum = inode->i_ino;
inum = inode->i_ino; else /* (cpos == 1) */
else /* (cpos == 1) */ inum = parent_ino(filp->f_path.dentry);
inum = parent_ino(filp->f_path.dentry);
if (!dir_emit_dots(filp, ctx))
if (!dir_emit_dots(filp, ctx)) goto out;
goto out; cpos++;
cpos++; ctx->pos++;
ctx->pos++;
}
if (cpos == 2)
cpos = 0;
} }
if (cpos == 2)
cpos = 0;
if (cpos & (DENTRY_SIZE - 1)) { if (cpos & (DENTRY_SIZE - 1)) {
err = -ENOENT; err = -ENOENT;
goto out; goto out;
...@@ -3345,7 +3327,7 @@ static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -3345,7 +3327,7 @@ static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf)
return -EIO; return -EIO;
} else { } else {
info.FatType = p_fs->vol_type; info.FatType = EXFAT;
info.ClusterSize = p_fs->cluster_size; info.ClusterSize = p_fs->cluster_size;
info.NumClusters = p_fs->num_clusters - 2; info.NumClusters = p_fs->num_clusters - 2;
info.UsedClusters = p_fs->used_clusters; info.UsedClusters = p_fs->used_clusters;
......
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