Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gfs2: convert simple_str to kstr

-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.

Thanks to Alexey Dobriyan for suggesting improvements in
block_store() and wdack_store()

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>

authored by

Fabian Frederick and committed by
Bob Peterson
e50ead48 01e64ee4

+48 -18
+48 -18
fs/gfs2/sys.c
··· 101 101 102 102 static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len) 103 103 { 104 - int error; 105 - int n = simple_strtol(buf, NULL, 0); 104 + int error, n; 105 + 106 + error = kstrtoint(buf, 0, &n); 107 + if (error) 108 + return error; 106 109 107 110 if (!capable(CAP_SYS_ADMIN)) 108 111 return -EPERM; ··· 137 134 138 135 static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len) 139 136 { 137 + int error, val; 138 + 140 139 if (!capable(CAP_SYS_ADMIN)) 141 140 return -EPERM; 142 141 143 - if (simple_strtol(buf, NULL, 0) != 1) 142 + error = kstrtoint(buf, 0, &val); 143 + if (error) 144 + return error; 145 + 146 + if (val != 1) 144 147 return -EINVAL; 145 148 146 149 gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n"); ··· 157 148 static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf, 158 149 size_t len) 159 150 { 151 + int error, val; 152 + 160 153 if (!capable(CAP_SYS_ADMIN)) 161 154 return -EPERM; 162 155 163 - if (simple_strtol(buf, NULL, 0) != 1) 156 + error = kstrtoint(buf, 0, &val); 157 + if (error) 158 + return error; 159 + 160 + if (val != 1) 164 161 return -EINVAL; 165 162 166 163 gfs2_statfs_sync(sdp->sd_vfs, 0); ··· 176 161 static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, 177 162 size_t len) 178 163 { 164 + int error, val; 165 + 179 166 if (!capable(CAP_SYS_ADMIN)) 180 167 return -EPERM; 181 168 182 - if (simple_strtol(buf, NULL, 0) != 1) 169 + error = kstrtoint(buf, 0, &val); 170 + if (error) 171 + return error; 172 + 173 + if (val != 1) 183 174 return -EINVAL; 184 175 185 176 gfs2_quota_sync(sdp->sd_vfs, 0); ··· 202 181 if (!capable(CAP_SYS_ADMIN)) 203 182 return -EPERM; 204 183 205 - id = simple_strtoul(buf, NULL, 0); 184 + error = kstrtou32(buf, 0, &id); 185 + if (error) 186 + return error; 206 187 207 188 qid = make_kqid(current_user_ns(), USRQUOTA, id); 208 189 if (!qid_valid(qid)) ··· 224 201 if (!capable(CAP_SYS_ADMIN)) 225 202 return -EPERM; 226 203 227 - id = simple_strtoul(buf, NULL, 0); 204 + error = kstrtou32(buf, 0, &id); 205 + if (error) 206 + return error; 228 207 229 208 qid = make_kqid(current_user_ns(), GRPQUOTA, id); 230 209 if (!qid_valid(qid)) ··· 349 324 static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) 350 325 { 351 326 struct lm_lockstruct *ls = &sdp->sd_lockstruct; 352 - ssize_t ret = len; 353 - int val; 327 + int ret, val; 354 328 355 - val = simple_strtol(buf, NULL, 0); 329 + ret = kstrtoint(buf, 0, &val); 330 + if (ret) 331 + return ret; 356 332 357 333 if (val == 1) 358 334 set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); ··· 362 336 smp_mb__after_atomic(); 363 337 gfs2_glock_thaw(sdp); 364 338 } else { 365 - ret = -EINVAL; 339 + return -EINVAL; 366 340 } 367 - return ret; 341 + return len; 368 342 } 369 343 370 344 static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf) ··· 376 350 377 351 static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len) 378 352 { 379 - ssize_t ret = len; 380 - int val; 353 + int ret, val; 381 354 382 - val = simple_strtol(buf, NULL, 0); 355 + ret = kstrtoint(buf, 0, &val); 356 + if (ret) 357 + return ret; 383 358 384 359 if ((val == 1) && 385 360 !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm")) 386 361 complete(&sdp->sd_wdack); 387 362 else 388 - ret = -EINVAL; 389 - return ret; 363 + return -EINVAL; 364 + return len; 390 365 } 391 366 392 367 static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf) ··· 580 553 { 581 554 struct gfs2_tune *gt = &sdp->sd_tune; 582 555 unsigned int x; 556 + int error; 583 557 584 558 if (!capable(CAP_SYS_ADMIN)) 585 559 return -EPERM; 586 560 587 - x = simple_strtoul(buf, NULL, 0); 561 + error = kstrtouint(buf, 0, &x); 562 + if (error) 563 + return error; 588 564 589 565 if (check_zero && !x) 590 566 return -EINVAL;