linux_ioctl.c 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* $OpenBSD: linux_ioctl.c,v 1.12 2015/04/19 08:37:32 ratchov Exp $ */
  2. /* $NetBSD: linux_ioctl.c,v 1.14 1996/04/05 00:01:28 christos Exp $ */
  3. /*
  4. * Copyright (c) 1995 Frank van der Linden
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. All advertising materials mentioning features or use of this software
  16. * must display the following acknowledgement:
  17. * This product includes software developed for the NetBSD Project
  18. * by Frank van der Linden
  19. * 4. The name of the author may not be used to endorse or promote products
  20. * derived from this software without specific prior written permission
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  23. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <sys/param.h>
  34. #include <sys/systm.h>
  35. #include <sys/ioctl.h>
  36. #include <sys/mount.h>
  37. #include <sys/socket.h>
  38. #include <net/if.h>
  39. #include <sys/sockio.h>
  40. #include <sys/syscallargs.h>
  41. #include <compat/linux/linux_types.h>
  42. #include <compat/linux/linux_signal.h>
  43. #include <compat/linux/linux_syscallargs.h>
  44. #include <compat/linux/linux_ioctl.h>
  45. /*
  46. * Most ioctl command are just converted to their OpenBSD values,
  47. * and passed on. The ones that take structure pointers and (flag)
  48. * values need some massaging. This is done the usual way by
  49. * allocating stackgap memory, letting the actual ioctl call do its
  50. * work their and converting back the data afterwards.
  51. */
  52. int
  53. linux_sys_ioctl(p, v, retval)
  54. register struct proc *p;
  55. void *v;
  56. register_t *retval;
  57. {
  58. register struct linux_sys_ioctl_args /* {
  59. syscallarg(int) fd;
  60. syscallarg(u_long) com;
  61. syscallarg(caddr_t) data;
  62. } */ *uap = v;
  63. switch (LINUX_IOCGROUP(SCARG(uap, com))) {
  64. case 't':
  65. case 'f':
  66. case 'T': /* XXX MIDI sequencer uses 'T' as well */
  67. return linux_ioctl_termios(p, uap, retval);
  68. case 'S':
  69. return linux_ioctl_cdrom(p, uap, retval);
  70. case 'r': /* VFAT ioctls; not yet support */
  71. return (EINVAL);
  72. case 0x89:
  73. return linux_ioctl_socket(p, uap, retval);
  74. case 0x03:
  75. return linux_ioctl_hdio(p, uap, retval);
  76. case 0x02:
  77. return linux_ioctl_fdio(p, uap, retval);
  78. case 0x12:
  79. return linux_ioctl_blkio(p, uap, retval);
  80. default:
  81. return linux_machdepioctl(p, uap, retval);
  82. }
  83. }