Permalink
Browse files

drivers: Update exFat filesystem to 1.2.4

  • Loading branch information...
Samsung-OSRC authored and AndreiLux committed Aug 16, 2013
1 parent 0daa2f2 commit 6ceb0a6901d09fbf17aa305def557e37fbcc185f
View
@@ -70,6 +70,16 @@ static UINT32 get_current_msec(void)
#define PRINT_TIME(n)
#endif
+static void __set_sb_dirty(struct super_block *sb)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
+ sb->s_dirt = 1;
+#else
+ struct exfat_sb_info *sbi = EXFAT_SB(sb);
+ sbi->s_dirt = 1;
+#endif
+}
+
extern UINT8 uni_upcase[];
static UINT8 name_buf[MAX_PATH_LENGTH *MAX_CHARSET_SIZE];
@@ -279,7 +289,8 @@ INT32 ffsUmountVol(struct super_block *sb)
bdev_close(sb);
if (p_fs->dev_ejected) {
- printk("[EXFAT] failed to unmount. device's already ejected.\n");
+ printk( "[EXFAT] unmounted with media errors. "
+ "device's already ejected.\n");
return FFS_MEDIAERR;
}
@@ -815,6 +826,22 @@ INT32 ffsTruncateFile(struct inode *inode, UINT64 old_size, UINT64 new_size)
return FFS_SUCCESS;
}
+static void update_parent_info( FILE_ID_T *fid, struct inode *parent_inode)
+{
+ FS_INFO_T *p_fs = &(EXFAT_SB(parent_inode->i_sb)->fs_info);
+ FILE_ID_T *parent_fid = &(EXFAT_I(parent_inode)->fid);
+
+ if (unlikely((parent_fid->flags != fid->dir.flags)
+ || (parent_fid->size != (fid->dir.size<<p_fs->cluster_size_bits))
+ || (parent_fid->start_clu != fid->dir.dir))) {
+
+ fid->dir.dir = parent_fid->start_clu;
+ fid->dir.flags = parent_fid->flags;
+ fid->dir.size = ((parent_fid->size + (p_fs->cluster_size-1))
+ >> p_fs->cluster_size_bits);
+ }
+}
+
INT32 ffsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry)
{
INT32 ret;
@@ -834,6 +861,8 @@ INT32 ffsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *
if ((new_path == NULL) || (STRLEN(new_path) == 0))
return FFS_ERROR;
+ update_parent_info(fid, old_parent_inode);
+
olddir.dir = fid->dir.dir;
olddir.size = fid->dir.size;
olddir.flags = fid->dir.flags;
@@ -857,6 +886,9 @@ INT32 ffsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *
ret = FFS_MEDIAERR;
new_fid = &EXFAT_I(new_inode)->fid;
+
+ update_parent_info(new_fid, new_parent_inode);
+
p_dir = &(new_fid->dir);
new_entry = new_fid->entry;
ep = get_entry_in_dir(sb, p_dir, new_entry, NULL);
@@ -1706,7 +1738,7 @@ INT32 fat_alloc_cluster(struct super_block *sb, INT32 num_alloc, CHAIN_T *p_chai
else if (new_clu >= p_fs->num_clusters)
new_clu = 2;
- sb->s_dirt = 1;
+ __set_sb_dirty(sb);
p_chain->dir = CLUSTER_32(~0);
@@ -1760,8 +1792,8 @@ INT32 exfat_alloc_cluster(struct super_block *sb, INT32 num_alloc, CHAIN_T *p_ch
p_chain->flags = 0x01;
}
- sb->s_dirt = 1;
-
+ __set_sb_dirty(sb);
+
p_chain->dir = CLUSTER_32(~0);
while ((new_clu = test_alloc_bitmap(sb, hint_clu-2)) != CLUSTER_32(~0)) {
@@ -1826,9 +1858,7 @@ void fat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, INT32 do_relse)
if ((p_chain->dir == CLUSTER_32(0)) || (p_chain->dir == CLUSTER_32(~0)))
return;
-
- sb->s_dirt = 1;
-
+ __set_sb_dirty(sb);
clu = p_chain->dir;
if (p_chain->size <= 0)
@@ -1876,8 +1906,7 @@ void exfat_free_cluster(struct super_block *sb, CHAIN_T *p_chain, INT32 do_relse
return;
}
- sb->s_dirt = 1;
-
+ __set_sb_dirty(sb);
clu = p_chain->dir;
if (p_chain->flags == 0x03) {
@@ -4868,7 +4897,7 @@ INT32 sector_write(struct super_block *sb, UINT32 sec, struct buffer_head *bh, I
if (!p_fs->dev_ejected) {
ret = bdev_write(sb, sec, bh, 1, sync);
- if (ret)
+ if (ret != FFS_SUCCESS)
p_fs->dev_ejected = TRUE;
}
@@ -64,6 +64,7 @@ INT32 bdev_close(struct super_block *sb)
INT32 bdev_read(struct super_block *sb, UINT32 secno, struct buffer_head **bh, UINT32 num_secs, INT32 read)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
+ FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
#if EXFAT_CONFIG_KERNEL_DEBUG
struct exfat_sb_info *sbi = EXFAT_SB(sb);
long flags = sbi->debug_flags;
@@ -82,7 +83,8 @@ INT32 bdev_read(struct super_block *sb, UINT32 secno, struct buffer_head **bh, U
if (*bh) return(FFS_SUCCESS);
- WARN_ONCE(1, "[EXFAT] No bh, device seems wrong or to be ejected.\n");
+ WARN(!p_fs->dev_ejected,
+ "[EXFAT] No bh, device seems wrong or to be ejected.\n");
return(FFS_MEDIAERR);
}
@@ -92,6 +94,7 @@ INT32 bdev_write(struct super_block *sb, UINT32 secno, struct buffer_head *bh, U
INT32 count;
struct buffer_head *bh2;
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
+ FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
#if EXFAT_CONFIG_KERNEL_DEBUG
struct exfat_sb_info *sbi = EXFAT_SB(sb);
long flags = sbi->debug_flags;
@@ -114,7 +117,7 @@ INT32 bdev_write(struct super_block *sb, UINT32 secno, struct buffer_head *bh, U
bh2 = __getblk(sb->s_bdev, secno, count);
if (bh2 == NULL)
- return (FFS_MEDIAERR);
+ goto no_bh;
lock_buffer(bh2);
MEMCPY(bh2->b_data, bh->b_data, count);
@@ -123,12 +126,18 @@ INT32 bdev_write(struct super_block *sb, UINT32 secno, struct buffer_head *bh, U
unlock_buffer(bh2);
if (sync && (sync_dirty_buffer(bh2) != 0)) {
__brelse(bh2);
- return (FFS_MEDIAERR);
+ goto no_bh;
}
__brelse(bh2);
}
return(FFS_SUCCESS);
+
+no_bh:
+ WARN(!p_fs->dev_ejected,
+ "[EXFAT] No bh, device seems wrong or to be ejected.\n");
+
+ return (FFS_MEDIAERR);
}
INT32 bdev_sync(struct super_block *sb)
Oops, something went wrong.

2 comments on commit 6ceb0a6

@sorgelig

This comment has been minimized.

Show comment Hide comment
@sorgelig

sorgelig Aug 17, 2013

Contributor

Wow! where you've got exFAT sources??

Contributor

sorgelig replied Aug 17, 2013

Wow! where you've got exFAT sources??

@AndreiLux

This comment has been minimized.

Show comment Hide comment
@AndreiLux

AndreiLux Aug 17, 2013

Owner

http://opensource.samsung.com/reception/receptionSub.do?method=search&searchValue=exfat

Samsung open-sourced their driver after a bit of drama.

About a month ago some idiot published a leaked version of exFat on Github (The code was floating around since April). I notified him about the nature of the code, but he rebutted me with some stupid counter-arguments.

He annoyed me so I sent a nice e-mail off to Samsung and GPL-Legal.

Results:

http://lwn.net/Articles/560424/
http://sfconservancy.org/news/2013/aug/16/exfat-samsung/

In the end Samsung published their code as it was in the wild already (And they were actually infringing GPL themselves).

Owner

AndreiLux replied Aug 17, 2013

http://opensource.samsung.com/reception/receptionSub.do?method=search&searchValue=exfat

Samsung open-sourced their driver after a bit of drama.

About a month ago some idiot published a leaked version of exFat on Github (The code was floating around since April). I notified him about the nature of the code, but he rebutted me with some stupid counter-arguments.

He annoyed me so I sent a nice e-mail off to Samsung and GPL-Legal.

Results:

http://lwn.net/Articles/560424/
http://sfconservancy.org/news/2013/aug/16/exfat-samsung/

In the end Samsung published their code as it was in the wild already (And they were actually infringing GPL themselves).

Please sign in to comment.