From 7bfc673fc1927bcb67192aea5461fb2c2f361dcd Mon Sep 17 00:00:00 2001 From: Dorimanx Date: Sun, 29 Dec 2013 17:15:01 +0200 Subject: [PATCH] exFAT (Samsung OSRC) bump to 1.2.5 + our stuff = 1.2.7 https://gerrit.omnirom.org/#/c/3937/ --- exfat_core.c | 44 ++++++++++++++++++++++++++++++-------------- exfat_super.c | 2 +- exfat_version.h | 2 +- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/exfat_core.c b/exfat_core.c index a487a2b..c99897f 100644 --- a/exfat_core.c +++ b/exfat_core.c @@ -596,6 +596,8 @@ s32 ffsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, u64 count, u num_alloced = p_fs->fs_func->alloc_cluster(sb, num_alloc, &new_clu); if (num_alloced == 0) break; + else if (num_alloced < 0) + return FFS_MEDIAERR; /* (2) append to the FAT chain */ if (last_clu == CLUSTER_32(~0)) { @@ -1334,7 +1336,9 @@ s32 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 < 1) + if (num_alloced < 0) + return FFS_MEDIAERR; + else if (num_alloced == 0) return FFS_FULL; /* (2) append to the FAT chain */ @@ -1805,16 +1809,19 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain) for (i = 2; i < p_fs->num_clusters; i++) { if (FAT_read(sb, new_clu, &read_clu) != 0) - return 0; + return -1; if (read_clu == CLUSTER_32(0)) { - FAT_write(sb, new_clu, CLUSTER_32(~0)); + if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0) + return -1; num_clusters++; if (p_chain->dir == CLUSTER_32(~0)) p_chain->dir = new_clu; - else - FAT_write(sb, last_clu, new_clu); + else { + if (FAT_write(sb, last_clu, new_clu) < 0) + return -1; + } last_clu = new_clu; @@ -1866,18 +1873,22 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, CHAIN_T *p_chain) } if (set_alloc_bitmap(sb, new_clu-2) != FFS_SUCCESS) - return 0; + return -1; num_clusters++; - if (p_chain->flags == 0x01) - FAT_write(sb, new_clu, CLUSTER_32(~0)); + if (p_chain->flags == 0x01) { + if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0) + return -1; + } if (p_chain->dir == CLUSTER_32(~0)) { p_chain->dir = new_clu; } else { - if (p_chain->flags == 0x01) - FAT_write(sb, last_clu, new_clu); + if (p_chain->flags == 0x01) { + if (FAT_write(sb, last_clu, new_clu) < 0) + return -1; + } } last_clu = new_clu; @@ -1939,7 +1950,8 @@ void fat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, s32 do_relse) if (FAT_read(sb, clu, &clu) == -1) break; - FAT_write(sb, prev, CLUSTER_32(0)); + if (FAT_write(sb, prev, CLUSTER_32(0)) < 0) + break; num_clusters++; } while (clu != CLUSTER_32(~0)); @@ -2097,7 +2109,8 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len) return; while (len > 1) { - FAT_write(sb, chain, chain+1); + if (FAT_write(sb, chain, chain+1) < 0) + break; chain++; len--; } @@ -3606,7 +3619,8 @@ s32 find_empty_entry(struct inode *inode, CHAIN_T *p_dir, s32 num_entries) p_fs->hint_uentry.clu.flags = 0x01; } if (clu.flags == 0x01) - FAT_write(sb, last_clu, clu.dir); + if (FAT_write(sb, last_clu, clu.dir) < 0) + return -1; if (p_fs->hint_uentry.entry == -1) { p_fs->hint_uentry.dir = p_dir->dir; @@ -4674,7 +4688,9 @@ s32 create_dir(struct inode *inode, CHAIN_T *p_dir, UNI_NAME_T *p_uniname, FILE_ /* (1) allocate a cluster */ ret = p_fs->fs_func->alloc_cluster(sb, 1, &clu); - if (ret < 1) + if (ret < 0) + return FFS_MEDIAERR; + else if (ret == 0) return FFS_FULL; ret = clear_cluster(sb, clu.dir); diff --git a/exfat_super.c b/exfat_super.c index 23d2733..eea339b 100644 --- a/exfat_super.c +++ b/exfat_super.c @@ -1781,7 +1781,7 @@ static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf) info.FreeClusters = info.NumClusters - info.UsedClusters; if (p_fs->dev_ejected) - return -EIO; + printk("[EXFAT] statfs on device is ejected\n"); } buf->f_type = sb->s_magic; diff --git a/exfat_version.h b/exfat_version.h index 2ad6a8f..ac24433 100644 --- a/exfat_version.h +++ b/exfat_version.h @@ -16,4 +16,4 @@ /* */ /************************************************************************/ -#define EXFAT_VERSION "1.2.6" +#define EXFAT_VERSION "1.2.7"