Inter-revision diff: patch 2

Comparing v1 (message) to v6 (message)

--- v1
+++ v6
@@ -2,15 +2,17 @@
 flags.
 
 Signed-off-by: Milosz Tanski <milosz@adfin.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
 ---
- fs/read_write.c                   | 82 ++++++++++++++++++++++++++++++++-------
- include/linux/syscalls.h          |  6 +++
- include/uapi/asm-generic/unistd.h |  6 ++-
- mm/filemap.c                      |  2 +-
- 4 files changed, 80 insertions(+), 16 deletions(-)
+ fs/read_write.c                   | 172 ++++++++++++++++++++++++++++++--------
+ include/linux/compat.h            |   6 ++
+ include/linux/syscalls.h          |   6 ++
+ include/uapi/asm-generic/unistd.h |   6 +-
+ mm/filemap.c                      |   5 +-
+ 5 files changed, 156 insertions(+), 39 deletions(-)
 
 diff --git a/fs/read_write.c b/fs/read_write.c
-index 9858c06..e3d8451 100644
+index 94b2d34..b1b4bc8 100644
 --- a/fs/read_write.c
 +++ b/fs/read_write.c
 @@ -866,6 +866,8 @@ ssize_t vfs_readv(struct file *file, const struct iovec __user *vec,
@@ -112,7 +114,7 @@
  		fdput(f);
  	}
  
-@@ -979,6 +981,58 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec,
+@@ -979,11 +981,63 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec,
  	return ret;
  }
  
@@ -171,6 +173,242 @@
  #ifdef CONFIG_COMPAT
  
  static ssize_t compat_do_readv_writev(int type, struct file *file,
+ 			       const struct compat_iovec __user *uvector,
+-			       unsigned long nr_segs, loff_t *pos)
++			       unsigned long nr_segs, loff_t *pos, int flags)
+ {
+ 	compat_ssize_t tot_len;
+ 	struct iovec iovstack[UIO_FASTIOV];
+@@ -1017,7 +1071,7 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
+ 
+ 	if (iter_fn)
+ 		ret = do_iter_readv_writev(file, type, iov, nr_segs, tot_len,
+-						pos, iter_fn, 0);
++						pos, iter_fn, flags);
+ 	else if (fnv)
+ 		ret = do_sync_readv_writev(file, iov, nr_segs, tot_len,
+ 						pos, fnv);
+@@ -1041,7 +1095,7 @@ out:
+ 
+ static size_t compat_readv(struct file *file,
+ 			   const struct compat_iovec __user *vec,
+-			   unsigned long vlen, loff_t *pos)
++			   unsigned long vlen, loff_t *pos, int flags)
+ {
+ 	ssize_t ret = -EBADF;
+ 
+@@ -1051,8 +1105,10 @@ static size_t compat_readv(struct file *file,
+ 	ret = -EINVAL;
+ 	if (!(file->f_mode & FMODE_CAN_READ))
+ 		goto out;
++	if (flags & ~0)
++		goto out;
+ 
+-	ret = compat_do_readv_writev(READ, file, vec, vlen, pos);
++	ret = compat_do_readv_writev(READ, file, vec, vlen, pos, flags);
+ 
+ out:
+ 	if (ret > 0)
+@@ -1061,9 +1117,9 @@ out:
+ 	return ret;
+ }
+ 
+-COMPAT_SYSCALL_DEFINE3(readv, compat_ulong_t, fd,
+-		const struct compat_iovec __user *,vec,
+-		compat_ulong_t, vlen)
++static size_t __compat_sys_readv(compat_ulong_t fd,
++				 const struct compat_iovec __user *vec,
++				 compat_ulong_t vlen, int flags)
+ {
+ 	struct fd f = fdget_pos(fd);
+ 	ssize_t ret;
+@@ -1072,16 +1128,24 @@ COMPAT_SYSCALL_DEFINE3(readv, compat_ulong_t, fd,
+ 	if (!f.file)
+ 		return -EBADF;
+ 	pos = f.file->f_pos;
+-	ret = compat_readv(f.file, vec, vlen, &pos);
++	ret = compat_readv(f.file, vec, vlen, &pos, flags);
+ 	if (ret >= 0)
+ 		f.file->f_pos = pos;
+ 	fdput_pos(f);
+ 	return ret;
++
++}
++
++COMPAT_SYSCALL_DEFINE3(readv, compat_ulong_t, fd,
++		const struct compat_iovec __user *,vec,
++		compat_ulong_t, vlen)
++{
++	return __compat_sys_readv(fd, vec, vlen, 0);
+ }
+ 
+ static long __compat_sys_preadv64(unsigned long fd,
+ 				  const struct compat_iovec __user *vec,
+-				  unsigned long vlen, loff_t pos)
++				  unsigned long vlen, loff_t pos, int flags)
+ {
+ 	struct fd f;
+ 	ssize_t ret;
+@@ -1093,7 +1157,7 @@ static long __compat_sys_preadv64(unsigned long fd,
+ 		return -EBADF;
+ 	ret = -ESPIPE;
+ 	if (f.file->f_mode & FMODE_PREAD)
+-		ret = compat_readv(f.file, vec, vlen, &pos);
++		ret = compat_readv(f.file, vec, vlen, &pos, flags);
+ 	fdput(f);
+ 	return ret;
+ }
+@@ -1103,7 +1167,7 @@ COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,
+ 		const struct compat_iovec __user *,vec,
+ 		unsigned long, vlen, loff_t, pos)
+ {
+-	return __compat_sys_preadv64(fd, vec, vlen, pos);
++	return __compat_sys_preadv64(fd, vec, vlen, pos, 0);
+ }
+ #endif
+ 
+@@ -1113,12 +1177,25 @@ COMPAT_SYSCALL_DEFINE5(preadv, compat_ulong_t, fd,
+ {
+ 	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
+ 
+-	return __compat_sys_preadv64(fd, vec, vlen, pos);
++	return __compat_sys_preadv64(fd, vec, vlen, pos, 0);
++}
++
++COMPAT_SYSCALL_DEFINE6(preadv2, compat_ulong_t, fd,
++		const struct compat_iovec __user *,vec,
++		compat_ulong_t, vlen, u32, pos_low, u32, pos_high,
++		int, flags)
++{
++	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
++
++	if (pos == -1)
++		return __compat_sys_readv(fd, vec, vlen, flags);
++
++	return __compat_sys_preadv64(fd, vec, vlen, pos, flags);
+ }
+ 
+ static size_t compat_writev(struct file *file,
+ 			    const struct compat_iovec __user *vec,
+-			    unsigned long vlen, loff_t *pos)
++			    unsigned long vlen, loff_t *pos, int flags)
+ {
+ 	ssize_t ret = -EBADF;
+ 
+@@ -1128,8 +1205,10 @@ static size_t compat_writev(struct file *file,
+ 	ret = -EINVAL;
+ 	if (!(file->f_mode & FMODE_CAN_WRITE))
+ 		goto out;
++	if (flags & ~0)
++		goto out;
+ 
+-	ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos);
++	ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos, flags);
+ 
+ out:
+ 	if (ret > 0)
+@@ -1138,9 +1217,9 @@ out:
+ 	return ret;
+ }
+ 
+-COMPAT_SYSCALL_DEFINE3(writev, compat_ulong_t, fd,
+-		const struct compat_iovec __user *, vec,
+-		compat_ulong_t, vlen)
++static size_t __compat_sys_writev(compat_ulong_t fd,
++				  const struct compat_iovec __user* vec,
++				  compat_ulong_t vlen, int flags)
+ {
+ 	struct fd f = fdget_pos(fd);
+ 	ssize_t ret;
+@@ -1149,28 +1228,36 @@ COMPAT_SYSCALL_DEFINE3(writev, compat_ulong_t, fd,
+ 	if (!f.file)
+ 		return -EBADF;
+ 	pos = f.file->f_pos;
+-	ret = compat_writev(f.file, vec, vlen, &pos);
++	ret = compat_writev(f.file, vec, vlen, &pos, flags);
+ 	if (ret >= 0)
+ 		f.file->f_pos = pos;
+ 	fdput_pos(f);
+ 	return ret;
+ }
+ 
++COMPAT_SYSCALL_DEFINE3(writev, compat_ulong_t, fd,
++		const struct compat_iovec __user *, vec,
++		compat_ulong_t, vlen)
++{
++	return __compat_sys_writev(fd, vec, vlen, 0);
++}
++
+ static long __compat_sys_pwritev64(unsigned long fd,
+ 				   const struct compat_iovec __user *vec,
+-				   unsigned long vlen, loff_t pos)
++				   unsigned long vlen, loff_t pos, int flags)
+ {
+ 	struct fd f;
+ 	ssize_t ret;
+ 
+ 	if (pos < 0)
+ 		return -EINVAL;
++
+ 	f = fdget(fd);
+ 	if (!f.file)
+ 		return -EBADF;
+ 	ret = -ESPIPE;
+ 	if (f.file->f_mode & FMODE_PWRITE)
+-		ret = compat_writev(f.file, vec, vlen, &pos);
++		ret = compat_writev(f.file, vec, vlen, &pos, flags);
+ 	fdput(f);
+ 	return ret;
+ }
+@@ -1180,7 +1267,7 @@ COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,
+ 		const struct compat_iovec __user *,vec,
+ 		unsigned long, vlen, loff_t, pos)
+ {
+-	return __compat_sys_pwritev64(fd, vec, vlen, pos);
++	return __compat_sys_pwritev64(fd, vec, vlen, pos, 0);
+ }
+ #endif
+ 
+@@ -1190,8 +1277,21 @@ COMPAT_SYSCALL_DEFINE5(pwritev, compat_ulong_t, fd,
+ {
+ 	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
+ 
+-	return __compat_sys_pwritev64(fd, vec, vlen, pos);
++	return __compat_sys_pwritev64(fd, vec, vlen, pos, 0);
++}
++
++COMPAT_SYSCALL_DEFINE6(pwritev2, compat_ulong_t, fd,
++		const struct compat_iovec __user *,vec,
++		compat_ulong_t, vlen, u32, pos_low, u32, pos_high, int, flags)
++{
++	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
++
++	if (pos == -1)
++		return __compat_sys_writev(fd, vec, vlen, flags);
++
++	return __compat_sys_pwritev64(fd, vec, vlen, pos, flags);
+ }
++
+ #endif
+ 
+ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
+diff --git a/include/linux/compat.h b/include/linux/compat.h
+index e649426..63a94e2 100644
+--- a/include/linux/compat.h
++++ b/include/linux/compat.h
+@@ -340,6 +340,12 @@ asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
+ asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
+ 		const struct compat_iovec __user *vec,
+ 		compat_ulong_t vlen, u32 pos_low, u32 pos_high);
++asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd,
++		const struct compat_iovec __user *vec,
++		compat_ulong_t vlen, u32 pos_low, u32 pos_high, int flags);
++asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,
++		const struct compat_iovec __user *vec,
++		compat_ulong_t vlen, u32 pos_low, u32 pos_high, int flags);
+ 
+ #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
+ asmlinkage long compat_sys_preadv64(unsigned long fd,
 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
 index bda9b81..cedc22e 100644
 --- a/include/linux/syscalls.h
@@ -191,7 +429,7 @@
  asmlinkage long sys_mkdir(const char __user *pathname, umode_t mode);
  asmlinkage long sys_chdir(const char __user *filename);
 diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
-index 22749c1..10f8883 100644
+index 22749c1..9406018 100644
 --- a/include/uapi/asm-generic/unistd.h
 +++ b/include/uapi/asm-generic/unistd.h
 @@ -213,6 +213,10 @@ __SC_COMP(__NR_pwrite64, sys_pwrite64, compat_sys_pwrite64)
@@ -199,9 +437,9 @@
  #define __NR_pwritev 70
  __SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev)
 +#define __NR_preadv2 281
-+__SC_COMP(__NR_preadv2, sys_preadv2)
++__SC_COMP(__NR_preadv2, sys_preadv2, compat_sys_preadv2)
 +#define __NR_pwritev2 282
-+__SC_COMP(__NR_pwritev2, sys_pwritev2)
++__SC_COMP(__NR_pwritev2, sys_pwritev2, compat_sys_pwritev2)
  
  /* fs/sendfile.c */
  #define __NR3264_sendfile 71
@@ -215,10 +453,27 @@
  /*
   * All syscalls below here should go away really,
 diff --git a/mm/filemap.c b/mm/filemap.c
-index cb7f530..45964c8 100644
+index 14b4642..530c263 100644
 --- a/mm/filemap.c
 +++ b/mm/filemap.c
-@@ -1735,7 +1735,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
+@@ -1457,6 +1457,7 @@ static void shrink_readahead_size_eio(struct file *filp,
+  * @ppos:	current file position
+  * @iter:	data destination
+  * @written:	already copied
++ * @flags:	optional flags
+  *
+  * This is a generic file read routine, and uses the
+  * mapping->a_ops->readpage() function for the actual low-level stuff.
+@@ -1465,7 +1466,7 @@ static void shrink_readahead_size_eio(struct file *filp,
+  * of the logic when it comes to error handling etc.
+  */
+ static ssize_t do_generic_file_read(struct file *filp, loff_t *ppos,
+-		struct iov_iter *iter, ssize_t written)
++		struct iov_iter *iter, ssize_t written, int flags)
+ {
+ 	struct address_space *mapping = filp->f_mapping;
+ 	struct inode *inode = mapping->host;
+@@ -1735,7 +1736,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
  		}
  	}
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help