diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-20 10:42:10 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 14:12:56 -0400 |
commit | 72ec35163f9f728ba1579fd80682e51e933dfa8a (patch) | |
tree | be16e677a5009144cb52c602dcb7dfbc2f86b12a /fs/compat.c | |
parent | bdaec334bbe7d234ca6ddd81aa74b2938d40e6b4 (diff) |
switch compat readv/writev variants to COMPAT_SYSCALL_DEFINE
... and take to fs/read_write.c
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/compat.c')
-rw-r--r-- | fs/compat.c | 186 |
1 files changed, 0 insertions, 186 deletions
diff --git a/fs/compat.c b/fs/compat.c index daa3b771d64d..5058345dc279 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1069,192 +1069,6 @@ asmlinkage long compat_sys_getdents64(unsigned int fd, | |||
1069 | } | 1069 | } |
1070 | #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */ | 1070 | #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */ |
1071 | 1071 | ||
1072 | static ssize_t compat_do_readv_writev(int type, struct file *file, | ||
1073 | const struct compat_iovec __user *uvector, | ||
1074 | unsigned long nr_segs, loff_t *pos) | ||
1075 | { | ||
1076 | compat_ssize_t tot_len; | ||
1077 | struct iovec iovstack[UIO_FASTIOV]; | ||
1078 | struct iovec *iov = iovstack; | ||
1079 | ssize_t ret; | ||
1080 | io_fn_t fn; | ||
1081 | iov_fn_t fnv; | ||
1082 | |||
1083 | ret = -EINVAL; | ||
1084 | if (!file->f_op) | ||
1085 | goto out; | ||
1086 | |||
1087 | ret = compat_rw_copy_check_uvector(type, uvector, nr_segs, | ||
1088 | UIO_FASTIOV, iovstack, &iov); | ||
1089 | if (ret <= 0) | ||
1090 | goto out; | ||
1091 | |||
1092 | tot_len = ret; | ||
1093 | ret = rw_verify_area(type, file, pos, tot_len); | ||
1094 | if (ret < 0) | ||
1095 | goto out; | ||
1096 | |||
1097 | fnv = NULL; | ||
1098 | if (type == READ) { | ||
1099 | fn = file->f_op->read; | ||
1100 | fnv = file->f_op->aio_read; | ||
1101 | } else { | ||
1102 | fn = (io_fn_t)file->f_op->write; | ||
1103 | fnv = file->f_op->aio_write; | ||
1104 | } | ||
1105 | |||
1106 | if (fnv) { | ||
1107 | file_start_write(file); | ||
1108 | ret = do_sync_readv_writev(file, iov, nr_segs, tot_len, | ||
1109 | pos, fnv); | ||
1110 | file_end_write(file); | ||
1111 | } else | ||
1112 | ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn); | ||
1113 | |||
1114 | out: | ||
1115 | if (iov != iovstack) | ||
1116 | kfree(iov); | ||
1117 | if ((ret + (type == READ)) > 0) { | ||
1118 | if (type == READ) | ||
1119 | fsnotify_access(file); | ||
1120 | else | ||
1121 | fsnotify_modify(file); | ||
1122 | } | ||
1123 | return ret; | ||
1124 | } | ||
1125 | |||
1126 | static size_t compat_readv(struct file *file, | ||
1127 | const struct compat_iovec __user *vec, | ||
1128 | unsigned long vlen, loff_t *pos) | ||
1129 | { | ||
1130 | ssize_t ret = -EBADF; | ||
1131 | |||
1132 | if (!(file->f_mode & FMODE_READ)) | ||
1133 | goto out; | ||
1134 | |||
1135 | ret = -EINVAL; | ||
1136 | if (!file->f_op || (!file->f_op->aio_read && !file->f_op->read)) | ||
1137 | goto out; | ||
1138 | |||
1139 | ret = compat_do_readv_writev(READ, file, vec, vlen, pos); | ||
1140 | |||
1141 | out: | ||
1142 | if (ret > 0) | ||
1143 | add_rchar(current, ret); | ||
1144 | inc_syscr(current); | ||
1145 | return ret; | ||
1146 | } | ||
1147 | |||
1148 | asmlinkage ssize_t | ||
1149 | compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, | ||
1150 | unsigned long vlen) | ||
1151 | { | ||
1152 | struct fd f = fdget(fd); | ||
1153 | ssize_t ret; | ||
1154 | loff_t pos; | ||
1155 | |||
1156 | if (!f.file) | ||
1157 | return -EBADF; | ||
1158 | pos = f.file->f_pos; | ||
1159 | ret = compat_readv(f.file, vec, vlen, &pos); | ||
1160 | f.file->f_pos = pos; | ||
1161 | fdput(f); | ||
1162 | return ret; | ||
1163 | } | ||
1164 | |||
1165 | asmlinkage ssize_t | ||
1166 | compat_sys_preadv64(unsigned long fd, const struct compat_iovec __user *vec, | ||
1167 | unsigned long vlen, loff_t pos) | ||
1168 | { | ||
1169 | struct fd f; | ||
1170 | ssize_t ret; | ||
1171 | |||
1172 | if (pos < 0) | ||
1173 | return -EINVAL; | ||
1174 | f = fdget(fd); | ||
1175 | if (!f.file) | ||
1176 | return -EBADF; | ||
1177 | ret = -ESPIPE; | ||
1178 | if (f.file->f_mode & FMODE_PREAD) | ||
1179 | ret = compat_readv(f.file, vec, vlen, &pos); | ||
1180 | fdput(f); | ||
1181 | return ret; | ||
1182 | } | ||
1183 | |||
1184 | asmlinkage ssize_t | ||
1185 | compat_sys_preadv(unsigned long fd, const struct compat_iovec __user *vec, | ||
1186 | unsigned long vlen, u32 pos_low, u32 pos_high) | ||
1187 | { | ||
1188 | loff_t pos = ((loff_t)pos_high << 32) | pos_low; | ||
1189 | return compat_sys_preadv64(fd, vec, vlen, pos); | ||
1190 | } | ||
1191 | |||
1192 | static size_t compat_writev(struct file *file, | ||
1193 | const struct compat_iovec __user *vec, | ||
1194 | unsigned long vlen, loff_t *pos) | ||
1195 | { | ||
1196 | ssize_t ret = -EBADF; | ||
1197 | |||
1198 | if (!(file->f_mode & FMODE_WRITE)) | ||
1199 | goto out; | ||
1200 | |||
1201 | ret = -EINVAL; | ||
1202 | if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write)) | ||
1203 | goto out; | ||
1204 | |||
1205 | ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos); | ||
1206 | |||
1207 | out: | ||
1208 | if (ret > 0) | ||
1209 | add_wchar(current, ret); | ||
1210 | inc_syscw(current); | ||
1211 | return ret; | ||
1212 | } | ||
1213 | |||
1214 | asmlinkage ssize_t | ||
1215 | compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, | ||
1216 | unsigned long vlen) | ||
1217 | { | ||
1218 | struct fd f = fdget(fd); | ||
1219 | ssize_t ret; | ||
1220 | loff_t pos; | ||
1221 | |||
1222 | if (!f.file) | ||
1223 | return -EBADF; | ||
1224 | pos = f.file->f_pos; | ||
1225 | ret = compat_writev(f.file, vec, vlen, &pos); | ||
1226 | f.file->f_pos = pos; | ||
1227 | fdput(f); | ||
1228 | return ret; | ||
1229 | } | ||
1230 | |||
1231 | asmlinkage ssize_t | ||
1232 | compat_sys_pwritev64(unsigned long fd, const struct compat_iovec __user *vec, | ||
1233 | unsigned long vlen, loff_t pos) | ||
1234 | { | ||
1235 | struct fd f; | ||
1236 | ssize_t ret; | ||
1237 | |||
1238 | if (pos < 0) | ||
1239 | return -EINVAL; | ||
1240 | f = fdget(fd); | ||
1241 | if (!f.file) | ||
1242 | return -EBADF; | ||
1243 | ret = -ESPIPE; | ||
1244 | if (f.file->f_mode & FMODE_PWRITE) | ||
1245 | ret = compat_writev(f.file, vec, vlen, &pos); | ||
1246 | fdput(f); | ||
1247 | return ret; | ||
1248 | } | ||
1249 | |||
1250 | asmlinkage ssize_t | ||
1251 | compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec, | ||
1252 | unsigned long vlen, u32 pos_low, u32 pos_high) | ||
1253 | { | ||
1254 | loff_t pos = ((loff_t)pos_high << 32) | pos_low; | ||
1255 | return compat_sys_pwritev64(fd, vec, vlen, pos); | ||
1256 | } | ||
1257 | |||
1258 | asmlinkage long | 1072 | asmlinkage long |
1259 | compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32, | 1073 | compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32, |
1260 | unsigned int nr_segs, unsigned int flags) | 1074 | unsigned int nr_segs, unsigned int flags) |