Skip to content

Commit 0ead004

Browse files
committed
Merge pull request zen-kernel#73 from Red54/patch-1
Add support for linux-2.6.31.
2 parents 3e2ccbc + d2baca1 commit 0ead004

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

exfat_data.c

+8
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,21 @@
5757
/*----------------------------------------------------------------------*/
5858

5959
/* FAT cache */
60+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
61+
DECLARE_MUTEX(f_sem);
62+
#else
6063
DEFINE_SEMAPHORE(f_sem);
64+
#endif
6165
BUF_CACHE_T FAT_cache_array[FAT_CACHE_SIZE];
6266
BUF_CACHE_T FAT_cache_lru_list;
6367
BUF_CACHE_T FAT_cache_hash_list[FAT_CACHE_HASH_SIZE];
6468

6569
/* buf cache */
70+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
71+
DECLARE_MUTEX(b_sem);
72+
#else
6673
DEFINE_SEMAPHORE(b_sem);
74+
#endif
6775
BUF_CACHE_T buf_cache_array[BUF_CACHE_SIZE];
6876
BUF_CACHE_T buf_cache_lru_list;
6977
BUF_CACHE_T buf_cache_hash_list[BUF_CACHE_HASH_SIZE];

exfat_oal.c

+4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555
/* */
5656
/*======================================================================*/
5757

58+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
59+
DECLARE_MUTEX(z_sem);
60+
#else
5861
DEFINE_SEMAPHORE(z_sem);
62+
#endif
5963

6064
s32 sm_init(struct semaphore *sm)
6165
{

exfat_super.c

+64
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ static struct inode *exfat_build_inode(struct super_block *sb, FILE_ID_T *fid, l
218218
static void exfat_detach(struct inode *inode);
219219
static void exfat_attach(struct inode *inode, loff_t i_pos);
220220
static inline unsigned long exfat_hash(loff_t i_pos);
221+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
222+
static int exfat_write_inode(struct inode *inode, int wait);
223+
#else
221224
static int exfat_write_inode(struct inode *inode, struct writeback_control *wbc);
225+
#endif
222226
static void exfat_write_super(struct super_block *sb);
223227

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

339343
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
340344
static int exfat_d_hash(const struct dentry *dentry, struct qstr *qstr)
345+
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
346+
static int exfat_d_hash(struct dentry *dentry, struct qstr *qstr)
341347
#else
342348
static int exfat_d_hash(const struct dentry *dentry, const struct inode *inode,
343349
struct qstr *qstr)
@@ -349,6 +355,8 @@ static int exfat_d_hash(const struct dentry *dentry, const struct inode *inode,
349355

350356
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
351357
static int exfat_d_hashi(const struct dentry *dentry, struct qstr *qstr)
358+
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
359+
static int exfat_d_hashi(struct dentry *dentry, struct qstr *qstr)
352360
#else
353361
static int exfat_d_hashi(const struct dentry *dentry, const struct inode *inode,
354362
struct qstr *qstr)
@@ -373,6 +381,8 @@ static int exfat_d_hashi(const struct dentry *dentry, const struct inode *inode,
373381
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
374382
static int exfat_cmpi(const struct dentry *parent, const struct dentry *dentry,
375383
unsigned int len, const char *str, const struct qstr *name)
384+
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
385+
static int exfat_cmpi(struct dentry *parent, struct qstr *a, struct qstr *b)
376386
#else
377387
static int exfat_cmpi(const struct dentry *parent, const struct inode *pinode,
378388
const struct dentry *dentry, const struct inode *inode,
@@ -382,13 +392,26 @@ static int exfat_cmpi(const struct dentry *parent, const struct inode *pinode,
382392
struct nls_table *t = EXFAT_SB(parent->d_sb)->nls_io;
383393
unsigned int alen, blen;
384394

395+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
396+
alen = exfat_striptail_len(a);
397+
blen = exfat_striptail_len(b);
398+
#else
385399
alen = exfat_striptail_len(name);
386400
blen = __exfat_striptail_len(len, str);
401+
#endif
387402
if (alen == blen) {
388403
if (t == NULL) {
404+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
405+
if (strncasecmp(a->name, b->name, alen) == 0)
406+
#else
389407
if (strncasecmp(name->name, str, alen) == 0)
408+
#endif
390409
return 0;
410+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
411+
} else if (nls_strnicmp(t, a->name, b->name, alen) == 0)
412+
#else
391413
} else if (nls_strnicmp(t, name->name, str, alen) == 0)
414+
#endif
392415
return 0;
393416
}
394417
return 1;
@@ -397,6 +420,9 @@ static int exfat_cmpi(const struct dentry *parent, const struct inode *pinode,
397420
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
398421
static int exfat_cmp(const struct dentry *parent, const struct dentry *dentry,
399422
unsigned int len, const char *str, const struct qstr *name)
423+
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
424+
static int exfat_cmp(struct dentry *parent, struct qstr *a,
425+
struct qstr *b)
400426
#else
401427
static int exfat_cmp(const struct dentry *parent, const struct inode *pinode,
402428
const struct dentry *dentry, const struct inode *inode,
@@ -405,10 +431,19 @@ static int exfat_cmp(const struct dentry *parent, const struct inode *pinode,
405431
{
406432
unsigned int alen, blen;
407433

434+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
435+
alen = exfat_striptail_len(a);
436+
blen = exfat_striptail_len(b);
437+
#else
408438
alen = exfat_striptail_len(name);
409439
blen = __exfat_striptail_len(len, str);
440+
#endif
410441
if (alen == blen) {
442+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
443+
if (strncmp(a->name, b->name, alen) == 0)
444+
#else
411445
if (strncmp(name->name, str, alen) == 0)
446+
#endif
412447
return 0;
413448
}
414449
return 1;
@@ -617,13 +652,22 @@ static long exfat_generic_ioctl(struct file *filp,
617652
}
618653

619654
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
655+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
656+
static int exfat_file_fsync(struct file *filp, struct dentry *dentry,
657+
int datasync)
658+
#else
620659
static int exfat_file_fsync(struct file *filp, int datasync)
660+
#endif
621661
{
622662
struct inode *inode = filp->f_mapping->host;
623663
struct super_block *sb = inode->i_sb;
624664
int res, err;
625665

666+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
667+
res = simple_fsync(filp, dentry, datasync);
668+
#else
626669
res = generic_file_fsync(filp, datasync);
670+
#endif
627671
err = FsSyncVol(sb, 1);
628672

629673
return res ? res : err;
@@ -1140,7 +1184,13 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
11401184
err2 = write_inode_now(inode, 1);
11411185
err = (err) ? (err) : (err2);
11421186
if (!err)
1187+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
1188+
err = wait_on_page_writeback_range(mapping,
1189+
start >> PAGE_CACHE_SHIFT,
1190+
(start + count - 1) >> PAGE_CACHE_SHIFT);
1191+
#else
11431192
err = filemap_fdatawait_range(mapping, start, start + count - 1);
1193+
#endif
11441194
}
11451195
return err;
11461196
}
@@ -1205,7 +1255,9 @@ static int exfat_setattr(struct dentry *dentry, struct iattr *attr)
12051255
struct inode *inode = dentry->d_inode;
12061256
unsigned int ia_valid;
12071257
int error;
1258+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)
12081259
loff_t old_size;
1260+
#endif
12091261

12101262
DPRINTK("exfat_setattr entered\n");
12111263

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

18431895
static int exfat_sync_inode(struct inode *inode)
18441896
{
1897+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
1898+
return exfat_write_inode(inode, 0);
1899+
#else
18451900
return exfat_write_inode(inode, NULL);
1901+
#endif
18461902
}
18471903

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

1928+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
1929+
static int exfat_write_inode(struct inode *inode, int wait)
1930+
#else
18721931
static int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
1932+
#endif
18731933
{
18741934
struct super_block *sb = inode->i_sb;
18751935
struct exfat_sb_info *sbi = EXFAT_SB(sb);
@@ -2296,13 +2356,15 @@ static int exfat_read_root(struct inode *inode)
22962356
return 0;
22972357
}
22982358

2359+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)
22992360
static void setup_dops(struct super_block *sb)
23002361
{
23012362
if (EXFAT_SB(sb)->options.casesensitive == 0)
23022363
sb->s_d_op = &exfat_ci_dentry_ops;
23032364
else
23042365
sb->s_d_op = &exfat_dentry_ops;
23052366
}
2367+
#endif
23062368

23072369
static int exfat_fill_super(struct super_block *sb, void *data, int silent)
23082370
{
@@ -2333,7 +2395,9 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent)
23332395
if (error)
23342396
goto out_fail;
23352397

2398+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)
23362399
setup_dops(sb);
2400+
#endif
23372401

23382402
error = -EIO;
23392403
sb_min_blocksize(sb, 512);

0 commit comments

Comments
 (0)