]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
new helper: fixed_size_llseek()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 16 Jun 2013 16:27:42 +0000 (20:27 +0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 29 Jun 2013 08:57:26 +0000 (12:57 +0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/read_write.c
include/linux/fs.h

index f646c8b565b913d5cbe02a5dafb2aba5a4b163ef..782dfc3acebcf038db62116ab65536fc28ed8a6a 100644 (file)
@@ -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
index 1db01c13ddce0cc85a3403da6b45a1bb61c4585f..803b7fa2520a088378940acc79f45977e0ddca37 100644 (file)
@@ -2428,6 +2428,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);