diff options
| -rw-r--r-- | fs/xfs/linux-2.6/xfs_ioctl.c | 314 | 
1 files changed, 2 insertions, 312 deletions
| diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index c6399b2cf17c..640c8b6b1956 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c | |||
| @@ -651,314 +651,6 @@ xfs_attrmulti_by_handle( | |||
| 651 | return -error; | 651 | return -error; | 
| 652 | } | 652 | } | 
| 653 | 653 | ||
| 654 | /* prototypes for a few of the stack-hungry cases that have | ||
| 655 | * their own functions. Functions are defined after their use | ||
| 656 | * so gcc doesn't get fancy and inline them with -03 */ | ||
| 657 | |||
| 658 | STATIC int | ||
| 659 | xfs_ioc_space( | ||
| 660 | struct xfs_inode *ip, | ||
| 661 | struct inode *inode, | ||
| 662 | struct file *filp, | ||
| 663 | int flags, | ||
| 664 | unsigned int cmd, | ||
| 665 | void __user *arg); | ||
| 666 | |||
| 667 | STATIC int | ||
| 668 | xfs_ioc_bulkstat( | ||
| 669 | xfs_mount_t *mp, | ||
| 670 | unsigned int cmd, | ||
| 671 | void __user *arg); | ||
| 672 | |||
| 673 | STATIC int | ||
| 674 | xfs_ioc_fsgeometry_v1( | ||
| 675 | xfs_mount_t *mp, | ||
| 676 | void __user *arg); | ||
| 677 | |||
| 678 | STATIC int | ||
| 679 | xfs_ioc_fsgeometry( | ||
| 680 | xfs_mount_t *mp, | ||
| 681 | void __user *arg); | ||
| 682 | |||
| 683 | STATIC int | ||
| 684 | xfs_ioc_xattr( | ||
| 685 | xfs_inode_t *ip, | ||
| 686 | struct file *filp, | ||
| 687 | unsigned int cmd, | ||
| 688 | void __user *arg); | ||
| 689 | |||
| 690 | STATIC int | ||
| 691 | xfs_ioc_fsgetxattr( | ||
| 692 | xfs_inode_t *ip, | ||
| 693 | int attr, | ||
| 694 | void __user *arg); | ||
| 695 | |||
| 696 | STATIC int | ||
| 697 | xfs_ioc_getbmap( | ||
| 698 | struct xfs_inode *ip, | ||
| 699 | int flags, | ||
| 700 | unsigned int cmd, | ||
| 701 | void __user *arg); | ||
| 702 | |||
| 703 | STATIC int | ||
| 704 | xfs_ioc_getbmapx( | ||
| 705 | struct xfs_inode *ip, | ||
| 706 | void __user *arg); | ||
| 707 | |||
| 708 | int | ||
| 709 | xfs_ioctl( | ||
| 710 | xfs_inode_t *ip, | ||
| 711 | struct file *filp, | ||
| 712 | int ioflags, | ||
| 713 | unsigned int cmd, | ||
| 714 | void __user *arg) | ||
| 715 | { | ||
| 716 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
| 717 | xfs_mount_t *mp = ip->i_mount; | ||
| 718 | int error; | ||
| 719 | |||
| 720 | xfs_itrace_entry(XFS_I(inode)); | ||
| 721 | switch (cmd) { | ||
| 722 | |||
| 723 | case XFS_IOC_ALLOCSP: | ||
| 724 | case XFS_IOC_FREESP: | ||
| 725 | case XFS_IOC_RESVSP: | ||
| 726 | case XFS_IOC_UNRESVSP: | ||
| 727 | case XFS_IOC_ALLOCSP64: | ||
| 728 | case XFS_IOC_FREESP64: | ||
| 729 | case XFS_IOC_RESVSP64: | ||
| 730 | case XFS_IOC_UNRESVSP64: | ||
| 731 | /* | ||
| 732 | * Only allow the sys admin to reserve space unless | ||
| 733 | * unwritten extents are enabled. | ||
| 734 | */ | ||
| 735 | if (!xfs_sb_version_hasextflgbit(&mp->m_sb) && | ||
| 736 | !capable(CAP_SYS_ADMIN)) | ||
| 737 | return -EPERM; | ||
| 738 | |||
| 739 | return xfs_ioc_space(ip, inode, filp, ioflags, cmd, arg); | ||
| 740 | |||
| 741 | case XFS_IOC_DIOINFO: { | ||
| 742 | struct dioattr da; | ||
| 743 | xfs_buftarg_t *target = | ||
| 744 | XFS_IS_REALTIME_INODE(ip) ? | ||
| 745 | mp->m_rtdev_targp : mp->m_ddev_targp; | ||
| 746 | |||
| 747 | da.d_mem = da.d_miniosz = 1 << target->bt_sshift; | ||
| 748 | da.d_maxiosz = INT_MAX & ~(da.d_miniosz - 1); | ||
| 749 | |||
| 750 | if (copy_to_user(arg, &da, sizeof(da))) | ||
| 751 | return -XFS_ERROR(EFAULT); | ||
| 752 | return 0; | ||
| 753 | } | ||
| 754 | |||
| 755 | case XFS_IOC_FSBULKSTAT_SINGLE: | ||
| 756 | case XFS_IOC_FSBULKSTAT: | ||
| 757 | case XFS_IOC_FSINUMBERS: | ||
| 758 | return xfs_ioc_bulkstat(mp, cmd, arg); | ||
| 759 | |||
| 760 | case XFS_IOC_FSGEOMETRY_V1: | ||
| 761 | return xfs_ioc_fsgeometry_v1(mp, arg); | ||
| 762 | |||
| 763 | case XFS_IOC_FSGEOMETRY: | ||
| 764 | return xfs_ioc_fsgeometry(mp, arg); | ||
| 765 | |||
| 766 | case XFS_IOC_GETVERSION: | ||
| 767 | return put_user(inode->i_generation, (int __user *)arg); | ||
| 768 | |||
| 769 | case XFS_IOC_FSGETXATTR: | ||
| 770 | return xfs_ioc_fsgetxattr(ip, 0, arg); | ||
| 771 | case XFS_IOC_FSGETXATTRA: | ||
| 772 | return xfs_ioc_fsgetxattr(ip, 1, arg); | ||
| 773 | case XFS_IOC_GETXFLAGS: | ||
| 774 | case XFS_IOC_SETXFLAGS: | ||
| 775 | case XFS_IOC_FSSETXATTR: | ||
| 776 | return xfs_ioc_xattr(ip, filp, cmd, arg); | ||
| 777 | |||
| 778 | case XFS_IOC_FSSETDM: { | ||
| 779 | struct fsdmidata dmi; | ||
| 780 | |||
| 781 | if (copy_from_user(&dmi, arg, sizeof(dmi))) | ||
| 782 | return -XFS_ERROR(EFAULT); | ||
| 783 | |||
| 784 | error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask, | ||
| 785 | dmi.fsd_dmstate); | ||
| 786 | return -error; | ||
| 787 | } | ||
| 788 | |||
| 789 | case XFS_IOC_GETBMAP: | ||
| 790 | case XFS_IOC_GETBMAPA: | ||
| 791 | return xfs_ioc_getbmap(ip, ioflags, cmd, arg); | ||
| 792 | |||
| 793 | case XFS_IOC_GETBMAPX: | ||
| 794 | return xfs_ioc_getbmapx(ip, arg); | ||
| 795 | |||
| 796 | case XFS_IOC_FD_TO_HANDLE: | ||
| 797 | case XFS_IOC_PATH_TO_HANDLE: | ||
| 798 | case XFS_IOC_PATH_TO_FSHANDLE: | ||
| 799 | return xfs_find_handle(cmd, arg); | ||
| 800 | |||
| 801 | case XFS_IOC_OPEN_BY_HANDLE: | ||
| 802 | return xfs_open_by_handle(mp, arg, filp, inode); | ||
| 803 | |||
| 804 | case XFS_IOC_FSSETDM_BY_HANDLE: | ||
| 805 | return xfs_fssetdm_by_handle(mp, arg, inode); | ||
| 806 | |||
| 807 | case XFS_IOC_READLINK_BY_HANDLE: | ||
| 808 | return xfs_readlink_by_handle(mp, arg, inode); | ||
| 809 | |||
| 810 | case XFS_IOC_ATTRLIST_BY_HANDLE: | ||
| 811 | return xfs_attrlist_by_handle(mp, arg, inode); | ||
| 812 | |||
| 813 | case XFS_IOC_ATTRMULTI_BY_HANDLE: | ||
| 814 | return xfs_attrmulti_by_handle(mp, arg, inode); | ||
| 815 | |||
| 816 | case XFS_IOC_SWAPEXT: { | ||
| 817 | error = xfs_swapext((struct xfs_swapext __user *)arg); | ||
| 818 | return -error; | ||
| 819 | } | ||
| 820 | |||
| 821 | case XFS_IOC_FSCOUNTS: { | ||
| 822 | xfs_fsop_counts_t out; | ||
| 823 | |||
| 824 | error = xfs_fs_counts(mp, &out); | ||
| 825 | if (error) | ||
| 826 | return -error; | ||
| 827 | |||
| 828 | if (copy_to_user(arg, &out, sizeof(out))) | ||
| 829 | return -XFS_ERROR(EFAULT); | ||
| 830 | return 0; | ||
| 831 | } | ||
| 832 | |||
| 833 | case XFS_IOC_SET_RESBLKS: { | ||
| 834 | xfs_fsop_resblks_t inout; | ||
| 835 | __uint64_t in; | ||
| 836 | |||
| 837 | if (!capable(CAP_SYS_ADMIN)) | ||
| 838 | return -EPERM; | ||
| 839 | |||
| 840 | if (copy_from_user(&inout, arg, sizeof(inout))) | ||
| 841 | return -XFS_ERROR(EFAULT); | ||
| 842 | |||
| 843 | /* input parameter is passed in resblks field of structure */ | ||
| 844 | in = inout.resblks; | ||
| 845 | error = xfs_reserve_blocks(mp, &in, &inout); | ||
| 846 | if (error) | ||
| 847 | return -error; | ||
| 848 | |||
| 849 | if (copy_to_user(arg, &inout, sizeof(inout))) | ||
| 850 | return -XFS_ERROR(EFAULT); | ||
| 851 | return 0; | ||
| 852 | } | ||
| 853 | |||
| 854 | case XFS_IOC_GET_RESBLKS: { | ||
| 855 | xfs_fsop_resblks_t out; | ||
| 856 | |||
| 857 | if (!capable(CAP_SYS_ADMIN)) | ||
| 858 | return -EPERM; | ||
| 859 | |||
| 860 | error = xfs_reserve_blocks(mp, NULL, &out); | ||
| 861 | if (error) | ||
| 862 | return -error; | ||
| 863 | |||
| 864 | if (copy_to_user(arg, &out, sizeof(out))) | ||
| 865 | return -XFS_ERROR(EFAULT); | ||
| 866 | |||
| 867 | return 0; | ||
| 868 | } | ||
| 869 | |||
| 870 | case XFS_IOC_FSGROWFSDATA: { | ||
| 871 | xfs_growfs_data_t in; | ||
| 872 | |||
| 873 | if (!capable(CAP_SYS_ADMIN)) | ||
| 874 | return -EPERM; | ||
| 875 | |||
| 876 | if (copy_from_user(&in, arg, sizeof(in))) | ||
| 877 | return -XFS_ERROR(EFAULT); | ||
| 878 | |||
| 879 | error = xfs_growfs_data(mp, &in); | ||
| 880 | return -error; | ||
| 881 | } | ||
| 882 | |||
| 883 | case XFS_IOC_FSGROWFSLOG: { | ||
| 884 | xfs_growfs_log_t in; | ||
| 885 | |||
| 886 | if (!capable(CAP_SYS_ADMIN)) | ||
| 887 | return -EPERM; | ||
| 888 | |||
| 889 | if (copy_from_user(&in, arg, sizeof(in))) | ||
| 890 | return -XFS_ERROR(EFAULT); | ||
| 891 | |||
| 892 | error = xfs_growfs_log(mp, &in); | ||
| 893 | return -error; | ||
| 894 | } | ||
| 895 | |||
| 896 | case XFS_IOC_FSGROWFSRT: { | ||
| 897 | xfs_growfs_rt_t in; | ||
| 898 | |||
| 899 | if (!capable(CAP_SYS_ADMIN)) | ||
| 900 | return -EPERM; | ||
| 901 | |||
| 902 | if (copy_from_user(&in, arg, sizeof(in))) | ||
| 903 | return -XFS_ERROR(EFAULT); | ||
| 904 | |||
| 905 | error = xfs_growfs_rt(mp, &in); | ||
| 906 | return -error; | ||
| 907 | } | ||
| 908 | |||
| 909 | case XFS_IOC_FREEZE: | ||
| 910 | if (!capable(CAP_SYS_ADMIN)) | ||
| 911 | return -EPERM; | ||
| 912 | |||
| 913 | if (inode->i_sb->s_frozen == SB_UNFROZEN) | ||
| 914 | freeze_bdev(inode->i_sb->s_bdev); | ||
| 915 | return 0; | ||
| 916 | |||
| 917 | case XFS_IOC_THAW: | ||
| 918 | if (!capable(CAP_SYS_ADMIN)) | ||
| 919 | return -EPERM; | ||
| 920 | if (inode->i_sb->s_frozen != SB_UNFROZEN) | ||
| 921 | thaw_bdev(inode->i_sb->s_bdev, inode->i_sb); | ||
| 922 | return 0; | ||
| 923 | |||
| 924 | case XFS_IOC_GOINGDOWN: { | ||
| 925 | __uint32_t in; | ||
| 926 | |||
| 927 | if (!capable(CAP_SYS_ADMIN)) | ||
| 928 | return -EPERM; | ||
| 929 | |||
| 930 | if (get_user(in, (__uint32_t __user *)arg)) | ||
| 931 | return -XFS_ERROR(EFAULT); | ||
| 932 | |||
| 933 | error = xfs_fs_goingdown(mp, in); | ||
| 934 | return -error; | ||
| 935 | } | ||
| 936 | |||
| 937 | case XFS_IOC_ERROR_INJECTION: { | ||
| 938 | xfs_error_injection_t in; | ||
| 939 | |||
| 940 | if (!capable(CAP_SYS_ADMIN)) | ||
| 941 | return -EPERM; | ||
| 942 | |||
| 943 | if (copy_from_user(&in, arg, sizeof(in))) | ||
| 944 | return -XFS_ERROR(EFAULT); | ||
| 945 | |||
| 946 | error = xfs_errortag_add(in.errtag, mp); | ||
| 947 | return -error; | ||
| 948 | } | ||
| 949 | |||
| 950 | case XFS_IOC_ERROR_CLEARALL: | ||
| 951 | if (!capable(CAP_SYS_ADMIN)) | ||
| 952 | return -EPERM; | ||
| 953 | |||
| 954 | error = xfs_errortag_clearall(mp, 1); | ||
| 955 | return -error; | ||
| 956 | |||
| 957 | default: | ||
| 958 | return -ENOTTY; | ||
| 959 | } | ||
| 960 | } | ||
| 961 | |||
| 962 | STATIC int | 654 | STATIC int | 
| 963 | xfs_ioc_space( | 655 | xfs_ioc_space( | 
| 964 | struct xfs_inode *ip, | 656 | struct xfs_inode *ip, | 
| @@ -1398,12 +1090,10 @@ xfs_ioctl( | |||
| 1398 | return xfs_ioc_fsgetxattr(ip, 0, arg); | 1090 | return xfs_ioc_fsgetxattr(ip, 0, arg); | 
| 1399 | case XFS_IOC_FSGETXATTRA: | 1091 | case XFS_IOC_FSGETXATTRA: | 
| 1400 | return xfs_ioc_fsgetxattr(ip, 1, arg); | 1092 | return xfs_ioc_fsgetxattr(ip, 1, arg); | 
| 1401 | case XFS_IOC_FSSETXATTR: | ||
| 1402 | return xfs_ioc_fssetxattr(ip, filp, arg); | ||
| 1403 | case XFS_IOC_GETXFLAGS: | 1093 | case XFS_IOC_GETXFLAGS: | 
| 1404 | return xfs_ioc_getxflags(ip, arg); | ||
| 1405 | case XFS_IOC_SETXFLAGS: | 1094 | case XFS_IOC_SETXFLAGS: | 
| 1406 | return xfs_ioc_setxflags(ip, filp, arg); | 1095 | case XFS_IOC_FSSETXATTR: | 
| 1096 | return xfs_ioc_xattr(ip, filp, cmd, arg); | ||
| 1407 | 1097 | ||
| 1408 | case XFS_IOC_FSSETDM: { | 1098 | case XFS_IOC_FSSETDM: { | 
| 1409 | struct fsdmidata dmi; | 1099 | struct fsdmidata dmi; | 
