Skip to content

Commit 4e3299e

Browse files
zx2c4Al Viro
authored andcommitted
fs: do not compare against ->llseek
Now vfs_llseek() can simply check for FMODE_LSEEK; if it's set, we know that ->llseek() won't be NULL and if it's not we should just fail with -ESPIPE. A couple of other places where we used to check for special values of ->llseek() (somewhat inconsistently) switched to checking FMODE_LSEEK. Signed-off-by: Jason A. Donenfeld <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent e747815 commit 4e3299e

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

fs/coredump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,9 @@ static int __dump_skip(struct coredump_params *cprm, size_t nr)
816816
{
817817
static char zeroes[PAGE_SIZE];
818818
struct file *file = cprm->file;
819-
if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
819+
if (file->f_mode & FMODE_LSEEK) {
820820
if (dump_interrupted() ||
821-
file->f_op->llseek(file, nr, SEEK_CUR) < 0)
821+
vfs_llseek(file, nr, SEEK_CUR) < 0)
822822
return 0;
823823
cprm->pos += nr;
824824
return 1;

fs/overlayfs/copy_up.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old,
226226
/* Couldn't clone, so now we try to copy the data */
227227

228228
/* Check if lower fs supports seek operation */
229-
if (old_file->f_mode & FMODE_LSEEK &&
230-
old_file->f_op->llseek)
229+
if (old_file->f_mode & FMODE_LSEEK)
231230
skip_hole = true;
232231

233232
while (len) {

fs/read_write.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,9 @@ EXPORT_SYMBOL(default_llseek);
290290

291291
loff_t vfs_llseek(struct file *file, loff_t offset, int whence)
292292
{
293-
loff_t (*fn)(struct file *, loff_t, int);
294-
295-
fn = no_llseek;
296-
if (file->f_mode & FMODE_LSEEK) {
297-
if (file->f_op->llseek)
298-
fn = file->f_op->llseek;
299-
}
300-
return fn(file, offset, whence);
293+
if (!(file->f_mode & FMODE_LSEEK))
294+
return -ESPIPE;
295+
return file->f_op->llseek(file, offset, whence);
301296
}
302297
EXPORT_SYMBOL(vfs_llseek);
303298

0 commit comments

Comments
 (0)