Guest User

Samsung Exfat 1.2.5 patch (from https://gerrit.omnirom.org/)

a guest
Jun 17th, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.24 KB | None | 0 0
  1. --- a/exfat.c   2013-08-16 12:38:00.000000000 +0700
  2. +++ b/exfat.c   2013-12-22 19:35:32.000000000 +0700
  3. @@ -595,6 +595,8 @@
  4.             num_alloced = p_fs->fs_func->alloc_cluster(sb, num_alloc, &new_clu);
  5.             if (num_alloced == 0)
  6.                 break;
  7. +           else if (num_alloced < 0)
  8. +               return FFS_MEDIAERR;
  9.  
  10.             if (last_clu == CLUSTER_32(~0)) {
  11.                 if (new_clu.flags == 0x01)
  12. @@ -1302,7 +1304,9 @@
  13.         new_clu.flags = fid->flags;
  14.  
  15.         num_alloced = p_fs->fs_func->alloc_cluster(sb, 1, &new_clu);
  16. -       if (num_alloced < 1)
  17. +       if (num_alloced < 0)
  18. +           return FFS_MEDIAERR;
  19. +       else if (num_alloced == 0)
  20.             return FFS_FULL;
  21.  
  22.         if (last_clu == CLUSTER_32(~0)) {
  23. @@ -1744,16 +1748,19 @@
  24.  
  25.     for (i = 2; i < p_fs->num_clusters; i++) {
  26.         if (FAT_read(sb, new_clu, &read_clu) != 0)
  27. -           return 0;
  28. +           return -1;
  29.  
  30.         if (read_clu == CLUSTER_32(0)) {
  31. -           FAT_write(sb, new_clu, CLUSTER_32(~0));
  32. +           if(FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0)
  33. +               return -1;
  34.             num_clusters++;
  35.  
  36.             if (p_chain->dir == CLUSTER_32(~0))
  37.                 p_chain->dir = new_clu;
  38. -           else
  39. -               FAT_write(sb, last_clu, new_clu);
  40. +           else {
  41. +               if(FAT_write(sb, last_clu, new_clu) < 0)
  42. +                   return -1;
  43. +           }
  44.  
  45.             last_clu = new_clu;
  46.  
  47. @@ -1805,18 +1812,22 @@
  48.         }
  49.  
  50.         if (set_alloc_bitmap(sb, new_clu-2) != FFS_SUCCESS)
  51. -           return 0;
  52. +           return -1;
  53.  
  54.         num_clusters++;
  55.  
  56. -       if (p_chain->flags == 0x01)
  57. -           FAT_write(sb, new_clu, CLUSTER_32(~0));
  58. +       if (p_chain->flags == 0x01) {
  59. +           if(FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0)
  60. +               return -1;
  61. +       }
  62.  
  63.         if (p_chain->dir == CLUSTER_32(~0)) {
  64.             p_chain->dir = new_clu;
  65.         } else {
  66. -           if (p_chain->flags == 0x01)
  67. -               FAT_write(sb, last_clu, new_clu);
  68. +           if (p_chain->flags == 0x01) {
  69. +               if(FAT_write(sb, last_clu, new_clu) < 0)
  70. +                   return -1;
  71. +           }
  72.         }
  73.         last_clu = new_clu;
  74.  
  75. @@ -1879,7 +1890,8 @@
  76.         if (FAT_read(sb, clu, &clu) == -1)
  77.             break;
  78.  
  79. -       FAT_write(sb, prev, CLUSTER_32(0));
  80. +       if (FAT_write(sb, prev, CLUSTER_32(0)) < 0)
  81. +           break;
  82.         num_clusters++;
  83.  
  84.     } while (clu != CLUSTER_32(~0));
  85. @@ -2039,7 +2051,8 @@
  86.         return;
  87.  
  88.     while (len > 1) {
  89. -       FAT_write(sb, chain, chain+1);
  90. +       if (FAT_write(sb, chain, chain+1) < 0)
  91. +           break;
  92.         chain++;
  93.         len--;
  94.     }
  95. @@ -3507,7 +3520,8 @@
  96.             p_fs->hint_uentry.clu.flags = 0x01;
  97.         }
  98.         if (clu.flags == 0x01)
  99. -           FAT_write(sb, last_clu, clu.dir);
  100. +           if(FAT_write(sb, last_clu, clu.dir) < 0)
  101. +               return -1;
  102.  
  103.         if (p_fs->hint_uentry.entry == -1) {
  104.             p_fs->hint_uentry.dir = p_dir->dir;
  105. @@ -4546,9 +4560,11 @@
  106.     clu.flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
  107.  
  108.     ret = p_fs->fs_func->alloc_cluster(sb, 1, &clu);
  109. -   if (ret < 1)
  110. +   if (ret < 0)
  111. +       return FFS_MEDIAERR;
  112. +   else if(ret == 0)
  113.         return FFS_FULL;
  114. -
  115. +  
  116.     ret = clear_cluster(sb, clu.dir);
  117.     if (ret != FFS_SUCCESS)
  118.         return ret;
  119. --- b/exfat_super.c 2013-12-22 19:35:32.000000000 +0700
  120. +++ a/exfat_super.c 2013-08-16 12:53:42.000000000 +0700
  121. @@ -60,6 +60,9 @@
  122.  #include <linux/exportfs.h>
  123.  #include <linux/mount.h>
  124.  #include <linux/vfs.h>
  125. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
  126. +#include <linux/aio.h>
  127. +#endif
  128.  #include <linux/parser.h>
  129.  #include <linux/uio.h>
  130.  #include <linux/writeback.h>
  131. @@ -1405,12 +1402,17 @@
  132.  static struct inode *exfat_iget(struct super_block *sb, loff_t i_pos) {
  133.     struct exfat_sb_info *sbi = EXFAT_SB(sb);
  134.     struct exfat_inode_info *info;
  135. -   struct hlist_node *node;
  136.     struct hlist_head *head = sbi->inode_hashtable + exfat_hash(i_pos);
  137.     struct inode *inode = NULL;
  138. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
  139. +   struct hlist_node *node;
  140.  
  141.     spin_lock(&sbi->inode_hash_lock);
  142.     hlist_for_each_entry(info, node, head, i_hash_fat) {
  143. +#else
  144. +   spin_lock(&sbi->inode_hash_lock);
  145. +   hlist_for_each_entry(info, head, i_hash_fat) {
  146. +#endif
  147.         CHECK_ERR(info->vfs_inode.i_sb != sb);
  148.  
  149.         if (i_pos != info->i_pos)
  150. @@ -1687,7 +1679,7 @@
  151.         info.FreeClusters = info.NumClusters - info.UsedClusters;
  152.  
  153.         if (p_fs->dev_ejected)
  154. -           return -EIO;
  155. +           printk("[EXFAT] statfs on device is ejected\n");
  156.     }
  157.  
  158.     buf->f_type = sb->s_magic;
  159. --- a/exfat_version.h   2013-08-14 14:03:26.000000000 +0700
  160. +++ b/exfat_version.h   2013-12-22 19:35:32.000000000 +0700
  161. @@ -1 +1 @@
  162. -#define EXFAT_VERSION  "1.2.4"
  163. +#define EXFAT_VERSION  "1.2.5"
Add Comment
Please, Sign In to add comment