From c007c75ae0353b632cccaccb11119c0ddd4f1250 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 26 Feb 2014 15:18:41 +0200 Subject: [PATCH] new helper: fixed_size_llseek() Change-Id: Iead39128eb10531a649a0550603083447007bda3 Signed-off-by: Al Viro Git-commit: 1bf9d14dff4a2c4de6152c6f751bdaf6896b68bb Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Signed-off-by: Tatyana Brokhman --- fs/read_write.c | 20 ++++++++++++++++++++ include/linux/fs.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 2cefa417be34..4270004d3d9c 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -144,6 +144,26 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int whence) } EXPORT_SYMBOL(generic_file_llseek); +/** + * fixed_size_llseek - llseek implementation for fixed-sized devices + * @file: file structure to seek on + * @offset: file offset to seek to + * @whence: type of seek + * @size: size of the file + * + */ +loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t size) +{ + switch (whence) { + case SEEK_SET: case SEEK_CUR: case SEEK_END: + return generic_file_llseek_size(file, offset, whence, + size, size); + default: + return -EINVAL; + } +} +EXPORT_SYMBOL(fixed_size_llseek); + /** * noop_llseek - No Operation Performed llseek implementation * @file: file structure to seek on diff --git a/include/linux/fs.h b/include/linux/fs.h index 65c2be22b601..f1431b327131 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2422,6 +2422,8 @@ extern loff_t no_llseek(struct file *file, loff_t offset, int whence); extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence); extern loff_t generic_file_llseek_size(struct file *file, loff_t offset, int whence, loff_t maxsize, loff_t eof); +extern loff_t fixed_size_llseek(struct file *file, loff_t offset, + int whence, loff_t size); extern int generic_file_open(struct inode * inode, struct file * filp); extern int nonseekable_open(struct inode * inode, struct file * filp);