aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2006-10-10 17:46:57 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-10 18:37:22 -0400
commitba2397efe10ba728c7ff22b179e218c292227c13 (patch)
tree00e55bb4ec8c27c522d78a51e1a3f42fb6177fce /kernel
parentfb136e97840872638cb08588c4c9b9fff7f7c456 (diff)
[PATCH] make kernel/relay.c __user-clean
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/relay.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/kernel/relay.c b/kernel/relay.c
index 1d63ecddfa70..f04bbdb56ac2 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -887,7 +887,7 @@ static int subbuf_read_actor(size_t read_start,
887 887
888 from = buf->start + read_start; 888 from = buf->start + read_start;
889 ret = avail; 889 ret = avail;
890 if (copy_to_user(desc->arg.data, from, avail)) { 890 if (copy_to_user(desc->arg.buf, from, avail)) {
891 desc->error = -EFAULT; 891 desc->error = -EFAULT;
892 ret = 0; 892 ret = 0;
893 } 893 }
@@ -946,24 +946,17 @@ typedef int (*subbuf_actor_t) (size_t read_start,
946 */ 946 */
947static inline ssize_t relay_file_read_subbufs(struct file *filp, 947static inline ssize_t relay_file_read_subbufs(struct file *filp,
948 loff_t *ppos, 948 loff_t *ppos,
949 size_t count,
950 subbuf_actor_t subbuf_actor, 949 subbuf_actor_t subbuf_actor,
951 read_actor_t actor, 950 read_actor_t actor,
952 void *target) 951 read_descriptor_t *desc)
953{ 952{
954 struct rchan_buf *buf = filp->private_data; 953 struct rchan_buf *buf = filp->private_data;
955 size_t read_start, avail; 954 size_t read_start, avail;
956 read_descriptor_t desc;
957 int ret; 955 int ret;
958 956
959 if (!count) 957 if (!desc->count)
960 return 0; 958 return 0;
961 959
962 desc.written = 0;
963 desc.count = count;
964 desc.arg.data = target;
965 desc.error = 0;
966
967 mutex_lock(&filp->f_dentry->d_inode->i_mutex); 960 mutex_lock(&filp->f_dentry->d_inode->i_mutex);
968 do { 961 do {
969 if (!relay_file_read_avail(buf, *ppos)) 962 if (!relay_file_read_avail(buf, *ppos))
@@ -974,19 +967,19 @@ static inline ssize_t relay_file_read_subbufs(struct file *filp,
974 if (!avail) 967 if (!avail)
975 break; 968 break;
976 969
977 avail = min(desc.count, avail); 970 avail = min(desc->count, avail);
978 ret = subbuf_actor(read_start, buf, avail, &desc, actor); 971 ret = subbuf_actor(read_start, buf, avail, desc, actor);
979 if (desc.error < 0) 972 if (desc->error < 0)
980 break; 973 break;
981 974
982 if (ret) { 975 if (ret) {
983 relay_file_read_consume(buf, read_start, ret); 976 relay_file_read_consume(buf, read_start, ret);
984 *ppos = relay_file_read_end_pos(buf, read_start, ret); 977 *ppos = relay_file_read_end_pos(buf, read_start, ret);
985 } 978 }
986 } while (desc.count && ret); 979 } while (desc->count && ret);
987 mutex_unlock(&filp->f_dentry->d_inode->i_mutex); 980 mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
988 981
989 return desc.written; 982 return desc->written;
990} 983}
991 984
992static ssize_t relay_file_read(struct file *filp, 985static ssize_t relay_file_read(struct file *filp,
@@ -994,8 +987,13 @@ static ssize_t relay_file_read(struct file *filp,
994 size_t count, 987 size_t count,
995 loff_t *ppos) 988 loff_t *ppos)
996{ 989{
997 return relay_file_read_subbufs(filp, ppos, count, subbuf_read_actor, 990 read_descriptor_t desc;
998 NULL, buffer); 991 desc.written = 0;
992 desc.count = count;
993 desc.arg.buf = buffer;
994 desc.error = 0;
995 return relay_file_read_subbufs(filp, ppos, subbuf_read_actor,
996 NULL, &desc);
999} 997}
1000 998
1001static ssize_t relay_file_sendfile(struct file *filp, 999static ssize_t relay_file_sendfile(struct file *filp,
@@ -1004,8 +1002,13 @@ static ssize_t relay_file_sendfile(struct file *filp,
1004 read_actor_t actor, 1002 read_actor_t actor,
1005 void *target) 1003 void *target)
1006{ 1004{
1007 return relay_file_read_subbufs(filp, ppos, count, subbuf_send_actor, 1005 read_descriptor_t desc;
1008 actor, target); 1006 desc.written = 0;
1007 desc.count = count;
1008 desc.arg.data = target;
1009 desc.error = 0;
1010 return relay_file_read_subbufs(filp, ppos, subbuf_send_actor,
1011 actor, &desc);
1009} 1012}
1010 1013
1011struct file_operations relay_file_operations = { 1014struct file_operations relay_file_operations = {