aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl_binary.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-02-23 14:51:48 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-26 02:46:11 -0500
commit7bb307e894d51308aa0582a8c4cc5875bbc645b9 (patch)
tree8b8434fe4674fb47236c0d7ca2256e7afc29f208 /kernel/sysctl_binary.c
parent94e07a7590ae855bae0536c42b3086fadc7c83a8 (diff)
export kernel_write(), convert open-coded instances
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/sysctl_binary.c')
-rw-r--r--kernel/sysctl_binary.c39
1 files changed, 7 insertions, 32 deletions
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 5a6384450501..37f240fec37a 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -971,7 +971,6 @@ out:
971static ssize_t bin_intvec(struct file *file, 971static ssize_t bin_intvec(struct file *file,
972 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen) 972 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
973{ 973{
974 mm_segment_t old_fs = get_fs();
975 ssize_t copied = 0; 974 ssize_t copied = 0;
976 char *buffer; 975 char *buffer;
977 ssize_t result; 976 ssize_t result;
@@ -984,13 +983,10 @@ static ssize_t bin_intvec(struct file *file,
984 if (oldval && oldlen) { 983 if (oldval && oldlen) {
985 unsigned __user *vec = oldval; 984 unsigned __user *vec = oldval;
986 size_t length = oldlen / sizeof(*vec); 985 size_t length = oldlen / sizeof(*vec);
987 loff_t pos = 0;
988 char *str, *end; 986 char *str, *end;
989 int i; 987 int i;
990 988
991 set_fs(KERNEL_DS); 989 result = kernel_read(file, 0, buffer, BUFSZ - 1);
992 result = vfs_read(file, buffer, BUFSZ - 1, &pos);
993 set_fs(old_fs);
994 if (result < 0) 990 if (result < 0)
995 goto out_kfree; 991 goto out_kfree;
996 992
@@ -1017,7 +1013,6 @@ static ssize_t bin_intvec(struct file *file,
1017 if (newval && newlen) { 1013 if (newval && newlen) {
1018 unsigned __user *vec = newval; 1014 unsigned __user *vec = newval;
1019 size_t length = newlen / sizeof(*vec); 1015 size_t length = newlen / sizeof(*vec);
1020 loff_t pos = 0;
1021 char *str, *end; 1016 char *str, *end;
1022 int i; 1017 int i;
1023 1018
@@ -1033,9 +1028,7 @@ static ssize_t bin_intvec(struct file *file,
1033 str += snprintf(str, end - str, "%lu\t", value); 1028 str += snprintf(str, end - str, "%lu\t", value);
1034 } 1029 }
1035 1030
1036 set_fs(KERNEL_DS); 1031 result = kernel_write(file, buffer, str - buffer, 0);
1037 result = vfs_write(file, buffer, str - buffer, &pos);
1038 set_fs(old_fs);
1039 if (result < 0) 1032 if (result < 0)
1040 goto out_kfree; 1033 goto out_kfree;
1041 } 1034 }
@@ -1049,7 +1042,6 @@ out:
1049static ssize_t bin_ulongvec(struct file *file, 1042static ssize_t bin_ulongvec(struct file *file,
1050 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen) 1043 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1051{ 1044{
1052 mm_segment_t old_fs = get_fs();
1053 ssize_t copied = 0; 1045 ssize_t copied = 0;
1054 char *buffer; 1046 char *buffer;
1055 ssize_t result; 1047 ssize_t result;
@@ -1062,13 +1054,10 @@ static ssize_t bin_ulongvec(struct file *file,
1062 if (oldval && oldlen) { 1054 if (oldval && oldlen) {
1063 unsigned long __user *vec = oldval; 1055 unsigned long __user *vec = oldval;
1064 size_t length = oldlen / sizeof(*vec); 1056 size_t length = oldlen / sizeof(*vec);
1065 loff_t pos = 0;
1066 char *str, *end; 1057 char *str, *end;
1067 int i; 1058 int i;
1068 1059
1069 set_fs(KERNEL_DS); 1060 result = kernel_read(file, 0, buffer, BUFSZ - 1);
1070 result = vfs_read(file, buffer, BUFSZ - 1, &pos);
1071 set_fs(old_fs);
1072 if (result < 0) 1061 if (result < 0)
1073 goto out_kfree; 1062 goto out_kfree;
1074 1063
@@ -1095,7 +1084,6 @@ static ssize_t bin_ulongvec(struct file *file,
1095 if (newval && newlen) { 1084 if (newval && newlen) {
1096 unsigned long __user *vec = newval; 1085 unsigned long __user *vec = newval;
1097 size_t length = newlen / sizeof(*vec); 1086 size_t length = newlen / sizeof(*vec);
1098 loff_t pos = 0;
1099 char *str, *end; 1087 char *str, *end;
1100 int i; 1088 int i;
1101 1089
@@ -1111,9 +1099,7 @@ static ssize_t bin_ulongvec(struct file *file,
1111 str += snprintf(str, end - str, "%lu\t", value); 1099 str += snprintf(str, end - str, "%lu\t", value);
1112 } 1100 }
1113 1101
1114 set_fs(KERNEL_DS); 1102 result = kernel_write(file, buffer, str - buffer, 0);
1115 result = vfs_write(file, buffer, str - buffer, &pos);
1116 set_fs(old_fs);
1117 if (result < 0) 1103 if (result < 0)
1118 goto out_kfree; 1104 goto out_kfree;
1119 } 1105 }
@@ -1127,19 +1113,15 @@ out:
1127static ssize_t bin_uuid(struct file *file, 1113static ssize_t bin_uuid(struct file *file,
1128 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen) 1114 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1129{ 1115{
1130 mm_segment_t old_fs = get_fs();
1131 ssize_t result, copied = 0; 1116 ssize_t result, copied = 0;
1132 1117
1133 /* Only supports reads */ 1118 /* Only supports reads */
1134 if (oldval && oldlen) { 1119 if (oldval && oldlen) {
1135 loff_t pos = 0;
1136 char buf[40], *str = buf; 1120 char buf[40], *str = buf;
1137 unsigned char uuid[16]; 1121 unsigned char uuid[16];
1138 int i; 1122 int i;
1139 1123
1140 set_fs(KERNEL_DS); 1124 result = kernel_read(file, 0, buf, sizeof(buf) - 1);
1141 result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
1142 set_fs(old_fs);
1143 if (result < 0) 1125 if (result < 0)
1144 goto out; 1126 goto out;
1145 1127
@@ -1175,18 +1157,14 @@ out:
1175static ssize_t bin_dn_node_address(struct file *file, 1157static ssize_t bin_dn_node_address(struct file *file,
1176 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen) 1158 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1177{ 1159{
1178 mm_segment_t old_fs = get_fs();
1179 ssize_t result, copied = 0; 1160 ssize_t result, copied = 0;
1180 1161
1181 if (oldval && oldlen) { 1162 if (oldval && oldlen) {
1182 loff_t pos = 0;
1183 char buf[15], *nodep; 1163 char buf[15], *nodep;
1184 unsigned long area, node; 1164 unsigned long area, node;
1185 __le16 dnaddr; 1165 __le16 dnaddr;
1186 1166
1187 set_fs(KERNEL_DS); 1167 result = kernel_read(file, 0, buf, sizeof(buf) - 1);
1188 result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
1189 set_fs(old_fs);
1190 if (result < 0) 1168 if (result < 0)
1191 goto out; 1169 goto out;
1192 1170
@@ -1215,7 +1193,6 @@ static ssize_t bin_dn_node_address(struct file *file,
1215 } 1193 }
1216 1194
1217 if (newval && newlen) { 1195 if (newval && newlen) {
1218 loff_t pos = 0;
1219 __le16 dnaddr; 1196 __le16 dnaddr;
1220 char buf[15]; 1197 char buf[15];
1221 int len; 1198 int len;
@@ -1232,9 +1209,7 @@ static ssize_t bin_dn_node_address(struct file *file,
1232 le16_to_cpu(dnaddr) >> 10, 1209 le16_to_cpu(dnaddr) >> 10,
1233 le16_to_cpu(dnaddr) & 0x3ff); 1210 le16_to_cpu(dnaddr) & 0x3ff);
1234 1211
1235 set_fs(KERNEL_DS); 1212 result = kernel_write(file, buf, len, 0);
1236 result = vfs_write(file, buf, len, &pos);
1237 set_fs(old_fs);
1238 if (result < 0) 1213 if (result < 0)
1239 goto out; 1214 goto out;
1240 } 1215 }