Skip to content

Commit 1bf9d14

Browse files
author
Al Viro
committed
new helper: fixed_size_llseek()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 0747fdb commit 1bf9d14

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎fs/read_write.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int whence)
144144
}
145145
EXPORT_SYMBOL(generic_file_llseek);
146146

147+
/**
148+
* fixed_size_llseek - llseek implementation for fixed-sized devices
149+
* @file: file structure to seek on
150+
* @offset: file offset to seek to
151+
* @whence: type of seek
152+
* @size: size of the file
153+
*
154+
*/
155+
loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t size)
156+
{
157+
switch (whence) {
158+
case SEEK_SET: case SEEK_CUR: case SEEK_END:
159+
return generic_file_llseek_size(file, offset, whence,
160+
size, size);
161+
default:
162+
return -EINVAL;
163+
}
164+
}
165+
EXPORT_SYMBOL(fixed_size_llseek);
166+
147167
/**
148168
* noop_llseek - No Operation Performed llseek implementation
149169
* @file: file structure to seek on

‎include/linux/fs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,6 +2428,8 @@ extern loff_t no_llseek(struct file *file, loff_t offset, int whence);
24282428
extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence);
24292429
extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
24302430
int whence, loff_t maxsize, loff_t eof);
2431+
extern loff_t fixed_size_llseek(struct file *file, loff_t offset,
2432+
int whence, loff_t size);
24312433
extern int generic_file_open(struct inode * inode, struct file * filp);
24322434
extern int nonseekable_open(struct inode * inode, struct file * filp);
24332435

0 commit comments

Comments
 (0)