Skip to content

Commit

Permalink
Add support for linux-2.6.31.
Browse files Browse the repository at this point in the history
  • Loading branch information
Red54 committed Aug 28, 2015
1 parent 3e2ccbc commit d2baca1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
8 changes: 8 additions & 0 deletions exfat_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,21 @@
/*----------------------------------------------------------------------*/

/* FAT cache */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
DECLARE_MUTEX(f_sem);
#else
DEFINE_SEMAPHORE(f_sem);
#endif
BUF_CACHE_T FAT_cache_array[FAT_CACHE_SIZE];
BUF_CACHE_T FAT_cache_lru_list;
BUF_CACHE_T FAT_cache_hash_list[FAT_CACHE_HASH_SIZE];

/* buf cache */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
DECLARE_MUTEX(b_sem);
#else
DEFINE_SEMAPHORE(b_sem);
#endif
BUF_CACHE_T buf_cache_array[BUF_CACHE_SIZE];
BUF_CACHE_T buf_cache_lru_list;
BUF_CACHE_T buf_cache_hash_list[BUF_CACHE_HASH_SIZE];
4 changes: 4 additions & 0 deletions exfat_oal.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
/* */
/*======================================================================*/

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
DECLARE_MUTEX(z_sem);
#else
DEFINE_SEMAPHORE(z_sem);
#endif

s32 sm_init(struct semaphore *sm)
{
Expand Down
64 changes: 64 additions & 0 deletions exfat_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ static struct inode *exfat_build_inode(struct super_block *sb, FILE_ID_T *fid, l
static void exfat_detach(struct inode *inode);
static void exfat_attach(struct inode *inode, loff_t i_pos);
static inline unsigned long exfat_hash(loff_t i_pos);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
static int exfat_write_inode(struct inode *inode, int wait);
#else
static int exfat_write_inode(struct inode *inode, struct writeback_control *wbc);
#endif
static void exfat_write_super(struct super_block *sb);

static void __lock_super(struct super_block *sb)
Expand Down Expand Up @@ -338,6 +342,8 @@ static unsigned int exfat_striptail_len(const struct qstr *qstr)

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
static int exfat_d_hash(const struct dentry *dentry, struct qstr *qstr)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
static int exfat_d_hash(struct dentry *dentry, struct qstr *qstr)
#else
static int exfat_d_hash(const struct dentry *dentry, const struct inode *inode,
struct qstr *qstr)
Expand All @@ -349,6 +355,8 @@ static int exfat_d_hash(const struct dentry *dentry, const struct inode *inode,

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
static int exfat_d_hashi(const struct dentry *dentry, struct qstr *qstr)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
static int exfat_d_hashi(struct dentry *dentry, struct qstr *qstr)
#else
static int exfat_d_hashi(const struct dentry *dentry, const struct inode *inode,
struct qstr *qstr)
Expand All @@ -373,6 +381,8 @@ static int exfat_d_hashi(const struct dentry *dentry, const struct inode *inode,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
static int exfat_cmpi(const struct dentry *parent, const struct dentry *dentry,
unsigned int len, const char *str, const struct qstr *name)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
static int exfat_cmpi(struct dentry *parent, struct qstr *a, struct qstr *b)
#else
static int exfat_cmpi(const struct dentry *parent, const struct inode *pinode,
const struct dentry *dentry, const struct inode *inode,
Expand All @@ -382,13 +392,26 @@ static int exfat_cmpi(const struct dentry *parent, const struct inode *pinode,
struct nls_table *t = EXFAT_SB(parent->d_sb)->nls_io;
unsigned int alen, blen;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
alen = exfat_striptail_len(a);
blen = exfat_striptail_len(b);
#else
alen = exfat_striptail_len(name);
blen = __exfat_striptail_len(len, str);
#endif
if (alen == blen) {
if (t == NULL) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
if (strncasecmp(a->name, b->name, alen) == 0)
#else
if (strncasecmp(name->name, str, alen) == 0)
#endif
return 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
} else if (nls_strnicmp(t, a->name, b->name, alen) == 0)
#else
} else if (nls_strnicmp(t, name->name, str, alen) == 0)
#endif
return 0;
}
return 1;
Expand All @@ -397,6 +420,9 @@ static int exfat_cmpi(const struct dentry *parent, const struct inode *pinode,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
static int exfat_cmp(const struct dentry *parent, const struct dentry *dentry,
unsigned int len, const char *str, const struct qstr *name)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
static int exfat_cmp(struct dentry *parent, struct qstr *a,
struct qstr *b)
#else
static int exfat_cmp(const struct dentry *parent, const struct inode *pinode,
const struct dentry *dentry, const struct inode *inode,
Expand All @@ -405,10 +431,19 @@ static int exfat_cmp(const struct dentry *parent, const struct inode *pinode,
{
unsigned int alen, blen;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
alen = exfat_striptail_len(a);
blen = exfat_striptail_len(b);
#else
alen = exfat_striptail_len(name);
blen = __exfat_striptail_len(len, str);
#endif
if (alen == blen) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
if (strncmp(a->name, b->name, alen) == 0)
#else
if (strncmp(name->name, str, alen) == 0)
#endif
return 0;
}
return 1;
Expand Down Expand Up @@ -617,13 +652,22 @@ static long exfat_generic_ioctl(struct file *filp,
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
static int exfat_file_fsync(struct file *filp, struct dentry *dentry,
int datasync)
#else
static int exfat_file_fsync(struct file *filp, int datasync)
#endif
{
struct inode *inode = filp->f_mapping->host;
struct super_block *sb = inode->i_sb;
int res, err;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
res = simple_fsync(filp, dentry, datasync);
#else
res = generic_file_fsync(filp, datasync);
#endif
err = FsSyncVol(sb, 1);

return res ? res : err;
Expand Down Expand Up @@ -1140,7 +1184,13 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
err2 = write_inode_now(inode, 1);
err = (err) ? (err) : (err2);
if (!err)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
err = wait_on_page_writeback_range(mapping,
start >> PAGE_CACHE_SHIFT,
(start + count - 1) >> PAGE_CACHE_SHIFT);
#else
err = filemap_fdatawait_range(mapping, start, start + count - 1);
#endif
}
return err;
}
Expand Down Expand Up @@ -1205,7 +1255,9 @@ static int exfat_setattr(struct dentry *dentry, struct iattr *attr)
struct inode *inode = dentry->d_inode;
unsigned int ia_valid;
int error;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)
loff_t old_size;
#endif

DPRINTK("exfat_setattr entered\n");

Expand Down Expand Up @@ -1842,7 +1894,11 @@ static struct inode *exfat_build_inode(struct super_block *sb,

static int exfat_sync_inode(struct inode *inode)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
return exfat_write_inode(inode, 0);
#else
return exfat_write_inode(inode, NULL);
#endif
}

static struct inode *exfat_alloc_inode(struct super_block *sb)
Expand All @@ -1869,7 +1925,11 @@ static void exfat_destroy_inode(struct inode *inode)
kmem_cache_free(exfat_inode_cachep, EXFAT_I(inode));
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
static int exfat_write_inode(struct inode *inode, int wait)
#else
static int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
#endif
{
struct super_block *sb = inode->i_sb;
struct exfat_sb_info *sbi = EXFAT_SB(sb);
Expand Down Expand Up @@ -2296,13 +2356,15 @@ static int exfat_read_root(struct inode *inode)
return 0;
}

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)
static void setup_dops(struct super_block *sb)
{
if (EXFAT_SB(sb)->options.casesensitive == 0)
sb->s_d_op = &exfat_ci_dentry_ops;
else
sb->s_d_op = &exfat_dentry_ops;
}
#endif

static int exfat_fill_super(struct super_block *sb, void *data, int silent)
{
Expand Down Expand Up @@ -2333,7 +2395,9 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent)
if (error)
goto out_fail;

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)
setup_dops(sb);
#endif

error = -EIO;
sb_min_blocksize(sb, 512);
Expand Down

0 comments on commit d2baca1

Please sign in to comment.