X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=include%2Flinux%2Ffile_compat.h;h=2fd6e5fc8779035b601f218210e4d567398c344d;hb=99d6d8dce6e1eca0928c72cf09677b244a90cb46;hp=916514566a23807fcd83ca4431f48ab72151259a;hpb=4a69112941e2f63d4551e5baae4bdee487e2f9f2;p=mirror_spl-debian.git diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h index 9165145..2fd6e5f 100644 --- a/include/linux/file_compat.h +++ b/include/linux/file_compat.h @@ -26,6 +26,7 @@ #define _SPL_FILE_COMPAT_H #include +#include #ifdef HAVE_FDTABLE_HEADER #include #endif @@ -70,6 +71,46 @@ spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len) return (error); } +static inline ssize_t +spl_kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos) +{ +#if defined(HAVE_KERNEL_WRITE_PPOS) + return (kernel_write(file, buf, count, pos)); +#else + mm_segment_t saved_fs; + ssize_t ret; + + saved_fs = get_fs(); + set_fs(get_ds()); + + ret = vfs_write(file, (__force const char __user *)buf, count, pos); + + set_fs(saved_fs); + + return (ret); +#endif +} + +static inline ssize_t +spl_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) +{ +#if defined(HAVE_KERNEL_READ_PPOS) + return (kernel_read(file, buf, count, pos)); +#else + mm_segment_t saved_fs; + ssize_t ret; + + saved_fs = get_fs(); + set_fs(get_ds()); + + ret = vfs_read(file, (void __user *)buf, count, pos); + + set_fs(saved_fs); + + return (ret); +#endif +} + #ifdef HAVE_2ARGS_VFS_FSYNC #define spl_filp_fsync(fp, sync) vfs_fsync(fp, sync) #else