Commit 288db830 authored by Brian Kocoloski's avatar Brian Kocoloski

update vfs interface for newer kernels

parent 443ab412
...@@ -228,16 +228,21 @@ file_read(struct file * file_ptr, ...@@ -228,16 +228,21 @@ file_read(struct file * file_ptr,
size_t length, size_t length,
loff_t offset) loff_t offset)
{ {
ssize_t ret; ssize_t ret;
mm_segment_t old_fs;
old_fs = get_fs();
set_fs(get_ds());
ret = vfs_read(file_ptr, buffer, length, &offset); #if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
{
mm_segment_t old_fs = get_fs();
set_fs(get_ds());
set_fs(old_fs); ret = vfs_read(file_ptr, buffer, length, &offset);
set_fs(old_fs);
}
#else
ret = kernel_read(file_ptr, buffer, length, &offset);
#endif
if (ret <= 0) { if (ret <= 0) {
printk(KERN_ERR "sys_read of %p for %lu bytes at offset %lld failed (ret=%ld)\n", file_ptr, length, offset, ret); printk(KERN_ERR "sys_read of %p for %lu bytes at offset %lld failed (ret=%ld)\n", file_ptr, length, offset, ret);
} }
...@@ -252,16 +257,20 @@ file_write(struct file * file_ptr, ...@@ -252,16 +257,20 @@ file_write(struct file * file_ptr,
size_t length, size_t length,
loff_t offset) loff_t offset)
{ {
mm_segment_t old_fs; ssize_t ret;
ssize_t ret;
old_fs = get_fs(); #if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
set_fs(get_ds()); {
mm_segment_t old_fs = get_fs();
set_fs(get_ds());
ret = vfs_write(file_ptr, buffer, length, &offset); ret = vfs_write(file_ptr, buffer, length, &offset);
set_fs(old_fs); set_fs(old_fs);
}
#else
ret = kernel_write(file_ptr, buffer, length, &offset);
#endif
if (ret <= 0) { if (ret <= 0) {
printk(KERN_ERR "sys_write for %lu bytes at offset %lld failed (ret=%ld)\n", length, offset, ret); printk(KERN_ERR "sys_write for %lu bytes at offset %lld failed (ret=%ld)\n", length, offset, ret);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment