aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_ioctl.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-25 00:58:08 -0400
committerDave Chinner <david@fromorbit.com>2014-06-25 00:58:08 -0400
commit2451337dd043901b5270b7586942abe564443e3d (patch)
tree5f2a59b2c829dbb942c18315ffc0edfed0d3790a /fs/xfs/xfs_ioctl.c
parent30f712c9dd69348aa51351d5cb6d366bf4fae31d (diff)
xfs: global error sign conversion
Convert all the errors the core XFs code to negative error signs like the rest of the kernel and remove all the sign conversion we do in the interface layers. Errors for conversion (and comparison) found via searches like: $ git grep " E" fs/xfs $ git grep "return E" fs/xfs $ git grep " E[A-Z].*;$" fs/xfs Negation points found via searches like: $ git grep "= -[a-z,A-Z]" fs/xfs $ git grep "return -[a-z,A-D,F-Z]" fs/xfs $ git grep " -[a-z].*;" fs/xfs [ with some bits I missed from Brian Foster ] Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_ioctl.c')
-rw-r--r--fs/xfs/xfs_ioctl.c140
1 files changed, 67 insertions, 73 deletions
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1a1648fbda1c..30983b8ceaa1 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -305,7 +305,7 @@ xfs_readlink_by_handle(
305 goto out_dput; 305 goto out_dput;
306 } 306 }
307 307
308 error = -xfs_readlink(XFS_I(dentry->d_inode), link); 308 error = xfs_readlink(XFS_I(dentry->d_inode), link);
309 if (error) 309 if (error)
310 goto out_kfree; 310 goto out_kfree;
311 error = readlink_copy(hreq->ohandle, olen, link); 311 error = readlink_copy(hreq->ohandle, olen, link);
@@ -330,10 +330,10 @@ xfs_set_dmattrs(
330 int error; 330 int error;
331 331
332 if (!capable(CAP_SYS_ADMIN)) 332 if (!capable(CAP_SYS_ADMIN))
333 return EPERM; 333 return -EPERM;
334 334
335 if (XFS_FORCED_SHUTDOWN(mp)) 335 if (XFS_FORCED_SHUTDOWN(mp))
336 return EIO; 336 return -EIO;
337 337
338 tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS); 338 tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS);
339 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); 339 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
@@ -388,7 +388,7 @@ xfs_fssetdm_by_handle(
388 goto out; 388 goto out;
389 } 389 }
390 390
391 error = -xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask, 391 error = xfs_set_dmattrs(XFS_I(dentry->d_inode), fsd.fsd_dmevmask,
392 fsd.fsd_dmstate); 392 fsd.fsd_dmstate);
393 393
394 out: 394 out:
@@ -431,7 +431,7 @@ xfs_attrlist_by_handle(
431 goto out_dput; 431 goto out_dput;
432 432
433 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos; 433 cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
434 error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen, 434 error = xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
435 al_hreq.flags, cursor); 435 al_hreq.flags, cursor);
436 if (error) 436 if (error)
437 goto out_kfree; 437 goto out_kfree;
@@ -455,20 +455,20 @@ xfs_attrmulti_attr_get(
455 __uint32_t flags) 455 __uint32_t flags)
456{ 456{
457 unsigned char *kbuf; 457 unsigned char *kbuf;
458 int error = EFAULT; 458 int error = -EFAULT;
459 459
460 if (*len > XATTR_SIZE_MAX) 460 if (*len > XATTR_SIZE_MAX)
461 return EINVAL; 461 return -EINVAL;
462 kbuf = kmem_zalloc_large(*len, KM_SLEEP); 462 kbuf = kmem_zalloc_large(*len, KM_SLEEP);
463 if (!kbuf) 463 if (!kbuf)
464 return ENOMEM; 464 return -ENOMEM;
465 465
466 error = xfs_attr_get(XFS_I(inode), name, kbuf, (int *)len, flags); 466 error = xfs_attr_get(XFS_I(inode), name, kbuf, (int *)len, flags);
467 if (error) 467 if (error)
468 goto out_kfree; 468 goto out_kfree;
469 469
470 if (copy_to_user(ubuf, kbuf, *len)) 470 if (copy_to_user(ubuf, kbuf, *len))
471 error = EFAULT; 471 error = -EFAULT;
472 472
473out_kfree: 473out_kfree:
474 kmem_free(kbuf); 474 kmem_free(kbuf);
@@ -484,20 +484,17 @@ xfs_attrmulti_attr_set(
484 __uint32_t flags) 484 __uint32_t flags)
485{ 485{
486 unsigned char *kbuf; 486 unsigned char *kbuf;
487 int error = EFAULT;
488 487
489 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 488 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
490 return EPERM; 489 return -EPERM;
491 if (len > XATTR_SIZE_MAX) 490 if (len > XATTR_SIZE_MAX)
492 return EINVAL; 491 return -EINVAL;
493 492
494 kbuf = memdup_user(ubuf, len); 493 kbuf = memdup_user(ubuf, len);
495 if (IS_ERR(kbuf)) 494 if (IS_ERR(kbuf))
496 return PTR_ERR(kbuf); 495 return PTR_ERR(kbuf);
497 496
498 error = xfs_attr_set(XFS_I(inode), name, kbuf, len, flags); 497 return xfs_attr_set(XFS_I(inode), name, kbuf, len, flags);
499
500 return error;
501} 498}
502 499
503int 500int
@@ -507,7 +504,7 @@ xfs_attrmulti_attr_remove(
507 __uint32_t flags) 504 __uint32_t flags)
508{ 505{
509 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 506 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
510 return EPERM; 507 return -EPERM;
511 return xfs_attr_remove(XFS_I(inode), name, flags); 508 return xfs_attr_remove(XFS_I(inode), name, flags);
512} 509}
513 510
@@ -536,18 +533,18 @@ xfs_attrmulti_by_handle(
536 if (IS_ERR(dentry)) 533 if (IS_ERR(dentry))
537 return PTR_ERR(dentry); 534 return PTR_ERR(dentry);
538 535
539 error = E2BIG; 536 error = -E2BIG;
540 size = am_hreq.opcount * sizeof(xfs_attr_multiop_t); 537 size = am_hreq.opcount * sizeof(xfs_attr_multiop_t);
541 if (!size || size > 16 * PAGE_SIZE) 538 if (!size || size > 16 * PAGE_SIZE)
542 goto out_dput; 539 goto out_dput;
543 540
544 ops = memdup_user(am_hreq.ops, size); 541 ops = memdup_user(am_hreq.ops, size);
545 if (IS_ERR(ops)) { 542 if (IS_ERR(ops)) {
546 error = -PTR_ERR(ops); 543 error = PTR_ERR(ops);
547 goto out_dput; 544 goto out_dput;
548 } 545 }
549 546
550 error = ENOMEM; 547 error = -ENOMEM;
551 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); 548 attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
552 if (!attr_name) 549 if (!attr_name)
553 goto out_kfree_ops; 550 goto out_kfree_ops;
@@ -557,7 +554,7 @@ xfs_attrmulti_by_handle(
557 ops[i].am_error = strncpy_from_user((char *)attr_name, 554 ops[i].am_error = strncpy_from_user((char *)attr_name,
558 ops[i].am_attrname, MAXNAMELEN); 555 ops[i].am_attrname, MAXNAMELEN);
559 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) 556 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
560 error = ERANGE; 557 error = -ERANGE;
561 if (ops[i].am_error < 0) 558 if (ops[i].am_error < 0)
562 break; 559 break;
563 560
@@ -588,19 +585,19 @@ xfs_attrmulti_by_handle(
588 mnt_drop_write_file(parfilp); 585 mnt_drop_write_file(parfilp);
589 break; 586 break;
590 default: 587 default:
591 ops[i].am_error = EINVAL; 588 ops[i].am_error = -EINVAL;
592 } 589 }
593 } 590 }
594 591
595 if (copy_to_user(am_hreq.ops, ops, size)) 592 if (copy_to_user(am_hreq.ops, ops, size))
596 error = EFAULT; 593 error = -EFAULT;
597 594
598 kfree(attr_name); 595 kfree(attr_name);
599 out_kfree_ops: 596 out_kfree_ops:
600 kfree(ops); 597 kfree(ops);
601 out_dput: 598 out_dput:
602 dput(dentry); 599 dput(dentry);
603 return -error; 600 return error;
604} 601}
605 602
606int 603int
@@ -652,7 +649,7 @@ xfs_ioc_space(
652 bf->l_start += XFS_ISIZE(ip); 649 bf->l_start += XFS_ISIZE(ip);
653 break; 650 break;
654 default: 651 default:
655 error = EINVAL; 652 error = -EINVAL;
656 goto out_unlock; 653 goto out_unlock;
657 } 654 }
658 655
@@ -669,7 +666,7 @@ xfs_ioc_space(
669 case XFS_IOC_UNRESVSP: 666 case XFS_IOC_UNRESVSP:
670 case XFS_IOC_UNRESVSP64: 667 case XFS_IOC_UNRESVSP64:
671 if (bf->l_len <= 0) { 668 if (bf->l_len <= 0) {
672 error = EINVAL; 669 error = -EINVAL;
673 goto out_unlock; 670 goto out_unlock;
674 } 671 }
675 break; 672 break;
@@ -682,7 +679,7 @@ xfs_ioc_space(
682 bf->l_start > mp->m_super->s_maxbytes || 679 bf->l_start > mp->m_super->s_maxbytes ||
683 bf->l_start + bf->l_len < 0 || 680 bf->l_start + bf->l_len < 0 ||
684 bf->l_start + bf->l_len >= mp->m_super->s_maxbytes) { 681 bf->l_start + bf->l_len >= mp->m_super->s_maxbytes) {
685 error = EINVAL; 682 error = -EINVAL;
686 goto out_unlock; 683 goto out_unlock;
687 } 684 }
688 685
@@ -723,7 +720,7 @@ xfs_ioc_space(
723 break; 720 break;
724 default: 721 default:
725 ASSERT(0); 722 ASSERT(0);
726 error = EINVAL; 723 error = -EINVAL;
727 } 724 }
728 725
729 if (error) 726 if (error)
@@ -759,7 +756,7 @@ xfs_ioc_space(
759out_unlock: 756out_unlock:
760 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 757 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
761 mnt_drop_write_file(filp); 758 mnt_drop_write_file(filp);
762 return -error; 759 return error;
763} 760}
764 761
765STATIC int 762STATIC int
@@ -807,7 +804,7 @@ xfs_ioc_bulkstat(
807 &done); 804 &done);
808 805
809 if (error) 806 if (error)
810 return -error; 807 return error;
811 808
812 if (bulkreq.ocount != NULL) { 809 if (bulkreq.ocount != NULL) {
813 if (copy_to_user(bulkreq.lastip, &inlast, 810 if (copy_to_user(bulkreq.lastip, &inlast,
@@ -831,7 +828,7 @@ xfs_ioc_fsgeometry_v1(
831 828
832 error = xfs_fs_geometry(mp, &fsgeo, 3); 829 error = xfs_fs_geometry(mp, &fsgeo, 3);
833 if (error) 830 if (error)
834 return -error; 831 return error;
835 832
836 /* 833 /*
837 * Caller should have passed an argument of type 834 * Caller should have passed an argument of type
@@ -853,7 +850,7 @@ xfs_ioc_fsgeometry(
853 850
854 error = xfs_fs_geometry(mp, &fsgeo, 4); 851 error = xfs_fs_geometry(mp, &fsgeo, 4);
855 if (error) 852 if (error)
856 return -error; 853 return error;
857 854
858 if (copy_to_user(arg, &fsgeo, sizeof(fsgeo))) 855 if (copy_to_user(arg, &fsgeo, sizeof(fsgeo)))
859 return -EFAULT; 856 return -EFAULT;
@@ -1041,16 +1038,16 @@ xfs_ioctl_setattr(
1041 trace_xfs_ioctl_setattr(ip); 1038 trace_xfs_ioctl_setattr(ip);
1042 1039
1043 if (mp->m_flags & XFS_MOUNT_RDONLY) 1040 if (mp->m_flags & XFS_MOUNT_RDONLY)
1044 return EROFS; 1041 return -EROFS;
1045 if (XFS_FORCED_SHUTDOWN(mp)) 1042 if (XFS_FORCED_SHUTDOWN(mp))
1046 return EIO; 1043 return -EIO;
1047 1044
1048 /* 1045 /*
1049 * Disallow 32bit project ids when projid32bit feature is not enabled. 1046 * Disallow 32bit project ids when projid32bit feature is not enabled.
1050 */ 1047 */
1051 if ((mask & FSX_PROJID) && (fa->fsx_projid > (__uint16_t)-1) && 1048 if ((mask & FSX_PROJID) && (fa->fsx_projid > (__uint16_t)-1) &&
1052 !xfs_sb_version_hasprojid32bit(&ip->i_mount->m_sb)) 1049 !xfs_sb_version_hasprojid32bit(&ip->i_mount->m_sb))
1053 return EINVAL; 1050 return -EINVAL;
1054 1051
1055 /* 1052 /*
1056 * If disk quotas is on, we make sure that the dquots do exist on disk, 1053 * If disk quotas is on, we make sure that the dquots do exist on disk,
@@ -1088,7 +1085,7 @@ xfs_ioctl_setattr(
1088 * CAP_FSETID capability is applicable. 1085 * CAP_FSETID capability is applicable.
1089 */ 1086 */
1090 if (!inode_owner_or_capable(VFS_I(ip))) { 1087 if (!inode_owner_or_capable(VFS_I(ip))) {
1091 code = EPERM; 1088 code = -EPERM;
1092 goto error_return; 1089 goto error_return;
1093 } 1090 }
1094 1091
@@ -1099,7 +1096,7 @@ xfs_ioctl_setattr(
1099 */ 1096 */
1100 if (mask & FSX_PROJID) { 1097 if (mask & FSX_PROJID) {
1101 if (current_user_ns() != &init_user_ns) { 1098 if (current_user_ns() != &init_user_ns) {
1102 code = EINVAL; 1099 code = -EINVAL;
1103 goto error_return; 1100 goto error_return;
1104 } 1101 }
1105 1102
@@ -1122,7 +1119,7 @@ xfs_ioctl_setattr(
1122 if (ip->i_d.di_nextents && 1119 if (ip->i_d.di_nextents &&
1123 ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != 1120 ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) !=
1124 fa->fsx_extsize)) { 1121 fa->fsx_extsize)) {
1125 code = EINVAL; /* EFBIG? */ 1122 code = -EINVAL; /* EFBIG? */
1126 goto error_return; 1123 goto error_return;
1127 } 1124 }
1128 1125
@@ -1141,7 +1138,7 @@ xfs_ioctl_setattr(
1141 1138
1142 extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize); 1139 extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize);
1143 if (extsize_fsb > MAXEXTLEN) { 1140 if (extsize_fsb > MAXEXTLEN) {
1144 code = EINVAL; 1141 code = -EINVAL;
1145 goto error_return; 1142 goto error_return;
1146 } 1143 }
1147 1144
@@ -1153,13 +1150,13 @@ xfs_ioctl_setattr(
1153 } else { 1150 } else {
1154 size = mp->m_sb.sb_blocksize; 1151 size = mp->m_sb.sb_blocksize;
1155 if (extsize_fsb > mp->m_sb.sb_agblocks / 2) { 1152 if (extsize_fsb > mp->m_sb.sb_agblocks / 2) {
1156 code = EINVAL; 1153 code = -EINVAL;
1157 goto error_return; 1154 goto error_return;
1158 } 1155 }
1159 } 1156 }
1160 1157
1161 if (fa->fsx_extsize % size) { 1158 if (fa->fsx_extsize % size) {
1162 code = EINVAL; 1159 code = -EINVAL;
1163 goto error_return; 1160 goto error_return;
1164 } 1161 }
1165 } 1162 }
@@ -1173,7 +1170,7 @@ xfs_ioctl_setattr(
1173 if ((ip->i_d.di_nextents || ip->i_delayed_blks) && 1170 if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&
1174 (XFS_IS_REALTIME_INODE(ip)) != 1171 (XFS_IS_REALTIME_INODE(ip)) !=
1175 (fa->fsx_xflags & XFS_XFLAG_REALTIME)) { 1172 (fa->fsx_xflags & XFS_XFLAG_REALTIME)) {
1176 code = EINVAL; /* EFBIG? */ 1173 code = -EINVAL; /* EFBIG? */
1177 goto error_return; 1174 goto error_return;
1178 } 1175 }
1179 1176
@@ -1184,7 +1181,7 @@ xfs_ioctl_setattr(
1184 if ((mp->m_sb.sb_rblocks == 0) || 1181 if ((mp->m_sb.sb_rblocks == 0) ||
1185 (mp->m_sb.sb_rextsize == 0) || 1182 (mp->m_sb.sb_rextsize == 0) ||
1186 (ip->i_d.di_extsize % mp->m_sb.sb_rextsize)) { 1183 (ip->i_d.di_extsize % mp->m_sb.sb_rextsize)) {
1187 code = EINVAL; 1184 code = -EINVAL;
1188 goto error_return; 1185 goto error_return;
1189 } 1186 }
1190 } 1187 }
@@ -1198,7 +1195,7 @@ xfs_ioctl_setattr(
1198 (fa->fsx_xflags & 1195 (fa->fsx_xflags &
1199 (XFS_XFLAG_IMMUTABLE | XFS_XFLAG_APPEND))) && 1196 (XFS_XFLAG_IMMUTABLE | XFS_XFLAG_APPEND))) &&
1200 !capable(CAP_LINUX_IMMUTABLE)) { 1197 !capable(CAP_LINUX_IMMUTABLE)) {
1201 code = EPERM; 1198 code = -EPERM;
1202 goto error_return; 1199 goto error_return;
1203 } 1200 }
1204 } 1201 }
@@ -1301,7 +1298,7 @@ xfs_ioc_fssetxattr(
1301 return error; 1298 return error;
1302 error = xfs_ioctl_setattr(ip, &fa, mask); 1299 error = xfs_ioctl_setattr(ip, &fa, mask);
1303 mnt_drop_write_file(filp); 1300 mnt_drop_write_file(filp);
1304 return -error; 1301 return error;
1305} 1302}
1306 1303
1307STATIC int 1304STATIC int
@@ -1346,7 +1343,7 @@ xfs_ioc_setxflags(
1346 return error; 1343 return error;
1347 error = xfs_ioctl_setattr(ip, &fa, mask); 1344 error = xfs_ioctl_setattr(ip, &fa, mask);
1348 mnt_drop_write_file(filp); 1345 mnt_drop_write_file(filp);
1349 return -error; 1346 return error;
1350} 1347}
1351 1348
1352STATIC int 1349STATIC int
@@ -1356,7 +1353,7 @@ xfs_getbmap_format(void **ap, struct getbmapx *bmv, int *full)
1356 1353
1357 /* copy only getbmap portion (not getbmapx) */ 1354 /* copy only getbmap portion (not getbmapx) */
1358 if (copy_to_user(base, bmv, sizeof(struct getbmap))) 1355 if (copy_to_user(base, bmv, sizeof(struct getbmap)))
1359 return EFAULT; 1356 return -EFAULT;
1360 1357
1361 *ap += sizeof(struct getbmap); 1358 *ap += sizeof(struct getbmap);
1362 return 0; 1359 return 0;
@@ -1385,7 +1382,7 @@ xfs_ioc_getbmap(
1385 error = xfs_getbmap(ip, &bmx, xfs_getbmap_format, 1382 error = xfs_getbmap(ip, &bmx, xfs_getbmap_format,
1386 (struct getbmap *)arg+1); 1383 (struct getbmap *)arg+1);
1387 if (error) 1384 if (error)
1388 return -error; 1385 return error;
1389 1386
1390 /* copy back header - only size of getbmap */ 1387 /* copy back header - only size of getbmap */
1391 if (copy_to_user(arg, &bmx, sizeof(struct getbmap))) 1388 if (copy_to_user(arg, &bmx, sizeof(struct getbmap)))
@@ -1399,7 +1396,7 @@ xfs_getbmapx_format(void **ap, struct getbmapx *bmv, int *full)
1399 struct getbmapx __user *base = *ap; 1396 struct getbmapx __user *base = *ap;
1400 1397
1401 if (copy_to_user(base, bmv, sizeof(struct getbmapx))) 1398 if (copy_to_user(base, bmv, sizeof(struct getbmapx)))
1402 return EFAULT; 1399 return -EFAULT;
1403 1400
1404 *ap += sizeof(struct getbmapx); 1401 *ap += sizeof(struct getbmapx);
1405 return 0; 1402 return 0;
@@ -1425,7 +1422,7 @@ xfs_ioc_getbmapx(
1425 error = xfs_getbmap(ip, &bmx, xfs_getbmapx_format, 1422 error = xfs_getbmap(ip, &bmx, xfs_getbmapx_format,
1426 (struct getbmapx *)arg+1); 1423 (struct getbmapx *)arg+1);
1427 if (error) 1424 if (error)
1428 return -error; 1425 return error;
1429 1426
1430 /* copy back header */ 1427 /* copy back header */
1431 if (copy_to_user(arg, &bmx, sizeof(struct getbmapx))) 1428 if (copy_to_user(arg, &bmx, sizeof(struct getbmapx)))
@@ -1445,33 +1442,33 @@ xfs_ioc_swapext(
1445 /* Pull information for the target fd */ 1442 /* Pull information for the target fd */
1446 f = fdget((int)sxp->sx_fdtarget); 1443 f = fdget((int)sxp->sx_fdtarget);
1447 if (!f.file) { 1444 if (!f.file) {
1448 error = EINVAL; 1445 error = -EINVAL;
1449 goto out; 1446 goto out;
1450 } 1447 }
1451 1448
1452 if (!(f.file->f_mode & FMODE_WRITE) || 1449 if (!(f.file->f_mode & FMODE_WRITE) ||
1453 !(f.file->f_mode & FMODE_READ) || 1450 !(f.file->f_mode & FMODE_READ) ||
1454 (f.file->f_flags & O_APPEND)) { 1451 (f.file->f_flags & O_APPEND)) {
1455 error = EBADF; 1452 error = -EBADF;
1456 goto out_put_file; 1453 goto out_put_file;
1457 } 1454 }
1458 1455
1459 tmp = fdget((int)sxp->sx_fdtmp); 1456 tmp = fdget((int)sxp->sx_fdtmp);
1460 if (!tmp.file) { 1457 if (!tmp.file) {
1461 error = EINVAL; 1458 error = -EINVAL;
1462 goto out_put_file; 1459 goto out_put_file;
1463 } 1460 }
1464 1461
1465 if (!(tmp.file->f_mode & FMODE_WRITE) || 1462 if (!(tmp.file->f_mode & FMODE_WRITE) ||
1466 !(tmp.file->f_mode & FMODE_READ) || 1463 !(tmp.file->f_mode & FMODE_READ) ||
1467 (tmp.file->f_flags & O_APPEND)) { 1464 (tmp.file->f_flags & O_APPEND)) {
1468 error = EBADF; 1465 error = -EBADF;
1469 goto out_put_tmp_file; 1466 goto out_put_tmp_file;
1470 } 1467 }
1471 1468
1472 if (IS_SWAPFILE(file_inode(f.file)) || 1469 if (IS_SWAPFILE(file_inode(f.file)) ||
1473 IS_SWAPFILE(file_inode(tmp.file))) { 1470 IS_SWAPFILE(file_inode(tmp.file))) {
1474 error = EINVAL; 1471 error = -EINVAL;
1475 goto out_put_tmp_file; 1472 goto out_put_tmp_file;
1476 } 1473 }
1477 1474
@@ -1479,17 +1476,17 @@ xfs_ioc_swapext(
1479 tip = XFS_I(file_inode(tmp.file)); 1476 tip = XFS_I(file_inode(tmp.file));
1480 1477
1481 if (ip->i_mount != tip->i_mount) { 1478 if (ip->i_mount != tip->i_mount) {
1482 error = EINVAL; 1479 error = -EINVAL;
1483 goto out_put_tmp_file; 1480 goto out_put_tmp_file;
1484 } 1481 }
1485 1482
1486 if (ip->i_ino == tip->i_ino) { 1483 if (ip->i_ino == tip->i_ino) {
1487 error = EINVAL; 1484 error = -EINVAL;
1488 goto out_put_tmp_file; 1485 goto out_put_tmp_file;
1489 } 1486 }
1490 1487
1491 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) { 1488 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {
1492 error = EIO; 1489 error = -EIO;
1493 goto out_put_tmp_file; 1490 goto out_put_tmp_file;
1494 } 1491 }
1495 1492
@@ -1597,7 +1594,7 @@ xfs_file_ioctl(
1597 error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask, 1594 error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask,
1598 dmi.fsd_dmstate); 1595 dmi.fsd_dmstate);
1599 mnt_drop_write_file(filp); 1596 mnt_drop_write_file(filp);
1600 return -error; 1597 return error;
1601 } 1598 }
1602 1599
1603 case XFS_IOC_GETBMAP: 1600 case XFS_IOC_GETBMAP:
@@ -1649,7 +1646,7 @@ xfs_file_ioctl(
1649 return error; 1646 return error;
1650 error = xfs_ioc_swapext(&sxp); 1647 error = xfs_ioc_swapext(&sxp);
1651 mnt_drop_write_file(filp); 1648 mnt_drop_write_file(filp);
1652 return -error; 1649 return error;
1653 } 1650 }
1654 1651
1655 case XFS_IOC_FSCOUNTS: { 1652 case XFS_IOC_FSCOUNTS: {
@@ -1657,7 +1654,7 @@ xfs_file_ioctl(
1657 1654
1658 error = xfs_fs_counts(mp, &out); 1655 error = xfs_fs_counts(mp, &out);
1659 if (error) 1656 if (error)
1660 return -error; 1657 return error;
1661 1658
1662 if (copy_to_user(arg, &out, sizeof(out))) 1659 if (copy_to_user(arg, &out, sizeof(out)))
1663 return -EFAULT; 1660 return -EFAULT;
@@ -1686,7 +1683,7 @@ xfs_file_ioctl(
1686 error = xfs_reserve_blocks(mp, &in, &inout); 1683 error = xfs_reserve_blocks(mp, &in, &inout);
1687 mnt_drop_write_file(filp); 1684 mnt_drop_write_file(filp);
1688 if (error) 1685 if (error)
1689 return -error; 1686 return error;
1690 1687
1691 if (copy_to_user(arg, &inout, sizeof(inout))) 1688 if (copy_to_user(arg, &inout, sizeof(inout)))
1692 return -EFAULT; 1689 return -EFAULT;
@@ -1701,7 +1698,7 @@ xfs_file_ioctl(
1701 1698
1702 error = xfs_reserve_blocks(mp, NULL, &out); 1699 error = xfs_reserve_blocks(mp, NULL, &out);
1703 if (error) 1700 if (error)
1704 return -error; 1701 return error;
1705 1702
1706 if (copy_to_user(arg, &out, sizeof(out))) 1703 if (copy_to_user(arg, &out, sizeof(out)))
1707 return -EFAULT; 1704 return -EFAULT;
@@ -1720,7 +1717,7 @@ xfs_file_ioctl(
1720 return error; 1717 return error;
1721 error = xfs_growfs_data(mp, &in); 1718 error = xfs_growfs_data(mp, &in);
1722 mnt_drop_write_file(filp); 1719 mnt_drop_write_file(filp);
1723 return -error; 1720 return error;
1724 } 1721 }
1725 1722
1726 case XFS_IOC_FSGROWFSLOG: { 1723 case XFS_IOC_FSGROWFSLOG: {
@@ -1734,7 +1731,7 @@ xfs_file_ioctl(
1734 return error; 1731 return error;
1735 error = xfs_growfs_log(mp, &in); 1732 error = xfs_growfs_log(mp, &in);
1736 mnt_drop_write_file(filp); 1733 mnt_drop_write_file(filp);
1737 return -error; 1734 return error;
1738 } 1735 }
1739 1736
1740 case XFS_IOC_FSGROWFSRT: { 1737 case XFS_IOC_FSGROWFSRT: {
@@ -1748,7 +1745,7 @@ xfs_file_ioctl(
1748 return error; 1745 return error;
1749 error = xfs_growfs_rt(mp, &in); 1746 error = xfs_growfs_rt(mp, &in);
1750 mnt_drop_write_file(filp); 1747 mnt_drop_write_file(filp);
1751 return -error; 1748 return error;
1752 } 1749 }
1753 1750
1754 case XFS_IOC_GOINGDOWN: { 1751 case XFS_IOC_GOINGDOWN: {
@@ -1760,8 +1757,7 @@ xfs_file_ioctl(
1760 if (get_user(in, (__uint32_t __user *)arg)) 1757 if (get_user(in, (__uint32_t __user *)arg))
1761 return -EFAULT; 1758 return -EFAULT;
1762 1759
1763 error = xfs_fs_goingdown(mp, in); 1760 return xfs_fs_goingdown(mp, in);
1764 return -error;
1765 } 1761 }
1766 1762
1767 case XFS_IOC_ERROR_INJECTION: { 1763 case XFS_IOC_ERROR_INJECTION: {
@@ -1773,16 +1769,14 @@ xfs_file_ioctl(
1773 if (copy_from_user(&in, arg, sizeof(in))) 1769 if (copy_from_user(&in, arg, sizeof(in)))
1774 return -EFAULT; 1770 return -EFAULT;
1775 1771
1776 error = xfs_errortag_add(in.errtag, mp); 1772 return xfs_errortag_add(in.errtag, mp);
1777 return -error;
1778 } 1773 }
1779 1774
1780 case XFS_IOC_ERROR_CLEARALL: 1775 case XFS_IOC_ERROR_CLEARALL:
1781 if (!capable(CAP_SYS_ADMIN)) 1776 if (!capable(CAP_SYS_ADMIN))
1782 return -EPERM; 1777 return -EPERM;
1783 1778
1784 error = xfs_errortag_clearall(mp, 1); 1779 return xfs_errortag_clearall(mp, 1);
1785 return -error;
1786 1780
1787 case XFS_IOC_FREE_EOFBLOCKS: { 1781 case XFS_IOC_FREE_EOFBLOCKS: {
1788 struct xfs_fs_eofblocks eofb; 1782 struct xfs_fs_eofblocks eofb;
@@ -1799,9 +1793,9 @@ xfs_file_ioctl(
1799 1793
1800 error = xfs_fs_eofblocks_from_user(&eofb, &keofb); 1794 error = xfs_fs_eofblocks_from_user(&eofb, &keofb);
1801 if (error) 1795 if (error)
1802 return -error; 1796 return error;
1803 1797
1804 return -xfs_icache_free_eofblocks(mp, &keofb); 1798 return xfs_icache_free_eofblocks(mp, &keofb);
1805 } 1799 }
1806 1800
1807 default: 1801 default: