Skip to content

Commit

Permalink
Linux 3.16 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ava1ar committed Aug 5, 2014
1 parent 4a12733 commit fe38709
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions exfat_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,10 +1324,17 @@ static int exfat_file_release(struct inode *inode, struct file *filp)

const struct file_operations exfat_file_operations = {
.llseek = generic_file_llseek,
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
.read = do_sync_read,
.write = do_sync_write,
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
#else
.read = new_sync_read,
.write = new_sync_write,
.read_iter = generic_file_read_iter,
.write_iter = generic_file_write_iter,
#endif
.mmap = generic_file_mmap,
.release = exfat_file_release,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
Expand Down Expand Up @@ -1566,9 +1573,14 @@ static int exfat_write_end(struct file *file, struct address_space *mapping,
return err;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
static ssize_t exfat_direct_IO(int rw, struct kiocb *iocb,
const struct iovec *iov,
loff_t offset, unsigned long nr_segs)
#else
static ssize_t exfat_direct_IO(int rw, struct kiocb *iocb,
struct iov_iter *iter, loff_t offset)
#endif
{
struct inode *inode = iocb->ki_filp->f_mapping->host;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
Expand All @@ -1577,18 +1589,28 @@ static ssize_t exfat_direct_IO(int rw, struct kiocb *iocb,
ssize_t ret;

if (rw == WRITE) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
if (EXFAT_I(inode)->mmu_private < (offset + iov_length(iov, nr_segs)))
#else
if (EXFAT_I(inode)->mmu_private < (offset + iov_iter_count(iter)))
#endif
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
ret = blockdev_direct_IO(rw, iocb, inode, iter,
offset, exfat_get_block);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
ret = blockdev_direct_IO(rw, iocb, inode, iov,
offset, nr_segs, exfat_get_block);
#else
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs, exfat_get_block, NULL);
#endif

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
if ((ret < 0) && (rw & WRITE))
exfat_write_failed(mapping, offset+iov_iter_count(iter));
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
if ((ret < 0) && (rw & WRITE))
exfat_write_failed(mapping, offset+iov_length(iov, nr_segs));
#endif
Expand Down

0 comments on commit fe38709

Please sign in to comment.