The code had its own non-standard FFS_FOO return codes. Go through
and convert them all the kernel standard -EFOO codes.
Valdis Kletnieks (15):
staging: exfat: Clean up return codes - FFS_FULL
staging: exfat: Clean up return codes - FFS_NOTFOUND
staging: exfat: Clean up return codes - FFS_DIRBUSY
staging: exfat: Clean up return codes - FFS_PERMISSIONERR
staging: exfat: Clean up return codes - FFS_NAMETOOLONG
staging: exfat: Clean up return codes - FFS_FILEEXIST
staging: exfat: Clean up return codes - FFS_INVALIDPATH
staging: exfat: Clean up return code - FFS_MEMORYERR
staging: exfat: Clean up return codes - FFS_FORMATERR
staging: exfat: Clean up return codes - FFS_MEDIAERR
staging: exfat: Clean up return codes - FFS_EOF
staging: exfat: Clean up return codes - FFS_INVALIDFID
staging: exfat: Clean up return codes - FFS_ERROR
staging: exfat: Clean up return codes - remove unused codes
staging: exfat: Clean up return codes - FFS_SUCCESS
drivers/staging/exfat/exfat.h | 24 +--
drivers/staging/exfat/exfat_blkdev.c | 18 +-
drivers/staging/exfat/exfat_cache.c | 4 +-
drivers/staging/exfat/exfat_core.c | 202 ++++++++++----------
drivers/staging/exfat/exfat_super.c | 269 ++++++++++++++-------------
5 files changed, 249 insertions(+), 268 deletions(-)
--
2.23.0
Convert FFS_NOTFOUND to -ENOENT
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_super.c | 6 +++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 4aca4ae44a98..1d82de4e1a5c 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -216,7 +216,6 @@ static inline u16 get_row_index(u16 i)
#define FFS_SEMAPHOREERR 6
#define FFS_INVALIDPATH 7
#define FFS_INVALIDFID 8
-#define FFS_NOTFOUND 9
#define FFS_FILEEXIST 10
#define FFS_PERMISSIONERR 11
#define FFS_NOTOPENED 12
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 273fe2310e76..50fc097ded69 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -572,7 +572,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid)
dentry = p_fs->fs_func->find_dir_entry(sb, &dir, &uni_name, num_entries,
&dos_name, TYPE_ALL);
if (dentry < -1) {
- ret = FFS_NOTFOUND;
+ ret = -ENOENT;
goto out;
}
@@ -2695,7 +2695,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
err = -EINVAL;
else if (err == FFS_FILEEXIST)
err = -ENOTEMPTY;
- else if (err == FFS_NOTFOUND)
+ else if (err == -ENOENT)
err = -ENOENT;
else if (err == FFS_DIRBUSY)
err = -EBUSY;
@@ -2752,7 +2752,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
err = -EINVAL;
else if (err == FFS_FILEEXIST)
err = -EEXIST;
- else if (err == FFS_NOTFOUND)
+ else if (err == -ENOENT)
err = -ENOENT;
else if (err == -ENOSPC)
err = -ENOSPC;
--
2.23.0
Convert FFS_DIRBUSY to -EBUSY
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_super.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 1d82de4e1a5c..ec52237b01cd 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i)
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
#define FFS_EOF 15
-#define FFS_DIRBUSY 16
#define FFS_MEMORYERR 17
#define FFS_NAMETOOLONG 18
#define FFS_ERROR 19
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 50fc097ded69..566cfba0a522 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -2697,7 +2697,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
err = -ENOTEMPTY;
else if (err == -ENOENT)
err = -ENOENT;
- else if (err == FFS_DIRBUSY)
+ else if (err == -EBUSY)
err = -EBUSY;
else
err = -EIO;
--
2.23.0
Convert FFS_PERMISSIONERR to -EPERM
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_super.c | 20 ++++++++++----------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index ec52237b01cd..86bdcf222a5a 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -217,7 +217,6 @@ static inline u16 get_row_index(u16 i)
#define FFS_INVALIDPATH 7
#define FFS_INVALIDFID 8
#define FFS_FILEEXIST 10
-#define FFS_PERMISSIONERR 11
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
#define FFS_EOF 15
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 566cfba0a522..fd5d8ba0d8bc 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -702,7 +702,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
/* check if the given file ID is opened */
if (fid->type != TYPE_FILE) {
- ret = FFS_PERMISSIONERR;
+ ret = -EPERM;
goto out;
}
@@ -832,7 +832,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
/* check if the given file ID is opened */
if (fid->type != TYPE_FILE) {
- ret = FFS_PERMISSIONERR;
+ ret = -EPERM;
goto out;
}
@@ -1079,7 +1079,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
/* check if the given file ID is opened */
if (fid->type != TYPE_FILE) {
- ret = FFS_PERMISSIONERR;
+ ret = -EPERM;
goto out;
}
@@ -1246,7 +1246,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
/* check if the old file is "." or ".." */
if (p_fs->vol_type != EXFAT) {
if ((olddir.dir != p_fs->root_dir) && (dentry < 2)) {
- ret = FFS_PERMISSIONERR;
+ ret = -EPERM;
goto out2;
}
}
@@ -1258,7 +1258,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
}
if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) {
- ret = FFS_PERMISSIONERR;
+ ret = -EPERM;
goto out2;
}
@@ -1365,7 +1365,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
}
if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) {
- ret = FFS_PERMISSIONERR;
+ ret = -EPERM;
goto out;
}
fs_set_vol_flags(sb, VOL_DIRTY);
@@ -1947,7 +1947,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
/* check if the given file ID is opened */
if (fid->type != TYPE_DIR)
- return FFS_PERMISSIONERR;
+ return -EPERM;
/* acquire the lock for file system critical section */
down(&p_fs->v_sem);
@@ -2145,7 +2145,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
/* check if the file is "." or ".." */
if (p_fs->vol_type != EXFAT) {
if ((dir.dir != p_fs->root_dir) && (dentry < 2))
- return FFS_PERMISSIONERR;
+ return -EPERM;
}
/* acquire the lock for file system critical section */
@@ -2526,7 +2526,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid));
if (err) {
- if (err == FFS_PERMISSIONERR)
+ if (err == -EPERM)
err = -EPERM;
else
err = -EIO;
@@ -2746,7 +2746,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir,
new_dentry);
if (err) {
- if (err == FFS_PERMISSIONERR)
+ if (err == -EPERM)
err = -EPERM;
else if (err == FFS_INVALIDPATH)
err = -EINVAL;
--
2.23.0
Convert FFS_MEMORYERR to -ENOMEM
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_core.c | 10 +++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 00e5e37100ce..2588a6cbe552 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -218,7 +218,6 @@ static inline u16 get_row_index(u16 i)
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
#define FFS_EOF 15
-#define FFS_MEMORYERR 17
#define FFS_ERROR 19
#define NUM_UPCASE 2918
diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c
index 23c369fb98e5..fa2bf18b4a14 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -177,7 +177,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
sizeof(struct buffer_head *),
GFP_KERNEL);
if (!p_fs->vol_amap)
- return FFS_MEMORYERR;
+ return -ENOMEM;
sector = START_SECTOR(p_fs->map_clu);
@@ -604,7 +604,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector,
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
if (!upcase_table)
- return FFS_MEMORYERR;
+ return -ENOMEM;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
while (sector < end_sector) {
@@ -644,7 +644,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector,
upcase_table[col_index] = kmalloc_array(UTBL_ROW_COUNT,
sizeof(u16), GFP_KERNEL);
if (!upcase_table[col_index]) {
- ret = FFS_MEMORYERR;
+ ret = -ENOMEM;
goto error;
}
@@ -684,7 +684,7 @@ static s32 __load_default_upcase_table(struct super_block *sb)
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
if (!upcase_table)
- return FFS_MEMORYERR;
+ return -ENOMEM;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
for (i = 0; index <= 0xFFFF && i < NUM_UPCASE * 2; i += 2) {
@@ -707,7 +707,7 @@ static s32 __load_default_upcase_table(struct super_block *sb)
sizeof(u16),
GFP_KERNEL);
if (!upcase_table[col_index]) {
- ret = FFS_MEMORYERR;
+ ret = -ENOMEM;
goto error;
}
--
2.23.0
Convert FFS_INVALIDPATH to -EINVAL
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_core.c | 10 +++++-----
drivers/staging/exfat/exfat_super.c | 10 +++++-----
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index c56363652c5d..00e5e37100ce 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -214,7 +214,6 @@ static inline u16 get_row_index(u16 i)
#define FFS_NOTMOUNTED 4
#define FFS_ALIGNMENTERR 5
#define FFS_SEMAPHOREERR 6
-#define FFS_INVALIDPATH 7
#define FFS_INVALIDFID 8
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c
index ba5680123b0f..23c369fb98e5 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -2124,7 +2124,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir,
num_entries = p_fs->fs_func->calc_num_entries(p_uniname);
if (num_entries == 0)
- return FFS_INVALIDPATH;
+ return -EINVAL;
if (p_fs->vol_type != EXFAT) {
nls_uniname_to_dosname(sb, p_dosname, p_uniname, &lossy);
@@ -2136,7 +2136,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir,
} else {
for (r = reserved_names; *r; r++) {
if (!strncmp((void *)p_dosname->name, *r, 8))
- return FFS_INVALIDPATH;
+ return -EINVAL;
}
if (p_dosname->name_case != 0xFF)
@@ -2257,11 +2257,11 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir,
struct file_id_t *fid = &(EXFAT_I(inode)->fid);
if (strscpy(name_buf, path, sizeof(name_buf)) < 0)
- return FFS_INVALIDPATH;
+ return -EINVAL;
nls_cstring_to_uniname(sb, p_uniname, name_buf, &lossy);
if (lossy)
- return FFS_INVALIDPATH;
+ return -EINVAL;
fid->size = i_size_read(inode);
@@ -2659,7 +2659,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
/* check if the source and target directory is the same */
if (fs_func->get_entry_type(epmov) == TYPE_DIR &&
fs_func->get_entry_clu0(epmov) == p_newdir->dir)
- return FFS_INVALIDPATH;
+ return -EINVAL;
buf_lock(sb, sector_mov);
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 2c294e238d7b..5b35e3683605 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -2356,7 +2356,7 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_REGULAR, &fid);
if (err) {
- if (err == FFS_INVALIDPATH)
+ if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
@@ -2567,7 +2567,7 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry,
err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_SYMLINK, &fid);
if (err) {
- if (err == FFS_INVALIDPATH)
+ if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
@@ -2637,7 +2637,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
err = ffsCreateDir(dir, (u8 *)dentry->d_name.name, &fid);
if (err) {
- if (err == FFS_INVALIDPATH)
+ if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
@@ -2691,7 +2691,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
err = ffsRemoveDir(dir, &(EXFAT_I(inode)->fid));
if (err) {
- if (err == FFS_INVALIDPATH)
+ if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -ENOTEMPTY;
@@ -2748,7 +2748,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
if (err) {
if (err == -EPERM)
err = -EPERM;
- else if (err == FFS_INVALIDPATH)
+ else if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
--
2.23.0
Convert FFS_MEDIAERR to (mostly) -ENOENT and -EIO. Some additional code surgery
needed to propogate correct error codes upwards.
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_blkdev.c | 18 ++---
drivers/staging/exfat/exfat_core.c | 68 ++++++++--------
drivers/staging/exfat/exfat_super.c | 115 ++++++++++++++-------------
4 files changed, 101 insertions(+), 101 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 7ca187e77cbe..df7b99707aed 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -210,7 +210,6 @@ static inline u16 get_row_index(u16 i)
/* return values */
#define FFS_SUCCESS 0
-#define FFS_MEDIAERR 1
#define FFS_MOUNTED 3
#define FFS_NOTMOUNTED 4
#define FFS_ALIGNMENTERR 5
diff --git a/drivers/staging/exfat/exfat_blkdev.c b/drivers/staging/exfat/exfat_blkdev.c
index 81d20e6241c6..0abae041f632 100644
--- a/drivers/staging/exfat/exfat_blkdev.c
+++ b/drivers/staging/exfat/exfat_blkdev.c
@@ -40,11 +40,11 @@ int bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh,
long flags = sbi->debug_flags;
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
- return FFS_MEDIAERR;
+ return -EIO;
#endif /* CONFIG_EXFAT_KERNEL_DEBUG */
if (!p_bd->opened)
- return FFS_MEDIAERR;
+ return -ENODEV;
if (*bh)
__brelse(*bh);
@@ -62,7 +62,7 @@ int bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh,
WARN(!p_fs->dev_ejected,
"[EXFAT] No bh, device seems wrong or to be ejected.\n");
- return FFS_MEDIAERR;
+ return -EIO;
}
int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh,
@@ -77,11 +77,11 @@ int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh,
long flags = sbi->debug_flags;
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
- return FFS_MEDIAERR;
+ return -EIO;
#endif /* CONFIG_EXFAT_KERNEL_DEBUG */
if (!p_bd->opened)
- return FFS_MEDIAERR;
+ return -ENODEV;
if (secno == bh->b_blocknr) {
lock_buffer(bh);
@@ -89,7 +89,7 @@ int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh,
mark_buffer_dirty(bh);
unlock_buffer(bh);
if (sync && (sync_dirty_buffer(bh) != 0))
- return FFS_MEDIAERR;
+ return -EIO;
} else {
count = num_secs << p_bd->sector_size_bits;
@@ -115,7 +115,7 @@ int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh,
WARN(!p_fs->dev_ejected,
"[EXFAT] No bh, device seems wrong or to be ejected.\n");
- return FFS_MEDIAERR;
+ return -EIO;
}
int bdev_sync(struct super_block *sb)
@@ -126,11 +126,11 @@ int bdev_sync(struct super_block *sb)
long flags = sbi->debug_flags;
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
- return FFS_MEDIAERR;
+ return -EIO;
#endif /* CONFIG_EXFAT_KERNEL_DEBUG */
if (!p_bd->opened)
- return FFS_MEDIAERR;
+ return -ENODEV;
return sync_blockdev(sb->s_bdev);
}
diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c
index 39c103e73b63..7e637a8e19d3 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -158,7 +158,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
ep = (struct bmap_dentry_t *)get_entry_in_dir(sb, &clu,
i, NULL);
if (!ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
type = p_fs->fs_func->get_entry_type((struct dentry_t *)ep);
@@ -202,7 +202,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
}
if (FAT_read(sb, clu.dir, &clu.dir) != 0)
- return FFS_MEDIAERR;
+ return -EIO;
}
return -EFSCORRUPTED;
@@ -391,13 +391,13 @@ static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc,
}
if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS)
- return -1;
+ return -EIO;
num_clusters++;
if (p_chain->flags == 0x01) {
if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0)
- return -1;
+ return -EIO;
}
if (p_chain->dir == CLUSTER_32(~0)) {
@@ -405,7 +405,7 @@ static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc,
} else {
if (p_chain->flags == 0x01) {
if (FAT_write(sb, last_clu, new_clu) < 0)
- return -1;
+ return -EIO;
}
}
last_clu = new_clu;
@@ -744,14 +744,14 @@ s32 load_upcase_table(struct super_block *sb)
clu.flags = 0x01;
if (p_fs->dev_ejected)
- return FFS_MEDIAERR;
+ return -EIO;
while (clu.dir != CLUSTER_32(~0)) {
for (i = 0; i < p_fs->dentries_per_clu; i++) {
ep = (struct case_dentry_t *)get_entry_in_dir(sb, &clu,
i, NULL);
if (!ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
type = p_fs->fs_func->get_entry_type((struct dentry_t *)ep);
@@ -771,7 +771,7 @@ s32 load_upcase_table(struct super_block *sb)
return FFS_SUCCESS;
}
if (FAT_read(sb, clu.dir, &clu.dir) != 0)
- return FFS_MEDIAERR;
+ return -EIO;
}
/* load default upcase table */
return __load_default_upcase_table(sb);
@@ -1253,12 +1253,12 @@ static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir,
file_ep = (struct file_dentry_t *)get_entry_in_dir(sb, p_dir, entry,
§or);
if (!file_ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
strm_ep = (struct strm_dentry_t *)get_entry_in_dir(sb, p_dir, entry + 1,
§or);
if (!strm_ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
init_file_entry(file_ep, type);
buf_modify(sb, sector);
@@ -1284,7 +1284,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir,
file_ep = (struct file_dentry_t *)get_entry_in_dir(sb, p_dir, entry,
§or);
if (!file_ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
file_ep->num_ext = (u8)(num_entries - 1);
buf_modify(sb, sector);
@@ -1292,7 +1292,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir,
strm_ep = (struct strm_dentry_t *)get_entry_in_dir(sb, p_dir, entry + 1,
§or);
if (!strm_ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
strm_ep->name_len = p_uniname->name_len;
SET16_A(strm_ep->name_hash, p_uniname->name_hash);
@@ -1303,7 +1303,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir,
entry + i,
§or);
if (!name_ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
init_name_entry(name_ep, uniname);
buf_modify(sb, sector);
@@ -1348,7 +1348,7 @@ static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir,
} else {
while (clu_offset > 0) {
if (FAT_read(sb, cur_clu, &cur_clu) == -1)
- return FFS_MEDIAERR;
+ return -EIO;
clu_offset--;
}
}
@@ -1626,10 +1626,10 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_
/* (1) allocate a cluster */
ret = p_fs->fs_func->alloc_cluster(sb, 1, &clu);
if (ret < 1)
- return -1;
+ return -EIO;
if (clear_cluster(sb, clu.dir) != FFS_SUCCESS)
- return -1;
+ return -EIO;
/* (2) append to the FAT chain */
if (clu.flags != p_dir->flags) {
@@ -1639,7 +1639,7 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_
}
if (clu.flags == 0x01)
if (FAT_write(sb, last_clu, clu.dir) < 0)
- return -1;
+ return -EIO;
if (p_fs->hint_uentry.entry == -1) {
p_fs->hint_uentry.dir = p_dir->dir;
@@ -1660,7 +1660,7 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_
ep = get_entry_in_dir(sb, &fid->dir,
fid->entry + 1, §or);
if (!ep)
- return -1;
+ return -ENOENT;
p_fs->fs_func->set_entry_size(ep, size);
p_fs->fs_func->set_entry_flag(ep, p_dir->flags);
buf_modify(sb, sector);
@@ -1895,7 +1895,7 @@ s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir,
for (i = 0; i < dentries_per_clu; i++) {
ep = get_entry_in_dir(sb, &clu, i, NULL);
if (!ep)
- return -1;
+ return -ENOENT;
entry_type = p_fs->fs_func->get_entry_type(ep);
@@ -1919,7 +1919,7 @@ s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir,
clu.dir = CLUSTER_32(~0);
} else {
if (FAT_read(sb, clu.dir, &clu.dir) != 0)
- return -1;
+ return -EIO;
}
}
@@ -2046,7 +2046,7 @@ static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir,
ep = (struct dos_dentry_t *)get_entry_in_dir(sb, &clu,
i, NULL);
if (!ep)
- return FFS_MEDIAERR;
+ return -ENOENT;
type = p_fs->fs_func->get_entry_type((struct dentry_t *)
ep);
@@ -2085,7 +2085,7 @@ static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir,
break; /* FAT16 root_dir */
if (FAT_read(sb, clu.dir, &clu.dir) != 0)
- return FFS_MEDIAERR;
+ return -EIO;
}
count = 0;
@@ -2378,7 +2378,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
/* (1) allocate a cluster */
ret = fs_func->alloc_cluster(sb, 1, &clu);
if (ret < 0)
- return FFS_MEDIAERR;
+ return ret;
else if (ret == 0)
return -ENOSPC;
@@ -2547,7 +2547,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
epold = get_entry_in_dir(sb, p_dir, oldentry, §or_old);
if (!epold)
- return FFS_MEDIAERR;
+ return -ENOENT;
buf_lock(sb, sector_old);
@@ -2556,7 +2556,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
epold);
if (num_old_entries < 0) {
buf_unlock(sb, sector_old);
- return FFS_MEDIAERR;
+ return -ENOENT;
}
num_old_entries++;
@@ -2577,7 +2577,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
epnew = get_entry_in_dir(sb, p_dir, newentry, §or_new);
if (!epnew) {
buf_unlock(sb, sector_old);
- return FFS_MEDIAERR;
+ return -ENOENT;
}
memcpy((void *)epnew, (void *)epold, DENTRY_SIZE);
@@ -2599,7 +2599,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
if (!epold || !epnew) {
buf_unlock(sb, sector_old);
- return FFS_MEDIAERR;
+ return -ENOENT;
}
memcpy((void *)epnew, (void *)epold, DENTRY_SIZE);
@@ -2654,7 +2654,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
epmov = get_entry_in_dir(sb, p_olddir, oldentry, §or_mov);
if (!epmov)
- return FFS_MEDIAERR;
+ return -ENOENT;
/* check if the source and target directory is the same */
if (fs_func->get_entry_type(epmov) == TYPE_DIR &&
@@ -2668,7 +2668,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
epmov);
if (num_old_entries < 0) {
buf_unlock(sb, sector_mov);
- return FFS_MEDIAERR;
+ return -ENOENT;
}
num_old_entries++;
@@ -2688,7 +2688,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
epnew = get_entry_in_dir(sb, p_newdir, newentry, §or_new);
if (!epnew) {
buf_unlock(sb, sector_mov);
- return FFS_MEDIAERR;
+ return -ENOENT;
}
memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE);
@@ -2708,7 +2708,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
§or_new);
if (!epmov || !epnew) {
buf_unlock(sb, sector_mov);
- return FFS_MEDIAERR;
+ return -ENOENT;
}
memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE);
@@ -2721,7 +2721,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
epnew = get_entry_in_dir(sb, &clu, 1, §or_new);
if (!epnew)
- return FFS_MEDIAERR;
+ return -ENOENT;
if (p_newdir->dir == p_fs->root_dir)
fs_func->set_entry_clu0(epnew, CLUSTER_32(0));
@@ -2753,7 +2753,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh,
bool read)
{
- s32 ret = FFS_MEDIAERR;
+ s32 ret = -EIO;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
if ((sec >= (p_fs->PBR_sector + p_fs->num_sectors)) &&
@@ -2776,7 +2776,7 @@ int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh,
int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh,
bool sync)
{
- s32 ret = FFS_MEDIAERR;
+ s32 ret = -EIO;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
if (sec >= (p_fs->PBR_sector + p_fs->num_sectors) &&
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 161971c80c02..a5c85dafefb4 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -364,7 +364,9 @@ static int ffsMountVol(struct super_block *sb)
bdev_open(sb);
if (p_bd->sector_size < sb->s_blocksize) {
- ret = FFS_MEDIAERR;
+ printk(KERN_INFO "EXFAT: maont failed - sector size %d less than blocksize %ld\n",
+ p_bd->sector_size, sb->s_blocksize);
+ ret = -EINVAL;
goto out;
}
if (p_bd->sector_size > sb->s_blocksize)
@@ -372,7 +374,7 @@ static int ffsMountVol(struct super_block *sb)
/* read Sector 0 */
if (sector_read(sb, 0, &tmp_bh, 1) != FFS_SUCCESS) {
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
@@ -429,7 +431,7 @@ static int ffsMountVol(struct super_block *sb)
free_alloc_bitmap(sb);
}
bdev_close(sb);
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
@@ -469,7 +471,7 @@ static int ffsUmountVol(struct super_block *sb)
if (p_fs->dev_ejected) {
pr_info("[EXFAT] unmounted with media errors. Device is already ejected.\n");
- err = FFS_MEDIAERR;
+ err = -EIO;
}
buf_shutdown(sb);
@@ -505,7 +507,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info)
info->FreeClusters = info->NumClusters - info->UsedClusters;
if (p_fs->dev_ejected)
- err = FFS_MEDIAERR;
+ err = -EIO;
/* release the lock for file system critical section */
up(&p_fs->v_sem);
@@ -526,7 +528,7 @@ static int ffsSyncVol(struct super_block *sb, bool do_sync)
fs_set_vol_flags(sb, VOL_CLEAN);
if (p_fs->dev_ejected)
- err = FFS_MEDIAERR;
+ err = -EIO;
/* release the lock for file system critical section */
up(&p_fs->v_sem);
@@ -595,14 +597,14 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid)
es = get_entry_set_in_dir(sb, &dir, dentry,
ES_2_ENTRIES, &ep);
if (!es) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep + 1;
} else {
ep = get_entry_in_dir(sb, &dir, dentry, NULL);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep;
@@ -627,7 +629,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid)
}
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
up(&p_fs->v_sem);
@@ -667,7 +669,7 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode,
#endif
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -738,7 +740,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
while (clu_offset > 0) {
/* clu = FAT_read(sb, clu); */
if (FAT_read(sb, clu, &clu) == -1)
- return FFS_MEDIAERR;
+ return -EIO;
clu_offset--;
}
@@ -791,7 +793,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
*rcount = read_bytes;
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -881,7 +883,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
last_clu = clu;
/* clu = FAT_read(sb, clu); */
if (FAT_read(sb, clu, &clu) == -1) {
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
clu_offset--;
@@ -903,7 +905,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
if (num_alloced == 0)
break;
if (num_alloced < 0) {
- ret = FFS_MEDIAERR;
+ ret = num_alloced;
goto out;
}
@@ -1048,7 +1050,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
ret = -ENOSPC;
else if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -1109,7 +1111,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
while (num_clusters > 0) {
last_clu = clu.dir;
if (FAT_read(sb, clu.dir, &clu.dir) == -1) {
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
num_clusters--;
@@ -1131,14 +1133,14 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
es = get_entry_set_in_dir(sb, &fid->dir, fid->entry,
ES_ALL_ENTRIES, &ep);
if (!es) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep + 1;
} else {
ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep;
@@ -1180,7 +1182,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
#endif
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
pr_debug("%s exited (%d)\n", __func__, ret);
@@ -1253,7 +1255,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
ep = get_entry_in_dir(sb, &olddir, dentry, NULL);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out2;
}
@@ -1266,7 +1268,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
if (new_inode) {
u32 entry_type;
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
new_fid = &EXFAT_I(new_inode)->fid;
update_parent_info(new_fid, new_parent_inode);
@@ -1328,7 +1330,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
#endif
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out2:
/* release the lock for file system critical section */
up(&p_fs->v_sem);
@@ -1360,7 +1362,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
ep = get_entry_in_dir(sb, &dir, dentry, NULL);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
@@ -1390,7 +1392,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
#endif
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
up(&p_fs->v_sem);
@@ -1414,7 +1416,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
if (fid->attr == attr) {
if (p_fs->dev_ejected)
- return FFS_MEDIAERR;
+ return -EIO;
return FFS_SUCCESS;
}
@@ -1422,7 +1424,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
if ((fid->dir.dir == p_fs->root_dir) &&
(fid->entry == -1)) {
if (p_fs->dev_ejected)
- return FFS_MEDIAERR;
+ return -EIO;
return FFS_SUCCESS;
}
}
@@ -1435,13 +1437,13 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
es = get_entry_set_in_dir(sb, &(fid->dir), fid->entry,
ES_ALL_ENTRIES, &ep);
if (!es) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
} else {
ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
}
@@ -1451,7 +1453,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
if (((type == TYPE_FILE) && (attr & ATTR_SUBDIR)) ||
((type == TYPE_DIR) && (!(attr & ATTR_SUBDIR)))) {
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
else
ret = FFS_ERROR;
@@ -1479,7 +1481,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
#endif
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
up(&p_fs->v_sem);
@@ -1535,13 +1537,13 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info)
count = count_dos_name_entries(sb, &dir, TYPE_DIR);
if (count < 0) {
- ret = FFS_MEDIAERR;
+ ret = count; /* propogate error upward */
goto out;
}
info->NumSubdirs = count;
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
}
@@ -1551,14 +1553,14 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info)
es = get_entry_set_in_dir(sb, &(fid->dir), fid->entry,
ES_2_ENTRIES, &ep);
if (!es) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep + 1;
} else {
ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep;
@@ -1624,14 +1626,14 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info)
count = count_dos_name_entries(sb, &dir, TYPE_DIR);
if (count < 0) {
- ret = FFS_MEDIAERR;
+ ret = count; /* propogate error upward */
goto out;
}
info->NumSubdirs += count;
}
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -1662,7 +1664,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info)
if ((fid->dir.dir == p_fs->root_dir) &&
(fid->entry == -1)) {
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
ret = FFS_SUCCESS;
goto out;
}
@@ -1675,7 +1677,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info)
es = get_entry_set_in_dir(sb, &(fid->dir), fid->entry,
ES_ALL_ENTRIES, &ep);
if (!es) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep + 1;
@@ -1683,7 +1685,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info)
/* for other than exfat */
ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
ep2 = ep;
@@ -1718,7 +1720,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info)
}
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -1780,7 +1782,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
while ((clu_offset > 0) && (*clu != CLUSTER_32(~0))) {
last_clu = *clu;
if (FAT_read(sb, *clu, clu) == -1) {
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
clu_offset--;
@@ -1798,7 +1800,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
/* (1) allocate a cluster */
num_alloced = p_fs->fs_func->alloc_cluster(sb, 1, &new_clu);
if (num_alloced < 0) {
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
} else if (num_alloced == 0) {
ret = -ENOSPC;
@@ -1829,7 +1831,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
es = get_entry_set_in_dir(sb, &fid->dir, fid->entry,
ES_ALL_ENTRIES, &ep);
if (!es) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
/* get stream entry */
@@ -1842,7 +1844,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
ep = get_entry_in_dir(sb, &(fid->dir),
fid->entry, §or);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
}
@@ -1872,7 +1874,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
fid->hint_last_clu = *clu;
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -1917,7 +1919,7 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid)
#endif
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
up(&p_fs->v_sem);
@@ -1947,7 +1949,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
/* check if the given file ID is opened */
if (fid->type != TYPE_DIR)
- return -EPERM;
+ return -ENOTDIR;
/* acquire the lock for file system critical section */
down(&p_fs->v_sem);
@@ -1997,7 +1999,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
while (clu_offset > 0) {
/* clu.dir = FAT_read(sb, clu.dir); */
if (FAT_read(sb, clu.dir, &clu.dir) == -1) {
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
clu_offset--;
@@ -2017,7 +2019,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
for ( ; i < dentries_per_clu; i++, dentry++) {
ep = get_entry_in_dir(sb, &clu, i, §or);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
type = fs_func->get_entry_type(ep);
@@ -2065,7 +2067,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
if (p_fs->vol_type == EXFAT) {
ep = get_entry_in_dir(sb, &clu, i + 1, NULL);
if (!ep) {
- ret = FFS_MEDIAERR;
+ ret = -ENOENT;
goto out;
}
} else {
@@ -2089,7 +2091,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
fid->rwoffset = (s64)(++dentry);
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
@@ -2104,7 +2106,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
} else {
/* clu.dir = FAT_read(sb, clu.dir); */
if (FAT_read(sb, clu.dir, &clu.dir) == -1) {
- ret = FFS_MEDIAERR;
+ ret = -EIO;
goto out;
}
}
@@ -2115,7 +2117,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
fid->rwoffset = (s64)(++dentry);
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -2178,7 +2180,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
#endif
if (p_fs->dev_ejected)
- ret = FFS_MEDIAERR;
+ ret = -EIO;
out:
/* release the lock for file system critical section */
@@ -2238,12 +2240,11 @@ static int exfat_readdir(struct file *filp, struct dir_context *ctx)
/* at least we tried to read a sector
* move cpos to next sector position (should be aligned)
*/
- if (err == FFS_MEDIAERR) {
+ if (err == -EIO) {
cpos += 1 << p_bd->sector_size_bits;
cpos &= ~((1 << p_bd->sector_size_bits) - 1);
}
- err = -EIO;
goto end_of_dir;
}
@@ -3495,7 +3496,7 @@ static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf)
struct vol_info_t info;
if (p_fs->used_clusters == UINT_MAX) {
- if (ffsGetVolInfo(sb, &info) == FFS_MEDIAERR)
+ if (ffsGetVolInfo(sb, &info) == -EIO)
return -EIO;
} else {
--
2.23.0
Covert FFS_INVALIDFID to -EINVAL
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_super.c | 10 +++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 3ff7293fedd2..505751bf1817 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -214,7 +214,6 @@ static inline u16 get_row_index(u16 i)
#define FFS_NOTMOUNTED 4
#define FFS_ALIGNMENTERR 5
#define FFS_SEMAPHOREERR 6
-#define FFS_INVALIDFID 8
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
#define FFS_ERROR 19
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index a0c28fd8824b..485297974ae7 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -693,7 +693,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
/* check the validity of the given file id */
if (!fid)
- return FFS_INVALIDFID;
+ return -EINVAL;
/* check the validity of pointer parameters */
if (!buffer)
@@ -823,7 +823,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
/* check the validity of the given file id */
if (!fid)
- return FFS_INVALIDFID;
+ return -EINVAL;
/* check the validity of pointer parameters */
if (!buffer)
@@ -1228,7 +1228,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
/* check the validity of the given file id */
if (!fid)
- return FFS_INVALIDFID;
+ return -EINVAL;
/* check the validity of pointer parameters */
if (!new_path || (*new_path == '\0'))
@@ -1349,7 +1349,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
/* check the validity of the given file id */
if (!fid)
- return FFS_INVALIDFID;
+ return -EINVAL;
/* acquire the lock for file system critical section */
down(&p_fs->v_sem);
@@ -2136,7 +2136,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
/* check the validity of the given file id */
if (!fid)
- return FFS_INVALIDFID;
+ return -EINVAL;
dir.dir = fid->dir.dir;
dir.size = fid->dir.size;
--
2.23.0
There are 6 FFS_* error values not used at all. Remove them.
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 2ca2710601ae..819a21d72c67 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -210,12 +210,6 @@ static inline u16 get_row_index(u16 i)
/* return values */
#define FFS_SUCCESS 0
-#define FFS_MOUNTED 3
-#define FFS_NOTMOUNTED 4
-#define FFS_ALIGNMENTERR 5
-#define FFS_SEMAPHOREERR 6
-#define FFS_NOTOPENED 12
-#define FFS_MAXOPENED 13
#define NUM_UPCASE 2918
--
2.23.0
Just replace FFS_SUCCESS with a literal 0.
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 3 -
drivers/staging/exfat/exfat_cache.c | 4 +-
drivers/staging/exfat/exfat_core.c | 90 ++++++++++++++---------------
drivers/staging/exfat/exfat_super.c | 50 ++++++++--------
4 files changed, 72 insertions(+), 75 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 819a21d72c67..3532879ca73e 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -208,9 +208,6 @@ static inline u16 get_row_index(u16 i)
#define FM_REGULAR 0x00
#define FM_SYMLINK 0x40
-/* return values */
-#define FFS_SUCCESS 0
-
#define NUM_UPCASE 2918
#define DOS_CUR_DIR_NAME ". "
diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c
index e9ad0353b4e5..44383cc1c937 100644
--- a/drivers/staging/exfat/exfat_cache.c
+++ b/drivers/staging/exfat/exfat_cache.c
@@ -214,7 +214,7 @@ static u8 *FAT_getblk(struct super_block *sb, sector_t sec)
FAT_cache_insert_hash(sb, bp);
- if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
+ if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {
FAT_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
@@ -583,7 +583,7 @@ static u8 *__buf_getblk(struct super_block *sb, sector_t sec)
buf_cache_insert_hash(sb, bp);
- if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
+ if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {
buf_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c
index 7efc5d08cada..3d01d0b9941b 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -102,7 +102,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag)
if (p_fs->vol_type == EXFAT) {
if (!p_fs->pbr_bh) {
if (sector_read(sb, p_fs->PBR_sector,
- &p_fs->pbr_bh, 1) != FFS_SUCCESS)
+ &p_fs->pbr_bh, 1) != 0)
return;
}
@@ -184,7 +184,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
for (j = 0; j < p_fs->map_sectors; j++) {
p_fs->vol_amap[j] = NULL;
ret = sector_read(sb, sector + j, &(p_fs->vol_amap[j]), 1);
- if (ret != FFS_SUCCESS) {
+ if (ret != 0) {
/* release all buffers and free vol_amap */
i = 0;
while (i < j)
@@ -197,7 +197,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
}
p_fs->pbr_bh = NULL;
- return FFS_SUCCESS;
+ return 0;
}
}
@@ -332,7 +332,7 @@ static void sync_alloc_bitmap(struct super_block *sb)
static s32 clear_cluster(struct super_block *sb, u32 clu)
{
sector_t s, n;
- s32 ret = FFS_SUCCESS;
+ s32 ret = 0;
struct buffer_head *tmp_bh = NULL;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
@@ -347,12 +347,12 @@ static s32 clear_cluster(struct super_block *sb, u32 clu)
for (; s < n; s++) {
ret = sector_read(sb, s, &tmp_bh, 0);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
memset((char *)tmp_bh->b_data, 0x0, p_bd->sector_size);
ret = sector_write(sb, s, tmp_bh, 0);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
break;
}
@@ -390,7 +390,7 @@ static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc,
}
}
- if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS)
+ if (set_alloc_bitmap(sb, new_clu - 2) != 0)
return -EIO;
num_clusters++;
@@ -468,7 +468,7 @@ static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain,
buf_release(sb, sector + i);
}
- if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
+ if (clr_alloc_bitmap(sb, clu - 2) != 0)
break;
clu++;
@@ -485,7 +485,7 @@ static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain,
buf_release(sb, sector + i);
}
- if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
+ if (clr_alloc_bitmap(sb, clu - 2) != 0)
break;
if (FAT_read(sb, clu, &clu) == -1)
@@ -609,7 +609,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector,
while (sector < end_sector) {
ret = sector_read(sb, sector, &tmp_bh, 1);
- if (ret != FFS_SUCCESS) {
+ if (ret != 0) {
pr_debug("sector read (0x%llX)fail\n",
(unsigned long long)sector);
goto error;
@@ -660,7 +660,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector,
if (index >= 0xFFFF && utbl_checksum == checksum) {
if (tmp_bh)
brelse(tmp_bh);
- return FFS_SUCCESS;
+ return 0;
}
ret = -EINVAL;
error:
@@ -721,7 +721,7 @@ static s32 __load_default_upcase_table(struct super_block *sb)
}
if (index >= 0xFFFF)
- return FFS_SUCCESS;
+ return 0;
error:
/* FATAL error: default upcase table has error */
@@ -766,9 +766,9 @@ s32 load_upcase_table(struct super_block *sb)
sector = START_SECTOR(tbl_clu);
num_sectors = ((tbl_size - 1) >> p_bd->sector_size_bits) + 1;
if (__load_upcase_table(sb, sector, num_sectors,
- GET32_A(ep->checksum)) != FFS_SUCCESS)
+ GET32_A(ep->checksum)) != 0)
break;
- return FFS_SUCCESS;
+ return 0;
}
if (FAT_read(sb, clu.dir, &clu.dir) != 0)
return -EIO;
@@ -844,7 +844,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb,
}
pr_debug("%s exited successfully\n", __func__);
- return FFS_SUCCESS;
+ return 0;
err_out:
pr_debug("%s failed\n", __func__);
return -EINVAL;
@@ -1266,7 +1266,7 @@ static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir,
init_strm_entry(strm_ep, flags, start_clu, size);
buf_modify(sb, sector);
- return FFS_SUCCESS;
+ return 0;
}
static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir,
@@ -1312,7 +1312,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir,
update_dir_checksum(sb, p_dir, entry);
- return FFS_SUCCESS;
+ return 0;
}
static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir,
@@ -1355,7 +1355,7 @@ static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir,
if (clu)
*clu = cur_clu;
- return FFS_SUCCESS;
+ return 0;
}
static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry,
@@ -1374,7 +1374,7 @@ static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entr
*sector += p_fs->root_start_sector;
} else {
ret = _walk_fat_chain(sb, p_dir, off, &clu);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
/* byte offset in cluster */
@@ -1387,7 +1387,7 @@ static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entr
*sector = off >> p_bd->sector_size_bits;
*sector += START_SECTOR(clu);
}
- return FFS_SUCCESS;
+ return 0;
}
struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir,
@@ -1397,7 +1397,7 @@ struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir,
sector_t sec;
u8 *buf;
- if (find_location(sb, p_dir, entry, &sec, &off) != FFS_SUCCESS)
+ if (find_location(sb, p_dir, entry, &sec, &off) != 0)
return NULL;
buf = buf_getblk(sb, sec);
@@ -1451,7 +1451,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb,
byte_offset = entry << DENTRY_SIZE_BITS;
ret = _walk_fat_chain(sb, p_dir, byte_offset, &clu);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return NULL;
/* byte offset in cluster */
@@ -1628,7 +1628,7 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_
if (ret < 1)
return -EIO;
- if (clear_cluster(sb, clu.dir) != FFS_SUCCESS)
+ if (clear_cluster(sb, clu.dir) != 0)
return -EIO;
/* (2) append to the FAT chain */
@@ -2107,7 +2107,7 @@ static s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir,
fat_attach_count_to_dos_name(p_dosname->name, count);
/* Now dos_name has DOS~????.EXT */
- return FFS_SUCCESS;
+ return 0;
}
/* input : dir, uni_name
@@ -2149,7 +2149,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir,
*entries = num_entries;
- return FFS_SUCCESS;
+ return 0;
}
void get_uni_name_from_dos_entry(struct super_block *sb,
@@ -2269,7 +2269,7 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir,
p_dir->size = (s32)(fid->size >> p_fs->cluster_size_bits);
p_dir->flags = fid->flags;
- return FFS_SUCCESS;
+ return 0;
}
/*
@@ -2347,7 +2347,7 @@ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr)
p_fs->fs_func = &exfat_fs_func;
- return FFS_SUCCESS;
+ return 0;
}
s32 create_dir(struct inode *inode, struct chain_t *p_dir,
@@ -2383,7 +2383,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
return -ENOSPC;
ret = clear_cluster(sb, clu.dir);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
if (p_fs->vol_type == EXFAT) {
@@ -2401,11 +2401,11 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
ret = fs_func->init_dir_entry(sb, &clu, 0, TYPE_DIR, clu.dir,
0);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
ret = fs_func->init_ext_entry(sb, &clu, 0, 1, NULL, &dot_name);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
memcpy(dot_name.name, DOS_PAR_DIR_NAME, DOS_NAME_LENGTH);
@@ -2417,12 +2417,12 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
ret = fs_func->init_dir_entry(sb, &clu, 1, TYPE_DIR,
p_dir->dir, 0);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
ret = p_fs->fs_func->init_ext_entry(sb, &clu, 1, 1, NULL,
&dot_name);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
}
@@ -2430,12 +2430,12 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
/* make sub-dir entry in parent directory */
ret = fs_func->init_dir_entry(sb, p_dir, dentry, TYPE_DIR, clu.dir,
size);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
ret = fs_func->init_ext_entry(sb, p_dir, dentry, num_entries, p_uniname,
&dos_name);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
fid->dir.dir = p_dir->dir;
@@ -2452,7 +2452,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
fid->rwoffset = 0;
fid->hint_last_off = -1;
- return FFS_SUCCESS;
+ return 0;
}
s32 create_file(struct inode *inode, struct chain_t *p_dir,
@@ -2480,12 +2480,12 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir,
*/
ret = fs_func->init_dir_entry(sb, p_dir, dentry, TYPE_FILE | mode,
CLUSTER_32(0), 0);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
ret = fs_func->init_ext_entry(sb, p_dir, dentry, num_entries, p_uniname,
&dos_name);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
fid->dir.dir = p_dir->dir;
@@ -2502,7 +2502,7 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir,
fid->rwoffset = 0;
fid->hint_last_off = -1;
- return FFS_SUCCESS;
+ return 0;
}
void remove_file(struct inode *inode, struct chain_t *p_dir, s32 entry)
@@ -2610,7 +2610,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
ret = fs_func->init_ext_entry(sb, p_dir, newentry,
num_new_entries, p_uniname,
&dos_name);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
fs_func->delete_dir_entry(sb, p_dir, oldentry, 0,
@@ -2629,14 +2629,14 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
ret = fs_func->init_ext_entry(sb, p_dir, oldentry,
num_new_entries, p_uniname,
&dos_name);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
fs_func->delete_dir_entry(sb, p_dir, oldentry, num_new_entries,
num_old_entries);
}
- return FFS_SUCCESS;
+ return 0;
}
s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
@@ -2732,7 +2732,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
ret = fs_func->init_ext_entry(sb, p_newdir, newentry, num_new_entries,
p_uniname, &dos_name);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
return ret;
fs_func->delete_dir_entry(sb, p_olddir, oldentry, 0, num_old_entries);
@@ -2743,7 +2743,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
fid->entry = newentry;
- return FFS_SUCCESS;
+ return 0;
}
/*
@@ -2766,7 +2766,7 @@ int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh,
if (!p_fs->dev_ejected) {
ret = bdev_read(sb, sec, bh, 1, read);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
p_fs->dev_ejected = 1;
}
@@ -2795,7 +2795,7 @@ int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh,
if (!p_fs->dev_ejected) {
ret = bdev_write(sb, sec, bh, 1, sync);
- if (ret != FFS_SUCCESS)
+ if (ret != 0)
p_fs->dev_ejected = 1;
}
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 0ce27a6babee..89462ac669c4 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -373,7 +373,7 @@ static int ffsMountVol(struct super_block *sb)
sb_set_blocksize(sb, p_bd->sector_size);
/* read Sector 0 */
- if (sector_read(sb, 0, &tmp_bh, 1) != FFS_SUCCESS) {
+ if (sector_read(sb, 0, &tmp_bh, 1) != 0) {
ret = -EIO;
goto out;
}
@@ -446,7 +446,7 @@ static int ffsMountVol(struct super_block *sb)
static int ffsUmountVol(struct super_block *sb)
{
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
- int err = FFS_SUCCESS;
+ int err = 0;
pr_info("[EXFAT] trying to unmount...\n");
@@ -487,7 +487,7 @@ static int ffsUmountVol(struct super_block *sb)
static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info)
{
- int err = FFS_SUCCESS;
+ int err = 0;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
/* check the validity of pointer parameters */
@@ -517,7 +517,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info)
static int ffsSyncVol(struct super_block *sb, bool do_sync)
{
- int err = FFS_SUCCESS;
+ int err = 0;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
/* acquire the lock for file system critical section */
@@ -768,13 +768,13 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
if ((offset == 0) && (oneblkread == p_bd->sector_size)) {
if (sector_read(sb, LogSector, &tmp_bh, 1) !=
- FFS_SUCCESS)
+ 0)
goto err_out;
memcpy((char *)buffer + read_bytes,
(char *)tmp_bh->b_data, (s32)oneblkread);
} else {
if (sector_read(sb, LogSector, &tmp_bh, 1) !=
- FFS_SUCCESS)
+ 0)
goto err_out;
memcpy((char *)buffer + read_bytes,
(char *)tmp_bh->b_data + offset,
@@ -844,7 +844,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
if (count == 0) {
if (wcount)
*wcount = 0;
- ret = FFS_SUCCESS;
+ ret = 0;
goto out;
}
@@ -953,12 +953,12 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
if ((offset == 0) && (oneblkwrite == p_bd->sector_size)) {
if (sector_read(sb, LogSector, &tmp_bh, 0) !=
- FFS_SUCCESS)
+ 0)
goto err_out;
memcpy((char *)tmp_bh->b_data,
(char *)buffer + write_bytes, (s32)oneblkwrite);
if (sector_write(sb, LogSector, tmp_bh, 0) !=
- FFS_SUCCESS) {
+ 0) {
brelse(tmp_bh);
goto err_out;
}
@@ -966,18 +966,18 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid,
if ((offset > 0) ||
((fid->rwoffset + oneblkwrite) < fid->size)) {
if (sector_read(sb, LogSector, &tmp_bh, 1) !=
- FFS_SUCCESS)
+ 0)
goto err_out;
} else {
if (sector_read(sb, LogSector, &tmp_bh, 0) !=
- FFS_SUCCESS)
+ 0)
goto err_out;
}
memcpy((char *)tmp_bh->b_data + offset,
(char *)buffer + write_bytes, (s32)oneblkwrite);
if (sector_write(sb, LogSector, tmp_bh, 0) !=
- FFS_SUCCESS) {
+ 0) {
brelse(tmp_bh);
goto err_out;
}
@@ -1091,7 +1091,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size)
}
if (old_size <= new_size) {
- ret = FFS_SUCCESS;
+ ret = 0;
goto out;
}
@@ -1310,7 +1310,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
ret = move_file(new_parent_inode, &olddir, dentry, &newdir,
&uni_name, fid);
- if ((ret == FFS_SUCCESS) && new_inode) {
+ if ((ret == 0) && new_inode) {
/* delete entries of new_dir */
ep = get_entry_in_dir(sb, p_dir, new_entry, NULL);
if (!ep)
@@ -1341,7 +1341,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
{
s32 dentry;
- int ret = FFS_SUCCESS;
+ int ret = 0;
struct chain_t dir, clu_to_free;
struct dentry_t *ep;
struct super_block *sb = inode->i_sb;
@@ -1405,7 +1405,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid)
static int ffsSetAttr(struct inode *inode, u32 attr)
{
u32 type;
- int ret = FFS_SUCCESS;
+ int ret = 0;
sector_t sector = 0;
struct dentry_t *ep;
struct super_block *sb = inode->i_sb;
@@ -1417,7 +1417,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
if (fid->attr == attr) {
if (p_fs->dev_ejected)
return -EIO;
- return FFS_SUCCESS;
+ return 0;
}
if (is_dir) {
@@ -1425,7 +1425,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
(fid->entry == -1)) {
if (p_fs->dev_ejected)
return -EIO;
- return FFS_SUCCESS;
+ return 0;
}
}
@@ -1494,7 +1494,7 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info)
{
sector_t sector = 0;
s32 count;
- int ret = FFS_SUCCESS;
+ int ret = 0;
struct chain_t dir;
struct uni_name_t uni_name;
struct timestamp_t tm;
@@ -1646,7 +1646,7 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info)
static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info)
{
sector_t sector = 0;
- int ret = FFS_SUCCESS;
+ int ret = 0;
struct timestamp_t tm;
struct dentry_t *ep, *ep2;
struct entry_set_cache_t *es = NULL;
@@ -1665,7 +1665,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info)
(fid->entry == -1)) {
if (p_fs->dev_ejected)
ret = -EIO;
- ret = FFS_SUCCESS;
+ ret = 0;
goto out;
}
}
@@ -1736,7 +1736,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
s32 num_clusters, num_alloced;
bool modified = false;
u32 last_clu;
- int ret = FFS_SUCCESS;
+ int ret = 0;
sector_t sector = 0;
struct chain_t new_clu;
struct dentry_t *ep;
@@ -1889,7 +1889,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu)
static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid)
{
- int ret = FFS_SUCCESS;
+ int ret = 0;
struct chain_t dir;
struct uni_name_t uni_name;
struct super_block *sb = inode->i_sb;
@@ -1930,7 +1930,7 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid)
static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
{
int i, dentry, clu_offset;
- int ret = FFS_SUCCESS;
+ int ret = 0;
s32 dentries_per_clu, dentries_per_clu_bits = 0;
u32 type;
sector_t sector;
@@ -2129,7 +2129,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry)
static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid)
{
s32 dentry;
- int ret = FFS_SUCCESS;
+ int ret = 0;
struct chain_t dir, clu_to_free;
struct super_block *sb = inode->i_sb;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
--
2.23.0
On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:
> The code had its own non-standard FFS_FOO return codes. Go through
> and convert them all the kernel standard -EFOO codes.
>
> Valdis Kletnieks (15):
> staging: exfat: Clean up return codes - FFS_FULL
> staging: exfat: Clean up return codes - FFS_NOTFOUND
> staging: exfat: Clean up return codes - FFS_DIRBUSY
> staging: exfat: Clean up return codes - FFS_PERMISSIONERR
> staging: exfat: Clean up return codes - FFS_NAMETOOLONG
> staging: exfat: Clean up return codes - FFS_FILEEXIST
> staging: exfat: Clean up return codes - FFS_INVALIDPATH
> staging: exfat: Clean up return code - FFS_MEMORYERR
> staging: exfat: Clean up return codes - FFS_FORMATERR
> staging: exfat: Clean up return codes - FFS_MEDIAERR
> staging: exfat: Clean up return codes - FFS_EOF
> staging: exfat: Clean up return codes - FFS_INVALIDFID
> staging: exfat: Clean up return codes - FFS_ERROR
> staging: exfat: Clean up return codes - remove unused codes
> staging: exfat: Clean up return codes - FFS_SUCCESS
All well and good, but does converting the error code from
positive to negative have any impact on any of the code
paths that use these return values?
if (error > 0)
vs
if (error < 0)
?
If you've gone through all the return tests,
then it would be nice to say so.
Convert FFS_EOF to return 0 for a zero-length read() as per 'man 2 read'.
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 1 -
drivers/staging/exfat/exfat_super.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index df7b99707aed..3ff7293fedd2 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -217,7 +217,6 @@ static inline u16 get_row_index(u16 i)
#define FFS_INVALIDFID 8
#define FFS_NOTOPENED 12
#define FFS_MAXOPENED 13
-#define FFS_EOF 15
#define FFS_ERROR 19
#define NUM_UPCASE 2918
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index a5c85dafefb4..a0c28fd8824b 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -717,7 +717,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
if (count == 0) {
if (rcount)
*rcount = 0;
- ret = FFS_EOF;
+ ret = 0;
goto out;
}
--
2.23.0
Convert FFS_FORMATERR to -EFSCORRUPTED
Signed-off-by: Valdis Kletnieks <[email protected]>
---
drivers/staging/exfat/exfat.h | 3 ++-
drivers/staging/exfat/exfat_core.c | 4 ++--
drivers/staging/exfat/exfat_super.c | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 2588a6cbe552..7ca187e77cbe 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -30,6 +30,8 @@
#undef DEBUG
#endif
+#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
+
#define DENTRY_SIZE 32 /* dir entry size */
#define DENTRY_SIZE_BITS 5
@@ -209,7 +211,6 @@ static inline u16 get_row_index(u16 i)
/* return values */
#define FFS_SUCCESS 0
#define FFS_MEDIAERR 1
-#define FFS_FORMATERR 2
#define FFS_MOUNTED 3
#define FFS_NOTMOUNTED 4
#define FFS_ALIGNMENTERR 5
diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c
index fa2bf18b4a14..39c103e73b63 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -205,7 +205,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
return FFS_MEDIAERR;
}
- return FFS_FORMATERR;
+ return -EFSCORRUPTED;
}
void free_alloc_bitmap(struct super_block *sb)
@@ -2309,7 +2309,7 @@ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr)
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
if (p_bpb->num_fats == 0)
- return FFS_FORMATERR;
+ return -EFSCORRUPTED;
p_fs->sectors_per_clu = 1 << p_bpb->sectors_per_clu_bits;
p_fs->sectors_per_clu_bits = p_bpb->sectors_per_clu_bits;
diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 5b35e3683605..161971c80c02 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -384,7 +384,7 @@ static int ffsMountVol(struct super_block *sb)
if (GET16_A(p_pbr->signature) != PBR_SIGNATURE) {
brelse(tmp_bh);
bdev_close(sb);
- ret = FFS_FORMATERR;
+ ret = -EFSCORRUPTED;
goto out;
}
--
2.23.0
On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:
> Just replace FFS_SUCCESS with a literal 0.
[]
> diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c
[]
> @@ -214,7 +214,7 @@ static u8 *FAT_getblk(struct super_block *sb, sector_t sec)
>
> FAT_cache_insert_hash(sb, bp);
>
> - if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) {
> + if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) {
Probably nicer to just drop the != 0
> diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
[]
> @@ -768,13 +768,13 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer,
>
> if ((offset == 0) && (oneblkread == p_bd->sector_size)) {
> if (sector_read(sb, LogSector, &tmp_bh, 1) !=
> - FFS_SUCCESS)
> + 0)
especially for these split line tests
On Thu, 24 Oct 2019 09:23:24 -0700, Joe Perches said:
> All well and good, but does converting the error code from
> positive to negative have any impact on any of the code
> paths that use these return values?
>
> if (error > 0)
> vs
> if (error < 0)
I was keeping an eye open for that, and didn't see any.
An interesting case is the FFS_EOF patch, which fixes an actual bug. If you did
a read for length 0, it would return FFS_EOF (==15) - which would be
interpreted as the number of bytes returned by read().
On Thu, Oct 24, 2019 at 11:53:20AM -0400, Valdis Kletnieks wrote:
> Convert FFS_FORMATERR to -EFSCORRUPTED
>
> Signed-off-by: Valdis Kletnieks <[email protected]>
> ---
> drivers/staging/exfat/exfat.h | 3 ++-
> drivers/staging/exfat/exfat_core.c | 4 ++--
> drivers/staging/exfat/exfat_super.c | 2 +-
> 3 files changed, 5 insertions(+), 4 deletions(-)
This causes build errors, maybe because I didn't take your other series.
So I'm stopping here, please rebase and resend.
thanks,
greg k-h