__put_user(kt.c_iflag, &it->c_iflag); __put_user(kt.c_oflag, &it->c_oflag); __put_user(kt.c_cflag, &it->c_cflag); __put_user(kt.c_lflag, &it->c_lflag); for(error = 0; error < NCCS; error++) __put_user(kt.c_cc[error], &it->c_cc[error]); error = 0; 
 error = __put_user(kt.c_iflag, &it->c_iflag); error |= __put_user(kt.c_oflag, &it->c_oflag); error |= __put_user(kt.c_cflag, &it->c_cflag); error |= __put_user(kt.c_lflag, &it->c_lflag);  for (i = 0; i < NCCS; i++) error |= __put_user(kt.c_cc[i], &it->c_cc[i]); 
asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg){	struct tty_struct *tp, *rtp;	mm_segment_t old_fs;	int error = 0;#ifdef DEBUG_IOCTLS	printk("[%s:%d] irix_ioctl(%d, ", current->comm, current->pid, fd);#endif	switch(cmd) {	case 0x00005401:#ifdef DEBUG_IOCTLS		printk("TCGETA, %08lx) ", arg);#endif		error = sys_ioctl(fd, TCGETA, arg);		break;	case 0x0000540d: {		struct termios kt;		struct irix_termios *it = (struct irix_termios *) arg;#ifdef DEBUG_IOCTLS		printk("TCGETS, %08lx) ", arg);#endif		if(!access_ok(VERIFY_WRITE, it, sizeof(*it))) {			error = -EFAULT;			break;		}		old_fs = get_fs(); set_fs(get_ds());		error = sys_ioctl(fd, TCGETS, (unsigned long) &kt);		set_fs(old_fs);		if (error)			break;		__put_user(kt.c_iflag, &it->c_iflag);		__put_user(kt.c_oflag, &it->c_oflag);		__put_user(kt.c_cflag, &it->c_cflag);		__put_user(kt.c_lflag, &it->c_lflag);		for(error = 0; error < NCCS; error++)			__put_user(kt.c_cc[error], &it->c_cc[error]);		error = 0;		break;	}	case 0x0000540e: {		struct termios kt;		struct irix_termios *it = (struct irix_termios *) arg;#ifdef DEBUG_IOCTLS		printk("TCSETS, %08lx) ", arg);#endif		if (!access_ok(VERIFY_READ, it, sizeof(*it))) {			error = -EFAULT;			break;		}		old_fs = get_fs(); set_fs(get_ds());		error = sys_ioctl(fd, TCGETS, (unsigned long) &kt);		set_fs(old_fs);		if(error)			break;		__get_user(kt.c_iflag, &it->c_iflag);		__get_user(kt.c_oflag, &it->c_oflag);		__get_user(kt.c_cflag, &it->c_cflag);		__get_user(kt.c_lflag, &it->c_lflag);		for(error = 0; error < NCCS; error++)			__get_user(kt.c_cc[error], &it->c_cc[error]);		old_fs = get_fs(); set_fs(get_ds());		error = sys_ioctl(fd, TCSETS, (unsigned long) &kt);		set_fs(old_fs);		break;	}	case 0x0000540f:#ifdef DEBUG_IOCTLS		printk("TCSETSW, %08lx) ", arg);#endif		error = sys_ioctl(fd, TCSETSW, arg);		break;	case 0x00005471:#ifdef DEBUG_IOCTLS		printk("TIOCNOTTY, %08lx) ", arg);#endif		error = sys_ioctl(fd, TIOCNOTTY, arg);		break;	case 0x00007416:#ifdef DEBUG_IOCTLS		printk("TIOCGSID, %08lx) ", arg);#endif		tp = get_tty(fd);		if(!tp) {			error = -EINVAL;			break;		}		rtp = get_real_tty(tp);#ifdef DEBUG_IOCTLS		printk("rtp->session=%d ", rtp->session);#endif		error = put_user(rtp->session, (unsigned long *) arg);		break;	case 0x746e:		/* TIOCSTART, same effect as hitting ^Q */#ifdef DEBUG_IOCTLS		printk("TIOCSTART, %08lx) ", arg);#endif		tp = get_tty(fd);		if(!tp) {			error = -EINVAL;			break;		}		rtp = get_real_tty(tp);		start_tty(rtp);		break;	case 0x20006968:#ifdef DEBUG_IOCTLS		printk("SIOCGETLABEL, %08lx) ", arg);#endif		error = -ENOPKG;		break;	case 0x40047477:#ifdef DEBUG_IOCTLS		printk("TIOCGPGRP, %08lx) ", arg);#endif		error = sys_ioctl(fd, TIOCGPGRP, arg);#ifdef DEBUG_IOCTLS		printk("arg=%d ", *(int *)arg);#endif		break;	case 0x40087468:#ifdef DEBUG_IOCTLS		printk("TIOCGWINSZ, %08lx) ", arg);#endif		error = sys_ioctl(fd, TIOCGWINSZ, arg);		break;	case 0x8004667e:#ifdef DEBUG_IOCTLS		printk("FIONBIO, %08lx) arg=%d ", arg, *(int *)arg);#endif		error = sys_ioctl(fd, FIONBIO, arg);		break;	case 0x80047476:#ifdef DEBUG_IOCTLS		printk("TIOCSPGRP, %08lx) arg=%d ", arg, *(int *)arg);#endif		error = sys_ioctl(fd, TIOCSPGRP, arg);		break;	case 0x8020690c:#ifdef DEBUG_IOCTLS		printk("SIOCSIFADDR, %08lx) arg=%d ", arg, *(int *)arg);#endif		error = sys_ioctl(fd, SIOCSIFADDR, arg);		break;	case 0x80206910:#ifdef DEBUG_IOCTLS		printk("SIOCSIFFLAGS, %08lx) arg=%d ", arg, *(int *)arg);#endif		error = sys_ioctl(fd, SIOCSIFFLAGS, arg);		break;	case 0xc0206911:#ifdef DEBUG_IOCTLS		printk("SIOCGIFFLAGS, %08lx) arg=%d ", arg, *(int *)arg);#endif		error = sys_ioctl(fd, SIOCGIFFLAGS, arg);		break;	case 0xc020691b:#ifdef DEBUG_IOCTLS		printk("SIOCGIFMETRIC, %08lx) arg=%d ", arg, *(int *)arg);#endif		error = sys_ioctl(fd, SIOCGIFMETRIC, arg);		break;	default: {#ifdef DEBUG_MISSING_IOCTL		char *msg = "Unimplemented IOCTL cmd tell linux@engr.sgi.com\n";#ifdef DEBUG_IOCTLS		printk("UNIMP_IOCTL, %08lx)\n", arg);#endif		old_fs = get_fs(); set_fs(get_ds());		sys_write(2, msg, strlen(msg));		set_fs(old_fs);		printk("[%s:%d] Does unimplemented IRIX ioctl cmd %08lx\n",		       current->comm, current->pid, cmd);		do_exit(255);#else		error = sys_ioctl (fd, cmd, arg);#endif	}	};#ifdef DEBUG_IOCTLS	printk("error=%d\n", error);#endif	return error;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/1592dac2410511d24836e18d416b1d02c678322b/irixioctl.c/buggy/arch/mips/kernel/irixioctl.c