diff options
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r-- | fs/compat_ioctl.c | 156 |
1 files changed, 12 insertions, 144 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 43dbcb0b21eb..26300fccb4fc 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -840,146 +840,6 @@ static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
840 | return err ? -EFAULT : 0; | 840 | return err ? -EFAULT : 0; |
841 | } | 841 | } |
842 | 842 | ||
843 | struct fb_fix_screeninfo32 { | ||
844 | char id[16]; | ||
845 | compat_caddr_t smem_start; | ||
846 | u32 smem_len; | ||
847 | u32 type; | ||
848 | u32 type_aux; | ||
849 | u32 visual; | ||
850 | u16 xpanstep; | ||
851 | u16 ypanstep; | ||
852 | u16 ywrapstep; | ||
853 | u32 line_length; | ||
854 | compat_caddr_t mmio_start; | ||
855 | u32 mmio_len; | ||
856 | u32 accel; | ||
857 | u16 reserved[3]; | ||
858 | }; | ||
859 | |||
860 | struct fb_cmap32 { | ||
861 | u32 start; | ||
862 | u32 len; | ||
863 | compat_caddr_t red; | ||
864 | compat_caddr_t green; | ||
865 | compat_caddr_t blue; | ||
866 | compat_caddr_t transp; | ||
867 | }; | ||
868 | |||
869 | static int fb_getput_cmap(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
870 | { | ||
871 | struct fb_cmap_user __user *cmap; | ||
872 | struct fb_cmap32 __user *cmap32; | ||
873 | __u32 data; | ||
874 | int err; | ||
875 | |||
876 | cmap = compat_alloc_user_space(sizeof(*cmap)); | ||
877 | cmap32 = compat_ptr(arg); | ||
878 | |||
879 | if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32))) | ||
880 | return -EFAULT; | ||
881 | |||
882 | if (get_user(data, &cmap32->red) || | ||
883 | put_user(compat_ptr(data), &cmap->red) || | ||
884 | get_user(data, &cmap32->green) || | ||
885 | put_user(compat_ptr(data), &cmap->green) || | ||
886 | get_user(data, &cmap32->blue) || | ||
887 | put_user(compat_ptr(data), &cmap->blue) || | ||
888 | get_user(data, &cmap32->transp) || | ||
889 | put_user(compat_ptr(data), &cmap->transp)) | ||
890 | return -EFAULT; | ||
891 | |||
892 | err = sys_ioctl(fd, cmd, (unsigned long) cmap); | ||
893 | |||
894 | if (!err) { | ||
895 | if (copy_in_user(&cmap32->start, | ||
896 | &cmap->start, | ||
897 | 2 * sizeof(__u32))) | ||
898 | err = -EFAULT; | ||
899 | } | ||
900 | return err; | ||
901 | } | ||
902 | |||
903 | static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix, | ||
904 | struct fb_fix_screeninfo32 __user *fix32) | ||
905 | { | ||
906 | __u32 data; | ||
907 | int err; | ||
908 | |||
909 | err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id)); | ||
910 | |||
911 | data = (__u32) (unsigned long) fix->smem_start; | ||
912 | err |= put_user(data, &fix32->smem_start); | ||
913 | |||
914 | err |= put_user(fix->smem_len, &fix32->smem_len); | ||
915 | err |= put_user(fix->type, &fix32->type); | ||
916 | err |= put_user(fix->type_aux, &fix32->type_aux); | ||
917 | err |= put_user(fix->visual, &fix32->visual); | ||
918 | err |= put_user(fix->xpanstep, &fix32->xpanstep); | ||
919 | err |= put_user(fix->ypanstep, &fix32->ypanstep); | ||
920 | err |= put_user(fix->ywrapstep, &fix32->ywrapstep); | ||
921 | err |= put_user(fix->line_length, &fix32->line_length); | ||
922 | |||
923 | data = (__u32) (unsigned long) fix->mmio_start; | ||
924 | err |= put_user(data, &fix32->mmio_start); | ||
925 | |||
926 | err |= put_user(fix->mmio_len, &fix32->mmio_len); | ||
927 | err |= put_user(fix->accel, &fix32->accel); | ||
928 | err |= copy_to_user(fix32->reserved, fix->reserved, | ||
929 | sizeof(fix->reserved)); | ||
930 | |||
931 | return err; | ||
932 | } | ||
933 | |||
934 | static int fb_get_fscreeninfo(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
935 | { | ||
936 | mm_segment_t old_fs; | ||
937 | struct fb_fix_screeninfo fix; | ||
938 | struct fb_fix_screeninfo32 __user *fix32; | ||
939 | int err; | ||
940 | |||
941 | fix32 = compat_ptr(arg); | ||
942 | |||
943 | old_fs = get_fs(); | ||
944 | set_fs(KERNEL_DS); | ||
945 | err = sys_ioctl(fd, cmd, (unsigned long) &fix); | ||
946 | set_fs(old_fs); | ||
947 | |||
948 | if (!err) | ||
949 | err = do_fscreeninfo_to_user(&fix, fix32); | ||
950 | |||
951 | return err; | ||
952 | } | ||
953 | |||
954 | static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
955 | { | ||
956 | int err; | ||
957 | |||
958 | switch (cmd) { | ||
959 | case FBIOGET_FSCREENINFO: | ||
960 | err = fb_get_fscreeninfo(fd,cmd, arg); | ||
961 | break; | ||
962 | |||
963 | case FBIOGETCMAP: | ||
964 | case FBIOPUTCMAP: | ||
965 | err = fb_getput_cmap(fd, cmd, arg); | ||
966 | break; | ||
967 | |||
968 | default: | ||
969 | do { | ||
970 | static int count; | ||
971 | if (++count <= 20) | ||
972 | printk("%s: Unknown fb ioctl cmd fd(%d) " | ||
973 | "cmd(%08x) arg(%08lx)\n", | ||
974 | __FUNCTION__, fd, cmd, arg); | ||
975 | } while(0); | ||
976 | err = -ENOSYS; | ||
977 | break; | ||
978 | }; | ||
979 | |||
980 | return err; | ||
981 | } | ||
982 | |||
983 | static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 843 | static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
984 | { | 844 | { |
985 | mm_segment_t old_fs = get_fs(); | 845 | mm_segment_t old_fs = get_fs(); |
@@ -2235,7 +2095,8 @@ static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
2235 | if (err) | 2095 | if (err) |
2236 | err = -EFAULT; | 2096 | err = -EFAULT; |
2237 | 2097 | ||
2238 | out: if (karg) kfree(karg); | 2098 | out: |
2099 | kfree(karg); | ||
2239 | return err; | 2100 | return err; |
2240 | } | 2101 | } |
2241 | 2102 | ||
@@ -2952,10 +2813,7 @@ HANDLE_IOCTL(BLKGETSIZE, w_long) | |||
2952 | HANDLE_IOCTL(0x1260, broken_blkgetsize) | 2813 | HANDLE_IOCTL(0x1260, broken_blkgetsize) |
2953 | HANDLE_IOCTL(BLKFRAGET, w_long) | 2814 | HANDLE_IOCTL(BLKFRAGET, w_long) |
2954 | HANDLE_IOCTL(BLKSECTGET, w_long) | 2815 | HANDLE_IOCTL(BLKSECTGET, w_long) |
2955 | HANDLE_IOCTL(FBIOGET_FSCREENINFO, fb_ioctl_trans) | ||
2956 | HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) | 2816 | HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) |
2957 | HANDLE_IOCTL(FBIOGETCMAP, fb_ioctl_trans) | ||
2958 | HANDLE_IOCTL(FBIOPUTCMAP, fb_ioctl_trans) | ||
2959 | HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans) | 2817 | HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans) |
2960 | HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans) | 2818 | HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans) |
2961 | HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans) | 2819 | HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans) |
@@ -3050,6 +2908,16 @@ HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) | |||
3050 | COMPATIBLE_IOCTL(TIOCGLTC) | 2908 | COMPATIBLE_IOCTL(TIOCGLTC) |
3051 | COMPATIBLE_IOCTL(TIOCSLTC) | 2909 | COMPATIBLE_IOCTL(TIOCSLTC) |
3052 | #endif | 2910 | #endif |
2911 | #ifdef TIOCSTART | ||
2912 | /* | ||
2913 | * For these two we have defintions in ioctls.h and/or termios.h on | ||
2914 | * some architectures but no actual implemention. Some applications | ||
2915 | * like bash call them if they are defined in the headers, so we provide | ||
2916 | * entries here to avoid syslog message spew. | ||
2917 | */ | ||
2918 | COMPATIBLE_IOCTL(TIOCSTART) | ||
2919 | COMPATIBLE_IOCTL(TIOCSTOP) | ||
2920 | #endif | ||
3053 | /* Usbdevfs */ | 2921 | /* Usbdevfs */ |
3054 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) | 2922 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) |
3055 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) | 2923 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) |