Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfs: introduce noop_llseek()

This is an implementation of ->llseek useable for the rare special case
when userspace expects the seek to succeed but the (device) file is
actually not able to perform the seek. In this case you use noop_llseek()
instead of falling back to the default implementation of ->llseek.

Signed-off-by: Jan Blunck <jblunck@suse.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

jan Blunck and committed by
Linus Torvalds
ae6afc3f 09eeb1f5

+18
+17
fs/read_write.c
··· 97 97 } 98 98 EXPORT_SYMBOL(generic_file_llseek); 99 99 100 + /** 101 + * noop_llseek - No Operation Performed llseek implementation 102 + * @file: file structure to seek on 103 + * @offset: file offset to seek to 104 + * @origin: type of seek 105 + * 106 + * This is an implementation of ->llseek useable for the rare special case when 107 + * userspace expects the seek to succeed but the (device) file is actually not 108 + * able to perform the seek. In this case you use noop_llseek() instead of 109 + * falling back to the default implementation of ->llseek. 110 + */ 111 + loff_t noop_llseek(struct file *file, loff_t offset, int origin) 112 + { 113 + return file->f_pos; 114 + } 115 + EXPORT_SYMBOL(noop_llseek); 116 + 100 117 loff_t no_llseek(struct file *file, loff_t offset, int origin) 101 118 { 102 119 return -ESPIPE;
+1
include/linux/fs.h
··· 2228 2228 2229 2229 extern void 2230 2230 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); 2231 + extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); 2231 2232 extern loff_t no_llseek(struct file *file, loff_t offset, int origin); 2232 2233 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin); 2233 2234 extern loff_t generic_file_llseek_unlocked(struct file *file, loff_t offset,