aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2005-11-16 03:52:57 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2005-11-16 03:52:57 -0500
commit6e87abd0b8cbb23ed9ffe5cc9f790fb5cac45eae (patch)
tree2469b23b6410153c7b25f03b6e5d3b846874a7d7 /fs
parent7b5603e056b8b5f3175f14badd895b9ac567f315 (diff)
[DVB]: Add compat ioctl handling.
Based upon a patch by Guido Guenther <agx@sigxcpu.org>. Some of these ioctls had embedded time_t objects or pointers, so needed translation. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/compat_ioctl.c133
1 files changed, 133 insertions, 0 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 26300fccb4f..f07e60f9e10 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -121,6 +121,11 @@
121 121
122#include <linux/hiddev.h> 122#include <linux/hiddev.h>
123 123
124#include <linux/dvb/audio.h>
125#include <linux/dvb/dmx.h>
126#include <linux/dvb/frontend.h>
127#include <linux/dvb/video.h>
128
124#undef INCLUDES 129#undef INCLUDES
125#endif 130#endif
126 131
@@ -413,6 +418,128 @@ out:
413 return err; 418 return err;
414} 419}
415 420
421struct compat_dmx_event {
422 dmx_event_t event;
423 compat_time_t timeStamp;
424 union
425 {
426 dmx_scrambling_status_t scrambling;
427 } u;
428};
429
430static int do_dmx_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
431{
432 struct dmx_event kevent;
433 mm_segment_t old_fs = get_fs();
434 int err;
435
436 set_fs(KERNEL_DS);
437 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
438 set_fs(old_fs);
439
440 if (!err) {
441 struct compat_dmx_event __user *up = compat_ptr(arg);
442
443 err = put_user(kevent.event, &up->event);
444 err |= put_user(kevent.timeStamp, &up->timeStamp);
445 err |= put_user(kevent.u.scrambling, &up->u.scrambling);
446 if (err)
447 err = -EFAULT;
448 }
449
450 return err;
451}
452
453struct compat_video_event {
454 int32_t type;
455 compat_time_t timestamp;
456 union {
457 video_size_t size;
458 unsigned int frame_rate;
459 } u;
460};
461
462static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg)
463{
464 struct video_event kevent;
465 mm_segment_t old_fs = get_fs();
466 int err;
467
468 set_fs(KERNEL_DS);
469 err = sys_ioctl(fd, cmd, (unsigned long) &kevent);
470 set_fs(old_fs);
471
472 if (!err) {
473 struct compat_video_event __user *up = compat_ptr(arg);
474
475 err = put_user(kevent.type, &up->type);
476 err |= put_user(kevent.timestamp, &up->timestamp);
477 err |= put_user(kevent.u.size.w, &up->u.size.w);
478 err |= put_user(kevent.u.size.h, &up->u.size.h);
479 err |= put_user(kevent.u.size.aspect_ratio,
480 &up->u.size.aspect_ratio);
481 if (err)
482 err = -EFAULT;
483 }
484
485 return err;
486}
487
488struct compat_video_still_picture {
489 compat_uptr_t iFrame;
490 int32_t size;
491};
492
493static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg)
494{
495 struct compat_video_still_picture __user *up;
496 struct video_still_picture __user *up_native;
497 compat_uptr_t fp;
498 int32_t size;
499 int err;
500
501 up = (struct compat_video_still_picture __user *) arg;
502 err = get_user(fp, &up->iFrame);
503 err |= get_user(size, &up->size);
504 if (err)
505 return -EFAULT;
506
507 up_native =
508 compat_alloc_user_space(sizeof(struct video_still_picture));
509
510 put_user(compat_ptr(fp), &up_native->iFrame);
511 put_user(size, &up_native->size);
512
513 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
514
515 return err;
516}
517
518struct compat_video_spu_palette {
519 int length;
520 compat_uptr_t palette;
521};
522
523static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg)
524{
525 struct compat_video_spu_palette __user *up;
526 struct video_spu_palette __user *up_native;
527 compat_uptr_t palp;
528 int length, err;
529
530 up = (struct compat_video_spu_palette __user *) arg;
531 err = get_user(palp, &up->palette);
532 err |= get_user(length, &up->length);
533
534 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
535 put_user(compat_ptr(palp), &up_native->palette);
536 put_user(length, &up_native->length);
537
538 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
539
540 return err;
541}
542
416#ifdef CONFIG_NET 543#ifdef CONFIG_NET
417static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg) 544static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
418{ 545{
@@ -2954,5 +3081,11 @@ HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
2954HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata) 3081HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
2955#endif 3082#endif
2956 3083
3084/* dvb */
3085HANDLE_IOCTL(DMX_GET_EVENT, do_dmx_get_event)
3086HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
3087HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
3088HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette)
3089
2957#undef DECLARES 3090#undef DECLARES
2958#endif 3091#endif