示例#1
0
文件: ioctl.c 项目: sarnobat/knoppix
static inline int solaris_r(unsigned int fd, unsigned int cmd, u32 arg)
{
	switch (cmd & 0xff) {
	case 10: /* SIOCADDRT */
		return compat_sys_ioctl(fd, SIOCADDRT, arg);
	case 11: /* SIOCDELRT */
		return compat_sys_ioctl(fd, SIOCDELRT, arg);
	}
	return -ENOSYS;
}
示例#2
0
asmlinkage int sunos_ioctl (int fd, u32 cmd, u32 arg)
{
	int ret = -EBADF;

	if(fd >= SUNOS_NR_OPEN)
		goto out;
	if(!fcheck(fd))
		goto out;

	if(cmd == TIOCSETD) {
		mm_segment_t old_fs = get_fs();
		int __user *p;
		int ntty = N_TTY;
		int tmp;

		p = (int __user *) (unsigned long) arg;
		ret = -EFAULT;
		if(get_user(tmp, p))
			goto out;
		if(tmp == 2) {
			set_fs(KERNEL_DS);
			ret = sys_ioctl(fd, cmd, (unsigned long) &ntty);
			set_fs(old_fs);
			ret = (ret == -EINVAL ? -EOPNOTSUPP : ret);
			goto out;
		}
	}
	if(cmd == TIOCNOTTY) {
		ret = sys_setsid();
		goto out;
	}
	switch(cmd) {
	case _IOW('r', 10, struct rtentry32):
		ret = compat_sys_ioctl(fd, SIOCADDRT, arg);
		goto out;
	case _IOW('r', 11, struct rtentry32):
		ret = compat_sys_ioctl(fd, SIOCDELRT, arg);
		goto out;

	case _IOW('i', 12, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFADDR, arg);
		goto out;
	case _IOWR('i', 13, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFADDR, arg);
		goto out;
	case _IOW('i', 14, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFDSTADDR, arg);
		goto out;
	case _IOWR('i', 15, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFDSTADDR, arg);
		goto out;
	case _IOW('i', 16, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFFLAGS, arg);
		goto out;
	case _IOWR('i', 17, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFFLAGS, arg);
		goto out;
	case _IOW('i', 18, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFMEM, arg);
		goto out;
	case _IOWR('i', 19, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFMEM, arg);
		goto out;

	case _IOWR('i', 20, struct ifconf32):
		ret = compat_sys_ioctl(fd, SIOCGIFCONF, arg);
		goto out;

	case _IOW('i', 21, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFMTU, arg);
		goto out;

	case _IOWR('i', 22, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFMTU, arg);
		goto out;

	case _IOWR('i', 23, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFBRDADDR, arg);
		goto out;
	case _IOW('i', 24, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFBRDADDR, arg);
		goto out;
	case _IOWR('i', 25, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFNETMASK, arg);
		goto out;
	case _IOW('i', 26, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFNETMASK, arg);
		goto out;
	case _IOWR('i', 27, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCGIFMETRIC, arg);
		goto out;
	case _IOW('i', 28, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCSIFMETRIC, arg);
		goto out;

	case _IOW('i', 30, struct arpreq):
		ret = compat_sys_ioctl(fd, SIOCSARP, arg);
		goto out;
	case _IOWR('i', 31, struct arpreq):
		ret = compat_sys_ioctl(fd, SIOCGARP, arg);
		goto out;
	case _IOW('i', 32, struct arpreq):
		ret = compat_sys_ioctl(fd, SIOCDARP, arg);
		goto out;

	case _IOW('i', 40, struct ifreq32): /* SIOCUPPER */
	case _IOW('i', 41, struct ifreq32): /* SIOCLOWER */
	case _IOW('i', 44, struct ifreq32): /* SIOCSETSYNC */
	case _IOW('i', 45, struct ifreq32): /* SIOCGETSYNC */
	case _IOW('i', 46, struct ifreq32): /* SIOCSSDSTATS */
	case _IOW('i', 47, struct ifreq32): /* SIOCSSESTATS */
	case _IOW('i', 48, struct ifreq32): /* SIOCSPROMISC */
		ret = -EOPNOTSUPP;
		goto out;

	case _IOW('i', 49, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCADDMULTI, arg);
		goto out;
	case _IOW('i', 50, struct ifreq32):
		ret = compat_sys_ioctl(fd, SIOCDELMULTI, arg);
		goto out;

	/* FDDI interface ioctls, unsupported. */
		
	case _IOW('i', 51, struct ifreq32): /* SIOCFDRESET */
	case _IOW('i', 52, struct ifreq32): /* SIOCFDSLEEP */
	case _IOW('i', 53, struct ifreq32): /* SIOCSTRTFMWAR */
	case _IOW('i', 54, struct ifreq32): /* SIOCLDNSTRTFW */
	case _IOW('i', 55, struct ifreq32): /* SIOCGETFDSTAT */
	case _IOW('i', 56, struct ifreq32): /* SIOCFDNMIINT */
	case _IOW('i', 57, struct ifreq32): /* SIOCFDEXUSER */
	case _IOW('i', 58, struct ifreq32): /* SIOCFDGNETMAP */
	case _IOW('i', 59, struct ifreq32): /* SIOCFDGIOCTL */
		printk("FDDI ioctl, returning EOPNOTSUPP\n");
		ret = -EOPNOTSUPP;
		goto out;

	case _IOW('t', 125, int):
		/* More stupid tty sunos ioctls, just
		 * say it worked.
		 */
		ret = 0;
		goto out;

	/* Non posix grp */
	case _IOW('t', 118, int): {
		int oldval, newval, __user *ptr;

		cmd = TIOCSPGRP;
		ptr = (int __user *) (unsigned long) arg;
		ret = -EFAULT;
		if(get_user(oldval, ptr))
			goto out;
		ret = compat_sys_ioctl(fd, cmd, arg);
		__get_user(newval, ptr);
		if(newval == -1) {
			__put_user(oldval, ptr);
			ret = -EIO;
		}
		if(ret == -ENOTTY)
			ret = -EIO;
		goto out;
	}

	case _IOR('t', 119, int): {
		int oldval, newval, __user *ptr;

		cmd = TIOCGPGRP;
		ptr = (int __user *) (unsigned long) arg;
		ret = -EFAULT;
		if(get_user(oldval, ptr))
			goto out;
		ret = compat_sys_ioctl(fd, cmd, arg);
		__get_user(newval, ptr);
		if(newval == -1) {
			__put_user(oldval, ptr);
			ret = -EIO;
		}
		if(ret == -ENOTTY)
			ret = -EIO;
		goto out;
	}
	};

	ret = compat_sys_ioctl(fd, cmd, arg);
	/* so stupid... */
	ret = (ret == -EINVAL ? -EOPNOTSUPP : ret);
out:
	return ret;
}
示例#3
0
文件: ioctl.c 项目: sarnobat/knoppix
static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg)
{
	switch (cmd & 0xff) {
	case 12: /* SIOCSIFADDR */
		return compat_sys_ioctl(fd, SIOCSIFADDR, arg);
	case 13: /* SIOCGIFADDR */
		return compat_sys_ioctl(fd, SIOCGIFADDR, arg);
	case 14: /* SIOCSIFDSTADDR */
		return compat_sys_ioctl(fd, SIOCSIFDSTADDR, arg);
	case 15: /* SIOCGIFDSTADDR */
		return compat_sys_ioctl(fd, SIOCGIFDSTADDR, arg);
	case 16: /* SIOCSIFFLAGS */
		return compat_sys_ioctl(fd, SIOCSIFFLAGS, arg);
	case 17: /* SIOCGIFFLAGS */
		return compat_sys_ioctl(fd, SIOCGIFFLAGS, arg);
	case 18: /* SIOCSIFMEM */
		return compat_sys_ioctl(fd, SIOCSIFMEM, arg);
	case 19: /* SIOCGIFMEM */
		return compat_sys_ioctl(fd, SIOCGIFMEM, arg);
	case 20: /* SIOCGIFCONF */
		return compat_sys_ioctl(fd, SIOCGIFCONF, arg);
	case 21: /* SIOCSIFMTU */
		return compat_sys_ioctl(fd, SIOCSIFMTU, arg);
	case 22: /* SIOCGIFMTU */
		return compat_sys_ioctl(fd, SIOCGIFMTU, arg);
	case 23: /* SIOCGIFBRDADDR */
		return compat_sys_ioctl(fd, SIOCGIFBRDADDR, arg);
	case 24: /* SIOCSIFBRDADDR */
		return compat_sys_ioctl(fd, SIOCSIFBRDADDR, arg);
	case 25: /* SIOCGIFNETMASK */
		return compat_sys_ioctl(fd, SIOCGIFNETMASK, arg);
	case 26: /* SIOCSIFNETMASK */
		return compat_sys_ioctl(fd, SIOCSIFNETMASK, arg);
	case 27: /* SIOCGIFMETRIC */
		return compat_sys_ioctl(fd, SIOCGIFMETRIC, arg);
	case 28: /* SIOCSIFMETRIC */
		return compat_sys_ioctl(fd, SIOCSIFMETRIC, arg);
	case 30: /* SIOCSARP */
		return compat_sys_ioctl(fd, SIOCSARP, arg);
	case 31: /* SIOCGARP */
		return compat_sys_ioctl(fd, SIOCGARP, arg);
	case 32: /* SIOCDARP */
		return compat_sys_ioctl(fd, SIOCDARP, arg);
	case 52: /* SIOCGETNAME */
	case 53: /* SIOCGETPEER */
		{
			struct sockaddr uaddr;
			int uaddr_len = sizeof(struct sockaddr), ret;
			long args[3];
			mm_segment_t old_fs = get_fs();
			int (*sys_socketcall)(int, unsigned long *) =
				(int (*)(int, unsigned long *))SYS(socketcall);
			
			args[0] = fd; args[1] = (long)&uaddr; args[2] = (long)&uaddr_len;
			set_fs(KERNEL_DS);
			ret = sys_socketcall(((cmd & 0xff) == 52) ? SYS_GETSOCKNAME : SYS_GETPEERNAME,
					args);
			set_fs(old_fs);
			if (ret >= 0) {
				if (copy_to_user((char *)A(arg), &uaddr, uaddr_len))
					return -EFAULT;
			}
			return ret;
		}
#if 0		
	case 86: /* SIOCSOCKSYS */
		return socksys_syscall(fd, arg);
#endif		
	case 87: /* SIOCGIFNUM */
		{
			struct net_device *d;
			int i = 0;
			
			read_lock_bh(&dev_base_lock);
			for (d = dev_base; d; d = d->next) i++;
			read_unlock_bh(&dev_base_lock);

			if (put_user (i, (int *)A(arg)))
				return -EFAULT;
			return 0;
		}
	}
	return -ENOSYS;
}