summaryrefslogtreecommitdiff
path: root/backport
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2015-12-20 22:11:00 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2015-12-21 00:52:40 +0100
commitbfb1f574048a4690f99382015cf7197a04f91217 (patch)
tree1f2900420738b8ed0ec4620a26b8cec0d3c0a4bc /backport
parentd50eb5385789f2534652b4762acfaea6f8a2c212 (diff)
backport: add no_seek_end_llseek()
no_seek_end_llseek() was added with kernel 4.5 in commit fb1d259e4 "new helpers: no_seek_end_llseek{,_size}()". This is used by wlcore. generic_file_llseek_size() is only available in kernel >= 3.2. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'backport')
-rw-r--r--backport/backport-include/linux/fs.h6
-rw-r--r--backport/compat/backport-4.5.c27
2 files changed, 33 insertions, 0 deletions
diff --git a/backport/backport-include/linux/fs.h b/backport/backport-include/linux/fs.h
index 2790db6e..42fb1e96 100644
--- a/backport/backport-include/linux/fs.h
+++ b/backport/backport-include/linux/fs.h
@@ -43,4 +43,10 @@ static inline struct inode *file_inode(struct file *f)
} while(0)
#endif /* replace_fops */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) && \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+#define no_seek_end_llseek LINUX_BACKPORT(no_seek_end_llseek)
+extern loff_t no_seek_end_llseek(struct file *, loff_t, int);
+#endif /* < 4.5 && >= 3.2 */
+
#endif /* _COMPAT_LINUX_FS_H */
diff --git a/backport/compat/backport-4.5.c b/backport/compat/backport-4.5.c
index e8f9b127..13c0a714 100644
--- a/backport/compat/backport-4.5.c
+++ b/backport/compat/backport-4.5.c
@@ -11,6 +11,7 @@
#include <linux/leds.h>
#include <linux/export.h>
#include <linux/errno.h>
+#include <linux/fs.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
int led_set_brightness_sync(struct led_classdev *led_cdev,
@@ -31,3 +32,29 @@ int led_set_brightness_sync(struct led_classdev *led_cdev,
}
EXPORT_SYMBOL_GPL(led_set_brightness_sync);
#endif /* >= 3.19 */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+/**
+ * no_seek_end_llseek - llseek implementation for fixed-sized devices
+ * @file: file structure to seek on
+ * @offset: file offset to seek to
+ * @whence: type of seek
+ *
+ */
+loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
+{
+ switch (whence) {
+ case SEEK_SET: case SEEK_CUR:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ return generic_file_llseek_size(file, offset, whence,
+ ~0ULL, 0);
+#else
+ return generic_file_llseek_size(file, offset, whence,
+ ~0ULL);
+#endif
+ default:
+ return -EINVAL;
+ }
+}
+EXPORT_SYMBOL_GPL(no_seek_end_llseek);
+#endif /* >= 3.2 */