root/arch/sparc/kernel/sunos_ioctl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sunos_ioctl

   1 /* $Id: sunos_ioctl.c,v 1.20 1996/04/25 06:09:08 davem Exp $
   2  * sunos_ioctl.c: The Linux Operating system: SunOS ioctl compatibility.
   3  * 
   4  * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
   5  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   6  */
   7 
   8 #include <asm/segment.h>
   9 
  10 #include <linux/sched.h>
  11 #include <linux/errno.h>
  12 #include <linux/string.h>
  13 #include <linux/termios.h>
  14 #include <linux/ioctl.h>
  15 #include <linux/route.h>
  16 #include <linux/sockios.h>
  17 #include <linux/if.h>
  18 #include <linux/netdevice.h>
  19 #include <linux/if_arp.h>
  20 #include <linux/fs.h>
  21 #include <linux/mm.h>
  22 #include <asm/kbio.h>
  23 
  24 #if 0
  25 extern char sunkbd_type;
  26 extern char sunkbd_layout;
  27 #endif
  28 
  29 extern asmlinkage int sys_ioctl(unsigned int, unsigned int, unsigned long);
  30 extern asmlinkage int sys_setsid(void);
  31 
  32 asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
  33 {
  34         struct file *filp;
  35         int foo;
  36 
  37         if (fd >= NR_OPEN || !(filp = current->files->fd [fd]))
  38                 return -EBADF;
  39 
  40         /* First handle an easy compat. case for tty ldisc. */
  41         if(cmd == TIOCSETD) {
  42                 int *p, ntty = N_TTY, old_fs;
  43 
  44                 p = (int *) arg;
  45                 foo = verify_area(VERIFY_WRITE, p, sizeof(int));
  46                 if(foo) return foo;
  47                 if(*p == 2) {
  48                         old_fs = get_fs();
  49                         set_fs(KERNEL_DS);
  50                         foo = sys_ioctl(fd, cmd, (int) &ntty);
  51                         set_fs(old_fs);
  52                         return (foo == -EINVAL ? -EOPNOTSUPP : foo);
  53                 }
  54         }
  55 
  56         /* Binary compatibility is good American knowhow fuckin' up. */
  57         if(cmd == TIOCNOTTY)
  58                 return sys_setsid();
  59 
  60         /* SunOS networking ioctls. */
  61         switch (cmd) {
  62         case _IOW('r', 10, struct rtentry):
  63                 return sys_ioctl(fd, SIOCADDRT, arg);
  64         case _IOW('r', 11, struct rtentry):
  65                 return sys_ioctl(fd, SIOCDELRT, arg);
  66         case _IOW('i', 12, struct ifreq):
  67                 return sys_ioctl(fd, SIOCSIFADDR, arg);
  68         case _IORW('i', 13, struct ifreq):
  69                 return sys_ioctl(fd, SIOCGIFADDR, arg);
  70         case _IOW('i', 14, struct ifreq):
  71                 return sys_ioctl(fd, SIOCSIFDSTADDR, arg);
  72         case _IORW('i', 15, struct ifreq):
  73                 return sys_ioctl(fd, SIOCGIFDSTADDR, arg);
  74         case _IOW('i', 16, struct ifreq):
  75                 return sys_ioctl(fd, SIOCSIFFLAGS, arg);
  76         case _IORW('i', 17, struct ifreq):
  77                 return sys_ioctl(fd, SIOCGIFFLAGS, arg);
  78         case _IOW('i', 18, struct ifreq):
  79                 return sys_ioctl(fd, SIOCSIFMEM, arg);
  80         case _IORW('i', 19, struct ifreq):
  81                 return sys_ioctl(fd, SIOCGIFMEM, arg);
  82         case _IORW('i', 20, struct ifconf):
  83                 return sys_ioctl(fd, SIOCGIFCONF, arg);
  84         case _IOW('i', 21, struct ifreq): /* SIOCSIFMTU */
  85                 return sys_ioctl(fd, SIOCSIFMTU, arg);
  86         case _IORW('i', 22, struct ifreq): /* SIOCGIFMTU */
  87                 return sys_ioctl(fd, SIOCGIFMTU, arg);
  88 
  89         case _IORW('i', 23, struct ifreq):
  90                 return sys_ioctl(fd, SIOCGIFBRDADDR, arg);
  91         case _IOW('i', 24, struct ifreq):
  92                 return sys_ioctl(fd, SIOCGIFBRDADDR, arg);
  93         case _IORW('i', 25, struct ifreq):
  94                 return sys_ioctl(fd, SIOCGIFNETMASK, arg);
  95         case _IOW('i', 26, struct ifreq):
  96                 return sys_ioctl(fd, SIOCSIFNETMASK, arg);
  97         case _IORW('i', 27, struct ifreq):
  98                 return sys_ioctl(fd, SIOCGIFMETRIC, arg);
  99         case _IOW('i', 28, struct ifreq):
 100                 return sys_ioctl(fd, SIOCSIFMETRIC, arg);
 101 
 102         case _IOW('i', 30, struct arpreq):
 103                 return sys_ioctl(fd, SIOCSARP, arg);
 104         case _IOW('i', 31, struct arpreq):
 105                 return sys_ioctl(fd, SIOCGARP, arg);
 106         case _IOW('i', 32, struct arpreq):
 107                 return sys_ioctl(fd, SIOCGARP, arg);
 108 
 109         case _IOW('i', 40, struct ifreq): /* SIOCUPPER */
 110         case _IOW('i', 41, struct ifreq): /* SIOCLOWER */
 111         case _IOW('i', 44, struct ifreq): /* SIOCSETSYNC */
 112         case _IOW('i', 45, struct ifreq): /* SIOCGETSYNC */
 113         case _IOW('i', 46, struct ifreq): /* SIOCSSDSTATS */
 114         case _IOW('i', 47, struct ifreq): /* SIOCSSESTATS */
 115         case _IOW('i', 48, struct ifreq): /* SIOCSPROMISC */
 116                 return -EOPNOTSUPP;
 117 
 118         case _IOW('i', 49, struct ifreq):
 119                 return sys_ioctl(fd, SIOCADDMULTI, arg);
 120         case _IOW('i', 50, struct ifreq):
 121                 return sys_ioctl(fd, SIOCDELMULTI, arg);
 122 
 123         /* FDDI interface ioctls, unsupported. */
 124                 
 125         case _IOW('i', 51, struct ifreq): /* SIOCFDRESET */
 126         case _IOW('i', 52, struct ifreq): /* SIOCFDSLEEP */
 127         case _IOW('i', 53, struct ifreq): /* SIOCSTRTFMWAR */
 128         case _IOW('i', 54, struct ifreq): /* SIOCLDNSTRTFW */
 129         case _IOW('i', 55, struct ifreq): /* SIOCGETFDSTAT */
 130         case _IOW('i', 56, struct ifreq): /* SIOCFDNMIINT */
 131         case _IOW('i', 57, struct ifreq): /* SIOCFDEXUSER */
 132         case _IOW('i', 58, struct ifreq): /* SIOCFDGNETMAP */
 133         case _IOW('i', 59, struct ifreq): /* SIOCFDGIOCTL */
 134                 printk("FDDI ioctl, returning EOPNOTSUPP\n");
 135                 return -EOPNOTSUPP;
 136         case _IOW('t', 125, int):
 137                 /* More stupid tty sunos ioctls, just
 138                  * say it worked.
 139                  */
 140                 return 0;
 141         /* Non posix grp */
 142         case _IOW('t', 118, int): {
 143                 int oldval, *ptr;
 144 
 145                 cmd = TIOCSPGRP;
 146                 ptr = (int *) arg;
 147                 oldval = verify_area(VERIFY_WRITE, ptr, sizeof(int));
 148                 if(oldval)
 149                         return oldval;
 150                 oldval = *ptr;
 151                 foo = sys_ioctl(fd, cmd, arg);
 152                 if(*ptr == -1) {
 153                         *ptr = oldval;
 154                         foo = -EIO;
 155                 }
 156                 if(foo == -ENOTTY)
 157                         foo = -EIO;
 158                 return foo;
 159         }
 160 
 161         case _IOR('t', 119, int): {
 162                 int oldval, *ptr;
 163 
 164                 cmd = TIOCGPGRP;
 165                 ptr = (int *) arg;
 166                 oldval = verify_area(VERIFY_WRITE, ptr, sizeof(int));
 167                 if(oldval)
 168                         return oldval;
 169                 oldval = *ptr;
 170                 foo = sys_ioctl(fd, cmd, arg);
 171                 if(*ptr == -1) {
 172                         *ptr = oldval;
 173                         foo = -EIO;
 174                 }
 175                 if(foo == -ENOTTY)
 176                         foo = -EIO;
 177                 return foo;
 178         }
 179         }
 180 
 181 #if 0
 182         if (cmd & 0xff00 == ('k' << 8)){
 183                 printk ("[[KBIO: %8.8x\n", (unsigned int) cmd);
 184         }
 185 #endif
 186 
 187         foo = sys_ioctl(fd, cmd, arg);
 188         /* so stupid... */
 189         return (foo == -EINVAL ? -EOPNOTSUPP : foo);
 190 }
 191 
 192 

/* [previous][next][first][last][top][bottom][index][help] */