diff options
-rw-r--r-- | fs/compat_ioctl.c | 49 | ||||
-rw-r--r-- | fs/fat/dir.c | 56 |
2 files changed, 56 insertions, 49 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index e5eb0f10f05a..e1a56437040a 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -108,7 +108,6 @@ | |||
108 | #include <linux/nbd.h> | 108 | #include <linux/nbd.h> |
109 | #include <linux/random.h> | 109 | #include <linux/random.h> |
110 | #include <linux/filter.h> | 110 | #include <linux/filter.h> |
111 | #include <linux/msdos_fs.h> | ||
112 | #include <linux/pktcdvd.h> | 111 | #include <linux/pktcdvd.h> |
113 | 112 | ||
114 | #include <linux/hiddev.h> | 113 | #include <linux/hiddev.h> |
@@ -1937,51 +1936,6 @@ static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
1937 | return err; | 1936 | return err; |
1938 | } | 1937 | } |
1939 | 1938 | ||
1940 | #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2]) | ||
1941 | #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2]) | ||
1942 | |||
1943 | static long | ||
1944 | put_dirent32 (struct dirent *d, struct compat_dirent __user *d32) | ||
1945 | { | ||
1946 | if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent))) | ||
1947 | return -EFAULT; | ||
1948 | |||
1949 | __put_user(d->d_ino, &d32->d_ino); | ||
1950 | __put_user(d->d_off, &d32->d_off); | ||
1951 | __put_user(d->d_reclen, &d32->d_reclen); | ||
1952 | if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen)) | ||
1953 | return -EFAULT; | ||
1954 | |||
1955 | return 0; | ||
1956 | } | ||
1957 | |||
1958 | static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg) | ||
1959 | { | ||
1960 | struct compat_dirent __user *p = compat_ptr(arg); | ||
1961 | int ret; | ||
1962 | mm_segment_t oldfs = get_fs(); | ||
1963 | struct dirent d[2]; | ||
1964 | |||
1965 | switch(cmd) | ||
1966 | { | ||
1967 | case VFAT_IOCTL_READDIR_BOTH32: | ||
1968 | cmd = VFAT_IOCTL_READDIR_BOTH; | ||
1969 | break; | ||
1970 | case VFAT_IOCTL_READDIR_SHORT32: | ||
1971 | cmd = VFAT_IOCTL_READDIR_SHORT; | ||
1972 | break; | ||
1973 | } | ||
1974 | |||
1975 | set_fs(KERNEL_DS); | ||
1976 | ret = sys_ioctl(fd,cmd,(unsigned long)&d); | ||
1977 | set_fs(oldfs); | ||
1978 | if (ret >= 0) { | ||
1979 | ret |= put_dirent32(&d[0], p); | ||
1980 | ret |= put_dirent32(&d[1], p + 1); | ||
1981 | } | ||
1982 | return ret; | ||
1983 | } | ||
1984 | |||
1985 | struct raw32_config_request | 1939 | struct raw32_config_request |
1986 | { | 1940 | { |
1987 | compat_int_t raw_minor; | 1941 | compat_int_t raw_minor; |
@@ -2726,9 +2680,6 @@ HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) | |||
2726 | HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget) | 2680 | HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget) |
2727 | HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) | 2681 | HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) |
2728 | HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64) | 2682 | HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64) |
2729 | /* vfat */ | ||
2730 | HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32) | ||
2731 | HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32) | ||
2732 | /* Raw devices */ | 2683 | /* Raw devices */ |
2733 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) | 2684 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) |
2734 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) | 2685 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 698b85bb1dd4..3e50a4166283 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/dirent.h> | 20 | #include <linux/dirent.h> |
21 | #include <linux/smp_lock.h> | 21 | #include <linux/smp_lock.h> |
22 | #include <linux/buffer_head.h> | 22 | #include <linux/buffer_head.h> |
23 | #include <linux/compat.h> | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | 25 | ||
25 | static inline loff_t fat_make_i_pos(struct super_block *sb, | 26 | static inline loff_t fat_make_i_pos(struct super_block *sb, |
@@ -741,10 +742,65 @@ static int fat_dir_ioctl(struct inode * inode, struct file * filp, | |||
741 | return ret; | 742 | return ret; |
742 | } | 743 | } |
743 | 744 | ||
745 | #ifdef CONFIG_COMPAT | ||
746 | #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2]) | ||
747 | #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2]) | ||
748 | |||
749 | static long fat_compat_put_dirent32(struct dirent *d, | ||
750 | struct compat_dirent __user *d32) | ||
751 | { | ||
752 | if (!access_ok(VERIFY_WRITE, d32, sizeof(struct compat_dirent))) | ||
753 | return -EFAULT; | ||
754 | |||
755 | __put_user(d->d_ino, &d32->d_ino); | ||
756 | __put_user(d->d_off, &d32->d_off); | ||
757 | __put_user(d->d_reclen, &d32->d_reclen); | ||
758 | if (__copy_to_user(d32->d_name, d->d_name, d->d_reclen)) | ||
759 | return -EFAULT; | ||
760 | |||
761 | return 0; | ||
762 | } | ||
763 | |||
764 | static long fat_compat_dir_ioctl(struct file *file, unsigned cmd, | ||
765 | unsigned long arg) | ||
766 | { | ||
767 | struct compat_dirent __user *p = compat_ptr(arg); | ||
768 | int ret; | ||
769 | mm_segment_t oldfs = get_fs(); | ||
770 | struct dirent d[2]; | ||
771 | |||
772 | switch (cmd) { | ||
773 | case VFAT_IOCTL_READDIR_BOTH32: | ||
774 | cmd = VFAT_IOCTL_READDIR_BOTH; | ||
775 | break; | ||
776 | case VFAT_IOCTL_READDIR_SHORT32: | ||
777 | cmd = VFAT_IOCTL_READDIR_SHORT; | ||
778 | break; | ||
779 | default: | ||
780 | return -ENOIOCTLCMD; | ||
781 | } | ||
782 | |||
783 | set_fs(KERNEL_DS); | ||
784 | lock_kernel(); | ||
785 | ret = fat_dir_ioctl(file->f_dentry->d_inode, file, | ||
786 | cmd, (unsigned long) &d); | ||
787 | unlock_kernel(); | ||
788 | set_fs(oldfs); | ||
789 | if (ret >= 0) { | ||
790 | ret |= fat_compat_put_dirent32(&d[0], p); | ||
791 | ret |= fat_compat_put_dirent32(&d[1], p + 1); | ||
792 | } | ||
793 | return ret; | ||
794 | } | ||
795 | #endif /* CONFIG_COMPAT */ | ||
796 | |||
744 | const struct file_operations fat_dir_operations = { | 797 | const struct file_operations fat_dir_operations = { |
745 | .read = generic_read_dir, | 798 | .read = generic_read_dir, |
746 | .readdir = fat_readdir, | 799 | .readdir = fat_readdir, |
747 | .ioctl = fat_dir_ioctl, | 800 | .ioctl = fat_dir_ioctl, |
801 | #ifdef CONFIG_COMPAT | ||
802 | .compat_ioctl = fat_compat_dir_ioctl, | ||
803 | #endif | ||
748 | .fsync = file_fsync, | 804 | .fsync = file_fsync, |
749 | }; | 805 | }; |
750 | 806 | ||