• Home
  • Raw
  • Download

Lines Matching refs:file

37 static inline bool unsigned_offsets(struct file *file)  in unsigned_offsets()  argument
39 return file->f_mode & FMODE_UNSIGNED_OFFSET; in unsigned_offsets()
54 loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize) in vfs_setpos() argument
56 if (offset < 0 && !unsigned_offsets(file)) in vfs_setpos()
61 if (offset != file->f_pos) { in vfs_setpos()
62 file->f_pos = offset; in vfs_setpos()
63 file->f_version = 0; in vfs_setpos()
86 generic_file_llseek_size(struct file *file, loff_t offset, int whence, in generic_file_llseek_size() argument
101 return file->f_pos; in generic_file_llseek_size()
107 spin_lock(&file->f_lock); in generic_file_llseek_size()
108 offset = vfs_setpos(file, file->f_pos + offset, maxsize); in generic_file_llseek_size()
109 spin_unlock(&file->f_lock); in generic_file_llseek_size()
130 return vfs_setpos(file, offset, maxsize); in generic_file_llseek_size()
144 loff_t generic_file_llseek(struct file *file, loff_t offset, int whence) in generic_file_llseek() argument
146 struct inode *inode = file->f_mapping->host; in generic_file_llseek()
148 return generic_file_llseek_size(file, offset, whence, in generic_file_llseek()
162 loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t size) in fixed_size_llseek() argument
166 return generic_file_llseek_size(file, offset, whence, in fixed_size_llseek()
181 loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence) in no_seek_end_llseek() argument
185 return generic_file_llseek_size(file, offset, whence, in no_seek_end_llseek()
201 loff_t no_seek_end_llseek_size(struct file *file, loff_t offset, int whence, loff_t size) in no_seek_end_llseek_size() argument
205 return generic_file_llseek_size(file, offset, whence, in no_seek_end_llseek_size()
224 loff_t noop_llseek(struct file *file, loff_t offset, int whence) in noop_llseek() argument
226 return file->f_pos; in noop_llseek()
230 loff_t no_llseek(struct file *file, loff_t offset, int whence) in no_llseek() argument
236 loff_t default_llseek(struct file *file, loff_t offset, int whence) in default_llseek() argument
238 struct inode *inode = file_inode(file); in default_llseek()
248 retval = file->f_pos; in default_llseek()
251 offset += file->f_pos; in default_llseek()
278 if (offset >= 0 || unsigned_offsets(file)) { in default_llseek()
279 if (offset != file->f_pos) { in default_llseek()
280 file->f_pos = offset; in default_llseek()
281 file->f_version = 0; in default_llseek()
291 loff_t vfs_llseek(struct file *file, loff_t offset, int whence) in vfs_llseek() argument
293 loff_t (*fn)(struct file *, loff_t, int); in vfs_llseek()
296 if (file->f_mode & FMODE_LSEEK) { in vfs_llseek()
297 if (file->f_op->llseek) in vfs_llseek()
298 fn = file->f_op->llseek; in vfs_llseek()
300 return fn(file, offset, whence); in vfs_llseek()
308 if (!f.file) in ksys_lseek()
313 loff_t res = vfs_llseek(f.file, offset, whence); in ksys_lseek()
343 if (!f.file) in SYSCALL_DEFINE5()
350 offset = vfs_llseek(f.file, ((loff_t) offset_high << 32) | offset_low, in SYSCALL_DEFINE5()
365 int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t count) in rw_verify_area() argument
370 inode = file_inode(file); in rw_verify_area()
382 if (!unsigned_offsets(file)) in rw_verify_area()
387 if (!unsigned_offsets(file)) in rw_verify_area()
392 retval = locks_mandatory_area(inode, file, pos, pos + count - 1, in rw_verify_area()
399 return security_file_permission(file, in rw_verify_area()
403 static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) in new_sync_read()
421 ssize_t __vfs_read(struct file *file, char __user *buf, size_t count, in __vfs_read() argument
424 if (file->f_op->read) in __vfs_read()
425 return file->f_op->read(file, buf, count, pos); in __vfs_read()
426 else if (file->f_op->read_iter) in __vfs_read()
427 return new_sync_read(file, buf, count, pos); in __vfs_read()
432 ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) in kernel_read() argument
440 result = vfs_read(file, (void __user *)buf, count, pos); in kernel_read()
446 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) in vfs_read() argument
450 if (!(file->f_mode & FMODE_READ)) in vfs_read()
452 if (!(file->f_mode & FMODE_CAN_READ)) in vfs_read()
457 ret = rw_verify_area(READ, file, pos, count); in vfs_read()
461 ret = __vfs_read(file, buf, count, pos); in vfs_read()
463 fsnotify_access(file); in vfs_read()
474 static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos) in new_sync_write()
492 static ssize_t __vfs_write(struct file *file, const char __user *p, in __vfs_write() argument
495 if (file->f_op->write) in __vfs_write()
496 return file->f_op->write(file, p, count, pos); in __vfs_write()
497 else if (file->f_op->write_iter) in __vfs_write()
498 return new_sync_write(file, p, count, pos); in __vfs_write()
503 ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos) in __kernel_write() argument
509 if (!(file->f_mode & FMODE_CAN_WRITE)) in __kernel_write()
517 ret = __vfs_write(file, p, count, pos); in __kernel_write()
520 fsnotify_modify(file); in __kernel_write()
528 ssize_t kernel_write(struct file *file, const void *buf, size_t count, in kernel_write() argument
537 res = vfs_write(file, (__force const char __user *)buf, count, pos); in kernel_write()
544 ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) in vfs_write() argument
548 if (!(file->f_mode & FMODE_WRITE)) in vfs_write()
550 if (!(file->f_mode & FMODE_CAN_WRITE)) in vfs_write()
555 ret = rw_verify_area(WRITE, file, pos, count); in vfs_write()
559 file_start_write(file); in vfs_write()
560 ret = __vfs_write(file, buf, count, pos); in vfs_write()
562 fsnotify_modify(file); in vfs_write()
566 file_end_write(file); in vfs_write()
574 static inline loff_t *file_ppos(struct file *file) in file_ppos() argument
576 return file->f_mode & FMODE_STREAM ? NULL : &file->f_pos; in file_ppos()
584 if (f.file) { in ksys_read()
585 loff_t pos, *ppos = file_ppos(f.file); in ksys_read()
590 ret = vfs_read(f.file, buf, count, ppos); in ksys_read()
592 f.file->f_pos = pos; in ksys_read()
608 if (f.file) { in ksys_write()
609 loff_t pos, *ppos = file_ppos(f.file); in ksys_write()
614 ret = vfs_write(f.file, buf, count, ppos); in ksys_write()
616 f.file->f_pos = pos; in ksys_write()
639 if (f.file) { in ksys_pread64()
641 if (f.file->f_mode & FMODE_PREAD) in ksys_pread64()
642 ret = vfs_read(f.file, buf, count, &pos); in ksys_pread64()
665 if (f.file) { in ksys_pwrite64()
667 if (f.file->f_mode & FMODE_PWRITE) in ksys_pwrite64()
668 ret = vfs_write(f.file, buf, count, &pos); in ksys_pwrite64()
681 static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, in do_iter_readv_writev()
704 static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter, in do_loop_readv_writev()
917 static ssize_t do_iter_read(struct file *file, struct iov_iter *iter, in do_iter_read() argument
923 if (!(file->f_mode & FMODE_READ)) in do_iter_read()
925 if (!(file->f_mode & FMODE_CAN_READ)) in do_iter_read()
931 ret = rw_verify_area(READ, file, pos, tot_len); in do_iter_read()
935 if (file->f_op->read_iter) in do_iter_read()
936 ret = do_iter_readv_writev(file, iter, pos, READ, flags); in do_iter_read()
938 ret = do_loop_readv_writev(file, iter, pos, READ, flags); in do_iter_read()
941 fsnotify_access(file); in do_iter_read()
945 ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos, in vfs_iter_read() argument
948 if (!file->f_op->read_iter) in vfs_iter_read()
950 return do_iter_read(file, iter, ppos, flags); in vfs_iter_read()
954 static ssize_t do_iter_write(struct file *file, struct iov_iter *iter, in do_iter_write() argument
960 if (!(file->f_mode & FMODE_WRITE)) in do_iter_write()
962 if (!(file->f_mode & FMODE_CAN_WRITE)) in do_iter_write()
968 ret = rw_verify_area(WRITE, file, pos, tot_len); in do_iter_write()
972 if (file->f_op->write_iter) in do_iter_write()
973 ret = do_iter_readv_writev(file, iter, pos, WRITE, flags); in do_iter_write()
975 ret = do_loop_readv_writev(file, iter, pos, WRITE, flags); in do_iter_write()
977 fsnotify_modify(file); in do_iter_write()
981 ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos, in vfs_iter_write() argument
984 if (!file->f_op->write_iter) in vfs_iter_write()
986 return do_iter_write(file, iter, ppos, flags); in vfs_iter_write()
990 ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, in vfs_readv() argument
1000 ret = do_iter_read(file, &iter, pos, flags); in vfs_readv()
1007 static ssize_t vfs_writev(struct file *file, const struct iovec __user *vec, in vfs_writev() argument
1017 file_start_write(file); in vfs_writev()
1018 ret = do_iter_write(file, &iter, pos, flags); in vfs_writev()
1019 file_end_write(file); in vfs_writev()
1031 if (f.file) { in do_readv()
1032 loff_t pos, *ppos = file_ppos(f.file); in do_readv()
1037 ret = vfs_readv(f.file, vec, vlen, ppos, flags); in do_readv()
1039 f.file->f_pos = pos; in do_readv()
1055 if (f.file) { in do_writev()
1056 loff_t pos, *ppos = file_ppos(f.file); in do_writev()
1061 ret = vfs_writev(f.file, vec, vlen, ppos, flags); in do_writev()
1063 f.file->f_pos = pos; in do_writev()
1089 if (f.file) { in do_preadv()
1091 if (f.file->f_mode & FMODE_PREAD) in do_preadv()
1092 ret = vfs_readv(f.file, vec, vlen, &pos, flags); in do_preadv()
1112 if (f.file) { in do_pwritev()
1114 if (f.file->f_mode & FMODE_PWRITE) in do_pwritev()
1115 ret = vfs_writev(f.file, vec, vlen, &pos, flags); in do_pwritev()
1178 static size_t compat_readv(struct file *file, in compat_readv() argument
1189 ret = do_iter_read(file, &iter, pos, flags); in compat_readv()
1206 if (!f.file) in do_compat_readv()
1208 pos = f.file->f_pos; in do_compat_readv()
1209 ret = compat_readv(f.file, vec, vlen, &pos, flags); in do_compat_readv()
1211 f.file->f_pos = pos; in do_compat_readv()
1234 if (!f.file) in do_compat_preadv64()
1237 if (f.file->f_mode & FMODE_PREAD) in do_compat_preadv64()
1238 ret = compat_readv(f.file, vec, vlen, &pos, flags); in do_compat_preadv64()
1286 static size_t compat_writev(struct file *file, in compat_writev() argument
1297 file_start_write(file); in compat_writev()
1298 ret = do_iter_write(file, &iter, pos, flags); in compat_writev()
1299 file_end_write(file); in compat_writev()
1316 if (!f.file) in do_compat_writev()
1318 pos = f.file->f_pos; in do_compat_writev()
1319 ret = compat_writev(f.file, vec, vlen, &pos, flags); in do_compat_writev()
1321 f.file->f_pos = pos; in do_compat_writev()
1343 if (!f.file) in do_compat_pwritev64()
1346 if (f.file->f_mode & FMODE_PWRITE) in do_compat_pwritev64()
1347 ret = compat_writev(f.file, vec, vlen, &pos, flags); in do_compat_pwritev64()
1411 if (!in.file) in do_sendfile()
1413 if (!(in.file->f_mode & FMODE_READ)) in do_sendfile()
1417 pos = in.file->f_pos; in do_sendfile()
1420 if (!(in.file->f_mode & FMODE_PREAD)) in do_sendfile()
1423 retval = rw_verify_area(READ, in.file, &pos, count); in do_sendfile()
1434 if (!out.file) in do_sendfile()
1436 if (!(out.file->f_mode & FMODE_WRITE)) in do_sendfile()
1438 in_inode = file_inode(in.file); in do_sendfile()
1439 out_inode = file_inode(out.file); in do_sendfile()
1440 out_pos = out.file->f_pos; in do_sendfile()
1441 retval = rw_verify_area(WRITE, out.file, &out_pos, count); in do_sendfile()
1463 if (in.file->f_flags & O_NONBLOCK) in do_sendfile()
1466 file_start_write(out.file); in do_sendfile()
1467 retval = do_splice_direct(in.file, &pos, out.file, &out_pos, count, fl); in do_sendfile()
1468 file_end_write(out.file); in do_sendfile()
1473 fsnotify_access(in.file); in do_sendfile()
1474 fsnotify_modify(out.file); in do_sendfile()
1475 out.file->f_pos = out_pos; in do_sendfile()
1479 in.file->f_pos = pos; in do_sendfile()
1592 ssize_t generic_copy_file_range(struct file *file_in, loff_t pos_in, in generic_copy_file_range()
1593 struct file *file_out, loff_t pos_out, in generic_copy_file_range()
1601 static ssize_t do_copy_file_range(struct file *file_in, loff_t pos_in, in do_copy_file_range()
1602 struct file *file_out, loff_t pos_out, in do_copy_file_range()
1628 ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, in vfs_copy_file_range()
1629 struct file *file_out, loff_t pos_out, in vfs_copy_file_range()
1704 if (!f_in.file) in SYSCALL_DEFINE6()
1708 if (!f_out.file) in SYSCALL_DEFINE6()
1716 pos_in = f_in.file->f_pos; in SYSCALL_DEFINE6()
1723 pos_out = f_out.file->f_pos; in SYSCALL_DEFINE6()
1726 ret = vfs_copy_file_range(f_in.file, pos_in, f_out.file, pos_out, len, in SYSCALL_DEFINE6()
1736 f_in.file->f_pos = pos_in; in SYSCALL_DEFINE6()
1743 f_out.file->f_pos = pos_out; in SYSCALL_DEFINE6()
1755 static int remap_verify_area(struct file *file, loff_t pos, loff_t len, in remap_verify_area() argument
1758 struct inode *inode = file_inode(file); in remap_verify_area()
1770 retval = locks_mandatory_area(inode, file, pos, end, in remap_verify_area()
1776 return security_file_permission(file, write ? MAY_WRITE : MAY_READ); in remap_verify_area()
1949 int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, in generic_remap_file_range_prep()
1950 struct file *file_out, loff_t pos_out, in generic_remap_file_range_prep()
2032 loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, in do_clone_file_range()
2033 struct file *file_out, loff_t pos_out, in do_clone_file_range()
2074 loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, in vfs_clone_file_range()
2075 struct file *file_out, loff_t pos_out, in vfs_clone_file_range()
2090 static bool allow_file_dedupe(struct file *file) in allow_file_dedupe() argument
2094 if (file->f_mode & FMODE_WRITE) in allow_file_dedupe()
2096 if (uid_eq(current_fsuid(), file_inode(file)->i_uid)) in allow_file_dedupe()
2098 if (!inode_permission(file_inode(file), MAY_WRITE)) in allow_file_dedupe()
2103 loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, in vfs_dedupe_file_range_one()
2104 struct file *dst_file, loff_t dst_pos, in vfs_dedupe_file_range_one()
2150 int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) in vfs_dedupe_file_range() argument
2153 struct inode *src = file_inode(file); in vfs_dedupe_file_range()
2161 if (!(file->f_mode & FMODE_READ)) in vfs_dedupe_file_range()
2176 if (!file->f_op->remap_file_range) in vfs_dedupe_file_range()
2179 ret = remap_verify_area(file, off, len, false); in vfs_dedupe_file_range()
2198 struct file *dst_file = dst_fd.file; in vfs_dedupe_file_range()
2210 deduped = vfs_dedupe_file_range_one(file, off, dst_file, in vfs_dedupe_file_range()