Skip to content

Commit

Permalink
exFAT (Samsung OSRC) bump to 1.2.5 + our stuff = 1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dorimanx committed Dec 29, 2013
1 parent e67ad2c commit 7bfc673
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
44 changes: 30 additions & 14 deletions exfat_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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--;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion exfat_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion exfat_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
/* */
/************************************************************************/

#define EXFAT_VERSION "1.2.6"
#define EXFAT_VERSION "1.2.7"

0 comments on commit 7bfc673

Please sign in to comment.