void __init change_floppy(char *fmt, ...) { struct termios termios; char buf[80]; char c; int fd; va_list args; va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0); if (fd >= 0) { sys_ioctl(fd, FDEJECT, 0); sys_close(fd); } printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf); fd = sys_open("/dev/console", O_RDWR, 0); if (fd >= 0) { sys_ioctl(fd, TCGETS, (long)&termios); termios.c_lflag &= ~ICANON; sys_ioctl(fd, TCSETSF, (long)&termios); sys_read(fd, &c, 1); termios.c_lflag |= ICANON; sys_ioctl(fd, TCSETSF, (long)&termios); sys_close(fd); } }
static int rtc32_ioctl(unsigned fd, unsigned cmd, unsigned long arg) { unsigned long val; mm_segment_t oldfs = get_fs(); int ret; switch (cmd) { case RTC_IRQP_READ32: set_fs(KERNEL_DS); ret = sys_ioctl(fd, RTC_IRQP_READ, (unsigned long)&val); set_fs(oldfs); if (!ret) ret = put_user(val, (unsigned int __user *) arg); return ret; case RTC_IRQP_SET32: cmd = RTC_IRQP_SET; break; case RTC_EPOCH_READ32: set_fs(KERNEL_DS); ret = sys_ioctl(fd, RTC_EPOCH_READ, (unsigned long) &val); set_fs(oldfs); if (!ret) ret = put_user(val, (unsigned int __user *) arg); return ret; case RTC_EPOCH_SET32: cmd = RTC_EPOCH_SET; break; } return sys_ioctl(fd,cmd,arg); }
static int drm32_getsetunique(unsigned int fd, unsigned int cmd, unsigned long arg) { drm32_unique_t __user *uarg = (drm32_unique_t __user *)arg; drm_unique_t __user *p = compat_alloc_user_space(sizeof(*p)); compat_uptr_t addr; int n; int ret; if (get_user(n, &uarg->unique_len) || put_user(n, &p->unique_len) || get_user(addr, &uarg->unique) || put_user(compat_ptr(addr), &p->unique)) return -EFAULT; if (cmd == DRM32_IOCTL_GET_UNIQUE) ret = sys_ioctl (fd, DRM_IOCTL_GET_UNIQUE, (unsigned long)p); else ret = sys_ioctl (fd, DRM_IOCTL_SET_UNIQUE, (unsigned long)p); if (ret) return ret; if (get_user(n, &p->unique_len) || put_user(n, &uarg->unique_len)) return -EFAULT; return 0; }
static int solaris_m(unsigned int fd, unsigned int cmd, u32 arg) { int ret; switch (cmd & 0xff) { case 1: /* MTIOCTOP */ ret = sys_ioctl(fd, MTIOCTOP, (unsigned long)&arg); break; case 2: /* MTIOCGET */ ret = sys_ioctl(fd, MTIOCGET, (unsigned long)&arg); break; case 3: /* MTIOCGETDRIVETYPE */ case 4: /* MTIOCPERSISTENT */ case 5: /* MTIOCPERSISTENTSTATUS */ case 6: /* MTIOCLRERR */ case 7: /* MTIOCGUARANTEEDORDER */ case 8: /* MTIOCRESERVE */ case 9: /* MTIOCRELEASE */ case 10: /* MTIOCFORCERESERVE */ case 13: /* MTIOCSTATE */ case 14: /* MTIOCREADIGNOREILI */ case 15: /* MTIOCREADIGNOREEOFS */ case 16: /* MTIOCSHORTFMK */ default: ret = -ENOSYS; /* linux doesn't support these */ break; }; return ret; }
static inline int solaris_T(unsigned int fd, unsigned int cmd, u32 arg) { switch (cmd & 0xff) { case 1: /* TCGETA */ return linux_to_solaris_termio(fd, TCGETA, arg); case 2: /* TCSETA */ return solaris_to_linux_termio(fd, TCSETA, arg); case 3: /* TCSETAW */ return solaris_to_linux_termio(fd, TCSETAW, arg); case 4: /* TCSETAF */ return solaris_to_linux_termio(fd, TCSETAF, arg); case 5: /* TCSBRK */ return sys_ioctl(fd, TCSBRK, arg); case 6: /* TCXONC */ return sys_ioctl(fd, TCXONC, arg); case 7: /* TCFLSH */ return sys_ioctl(fd, TCFLSH, arg); case 13: /* TCGETS */ return linux_to_solaris_termios(fd, TCGETS, arg); case 14: /* TCSETS */ return solaris_to_linux_termios(fd, TCSETS, arg); case 15: /* TCSETSW */ return solaris_to_linux_termios(fd, TCSETSW, arg); case 16: /* TCSETSF */ return solaris_to_linux_termios(fd, TCSETSF, arg); case 103: /* TIOCSWINSZ */ return sys_ioctl(fd, TIOCSWINSZ, arg); case 104: /* TIOCGWINSZ */ return sys_ioctl(fd, TIOCGWINSZ, arg); } return -ENOSYS; }
static int pci_init(pci_bus_cookie *cookie) { id_list *vendor_ids; id_list *device_ids; int err; device dev; int i,j; int fd; struct pci_cfg cfg; int pp; vendor_ids = kmalloc(sizeof(id_list) + sizeof(uint32)); vendor_ids->num_ids = 1; vendor_ids->id[0] = _INTEL_VENDORID; device_ids = kmalloc(sizeof(id_list) + sizeof(uint32)); device_ids->num_ids = 1; device_ids->id[0] = _82371AB_DEVICE_ID; err = bus_find_device(1, vendor_ids, device_ids, &dev); if(err < 0) { TRACE(("unable to pci find controller\n")); err = -1; goto err; } fd = sys_open(dev.dev_path,STREAM_TYPE_DEVICE,0); sys_ioctl(fd, PCI_DUMP_CFG, NULL, 0); sys_ioctl(fd, PCI_GET_CFG, &cfg, sizeof(struct pci_cfg)); sys_close(fd); cookie->io_port = dev.base[4]; cookie->busMasterActivated = /*(buffer[0x9] & 0x80)!=0*/true; if(cookie->channel==0) { cookie->irq = 0x14; cookie->base_reg = 0x1F0; cookie->status_reg = 0x200 + cookie->base_reg; } else { cookie->irq = 0x15; cookie->base_reg = 0x170; cookie->status_reg = 0x200 + cookie->base_reg; } TRACE(("pci_init:irq=%X\n",cfg.irq)); TRACE(("pci_init:header=%X\n",cfg.header_type)); TRACE(("pci_init: found device at '%s'\n", dev.dev_path)); for(i=0; i<MAX_DEV_IO_RANGES; i++) { TRACE(("pci_init: found device at base '%X'\n", dev.base[i])); } TRACE(("pci_init: found device at irq '%X'\n", dev.irq)); err: kfree(vendor_ids); kfree(device_ids); return err; }
/* * Description : open uart * Input : None * Output : success : 0 fail : others */ int felica_uart_open(void) { // struct termios newtio; int rc; mm_segment_t old_fs = get_fs(); #ifdef FEATURE_DEBUG_LOW FELICA_DEBUG_MSG("[FELICA_UART] open_hs_uart - start \n"); #endif if(0 <= fd) { FELICA_DEBUG_MSG("[FELICA_UART] felica_uart is already opened fd : %d\n",fd); return 0; } set_fs(KERNEL_DS); fd = sys_open("/dev/ttyO3", O_RDWR | O_NOCTTY | O_NONBLOCK, 0); FELICA_DEBUG_MSG("[FELICA_UART] open UART - fd : %d \n",fd); if (fd < 0) { FELICA_DEBUG_MSG("[FELICA_UART] ERROR - can not sys_open \n"); set_fs(old_fs); return fd; } { /* Set speed */ struct termios newtio; // yjchoi; 120412 temporary block due to build error serial_omap_disable_console_port(); // yjchoi; 120412 temporary block due to build error rc = felica_gpio_open(GPIO_FELICA_UART_SW, GPIO_DIRECTION_OUT, GPIO_LOW_VALUE); felica_gpio_write(GPIO_FELICA_UART_SW, 0); sys_ioctl(fd, TCGETS, (unsigned long)&newtio); memcpy(&console_settings, &newtio, sizeof(struct termios)); memset(&newtio, 0, sizeof(newtio)); newtio.c_cflag = B460800 | CS8 | CLOCAL | CREAD; newtio.c_cc[VMIN] = 1; newtio.c_cc[VTIME] = 5; sys_ioctl(fd, TCFLSH, TCIOFLUSH); sys_ioctl(fd, TCSETSF, (unsigned long)&newtio); } set_fs(old_fs); #ifdef FEATURE_DEBUG_LOW FELICA_DEBUG_MSG("[FELICA_UART] open_hs_uart - end \n"); #endif return 0; }
static inline int solaris_t(unsigned int fd, unsigned int cmd, u32 arg) { switch (cmd & 0xff) { case 20: /* TIOCGPGRP */ return sys_ioctl(fd, TIOCGPGRP, arg); case 21: /* TIOCSPGRP */ return sys_ioctl(fd, TIOCSPGRP, arg); } return -ENOSYS; }
/* * Description : close uart * Input : None * Output : success : 0 */ int felica_uart_close(void) { mm_segment_t old_fs = get_fs(); #ifdef FEATURE_DEBUG_LOW FELICA_DEBUG_MSG("[FELICA_UART] close_hs_uart - start \n"); #endif if(0 > fd) { FELICA_DEBUG_MSG("[FELICA_UART] felica_uart is not opened\n"); return 0; } set_fs(KERNEL_DS); { /* Set speed */ struct termios settings; sys_ioctl(fd, TCGETS, (unsigned long)&settings); #if 1 memcpy(&settings, &console_settings, sizeof(struct termios)); FELICA_DEBUG_MSG("[FELICA_UART] Set BAUD rate to 115200\n"); #else if((settings.c_cflag & CBAUD) == B460800) { settings.c_cflag &= ~(CBAUD); settings.c_cflag |= B115200; FELICA_DEBUG_MSG("[FELICA_UART] Set BAUD rate to 115200\n"); } #endif sys_ioctl(fd, TCSETS, (unsigned long)&settings); } sys_close(fd); fd = -1; felica_gpio_write(GPIO_FELICA_UART_SW, 1); // yjchoi; 120412 temporary block due to build error serial_omap_enable_console_port(); set_fs(old_fs); #ifdef FEATURE_DEBUG_LOW FELICA_DEBUG_MSG("[FELICA_UART] close_hs_uart - end \n"); #endif return 0; }
static int drm32_getsetunique(unsigned int fd, unsigned int cmd, unsigned long arg) { drm32_unique_t __user *uarg = (drm32_unique_t __user *)arg; drm_unique_t karg; mm_segment_t old_fs; char __user *uptr; u32 tmp; int ret; if (get_user(karg.unique_len, &uarg->unique_len)) return -EFAULT; karg.unique = NULL; if (get_user(tmp, &uarg->unique)) return -EFAULT; uptr = A(tmp); if (uptr) { karg.unique = kmalloc(karg.unique_len, GFP_KERNEL); if (!karg.unique) return -ENOMEM; if (cmd == DRM32_IOCTL_SET_UNIQUE && copy_from_user(karg.unique, uptr, karg.unique_len)) { kfree(karg.unique); return -EFAULT; } } old_fs = get_fs(); set_fs(KERNEL_DS); if (cmd == DRM32_IOCTL_GET_UNIQUE) ret = sys_ioctl (fd, DRM_IOCTL_GET_UNIQUE, (unsigned long)&karg); else ret = sys_ioctl (fd, DRM_IOCTL_SET_UNIQUE, (unsigned long)&karg); set_fs(old_fs); if (!ret) { if (cmd == DRM32_IOCTL_GET_UNIQUE && uptr != NULL && copy_to_user(uptr, karg.unique, karg.unique_len)) ret = -EFAULT; if (put_user(karg.unique_len, &uarg->unique_len)) ret = -EFAULT; } if (karg.unique != NULL) kfree(karg.unique); return ret; }
static int hpux_ioctl_t(int fd, unsigned long cmd, unsigned long arg) { int result = -EOPNOTSUPP; int nr = _IOC_NR(cmd); switch (nr) { case 106: result = sys_ioctl(fd, TIOCSWINSZ, arg); break; case 107: result = sys_ioctl(fd, TIOCGWINSZ, arg); break; } return result; }
static int loop_status(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *f) { mm_segment_t old_fs = get_fs(); struct loop_info l; int err = -EINVAL; switch(cmd) { case LOOP_SET_STATUS: err = get_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number); err |= __get_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device); err |= __get_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode); err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice); err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset, 8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset); if (err) { err = -EFAULT; } else { set_fs (KERNEL_DS); err = sys_ioctl (fd, cmd, (unsigned long)&l); set_fs (old_fs); } break; case LOOP_GET_STATUS: set_fs (KERNEL_DS); err = sys_ioctl (fd, cmd, (unsigned long)&l); set_fs (old_fs); if (!err) { err = put_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number); err |= __put_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device); err |= __put_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode); err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice); err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset, (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset); if (err) err = -EFAULT; } break; default: { static int count = 0; if (++count <= 20) printk("%s: Unknown loop ioctl cmd, fd(%d) " "cmd(%08x) arg(%08lx)\n", __FUNCTION__, fd, cmd, arg); } } return err; }
int freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap) { struct ioctl_args ap /*{ int fd; u_long com; caddr_t data; }*/ ; struct file *fp; cap_rights_t rights; int error; error = fget(td, uap->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); if (error != 0) return (error); if ((fp->f_flag & (FREAD | FWRITE)) == 0) { fdrop(fp, td); return (EBADF); } switch (uap->com) { case MDIOCATTACH_32: /* FALLTHROUGH */ case MDIOCDETACH_32: /* FALLTHROUGH */ case MDIOCQUERY_32: /* FALLTHROUGH */ case MDIOCLIST_32: error = freebsd32_ioctl_md(td, uap, fp); break; case CDIOREADTOCENTRYS_32: error = freebsd32_ioctl_ioc_read_toc(td, uap, fp); break; case FIODGNAME_32: error = freebsd32_ioctl_fiodgname(td, uap, fp); break; case MEMRANGE_GET32: /* FALLTHROUGH */ case MEMRANGE_SET32: error = freebsd32_ioctl_memrange(td, uap, fp); break; case PCIOCGETCONF_32: error = freebsd32_ioctl_pciocgetconf(td, uap, fp); break; case SG_IO_32: error = freebsd32_ioctl_sg(td, uap, fp); break; default: fdrop(fp, td); ap.fd = uap->fd; ap.com = uap->com; PTRIN_CP(*uap, ap, data); return sys_ioctl(td, &ap); } fdrop(fp, td); return error; }
static inline int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) { struct rtentry32 *ur = (struct rtentry32 *) A(arg); struct rtentry r; char devname[16]; u32 rtdev; int ret; mm_segment_t old_fs = get_fs(); ret = copy_from_user (&r.rt_dst, &(ur->rt_dst), 3 * sizeof(struct sockaddr)); ret |= __get_user (r.rt_flags, &(ur->rt_flags)); ret |= __get_user (r.rt_metric, &(ur->rt_metric)); ret |= __get_user (r.rt_mtu, &(ur->rt_mtu)); ret |= __get_user (r.rt_window, &(ur->rt_window)); ret |= __get_user (r.rt_irtt, &(ur->rt_irtt)); ret |= __get_user (rtdev, &(ur->rt_dev)); if (rtdev) { ret |= copy_from_user (devname, (char *) A(rtdev), 15); r.rt_dev = devname; devname[15] = 0; } else r.rt_dev = 0; if (ret) return -EFAULT; set_fs (KERNEL_DS); ret = sys_ioctl (fd, cmd, (long)&r); set_fs (old_fs); return ret; }
static inline int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg) { struct ifreq32 *uifr = (struct ifreq32 *) A(arg); struct ifreq ifr; mm_segment_t old_fs; int err; switch (cmd) { case SIOCSIFMAP: err = copy_from_user(&ifr, uifr, sizeof(ifr.ifr_name)); err |= __get_user(ifr.ifr_map.mem_start, &(uifr->ifr_ifru.ifru_map.mem_start)); err |= __get_user(ifr.ifr_map.mem_end, &(uifr->ifr_ifru.ifru_map.mem_end)); err |= __get_user(ifr.ifr_map.base_addr, &(uifr->ifr_ifru.ifru_map.base_addr)); err |= __get_user(ifr.ifr_map.irq, &(uifr->ifr_ifru.ifru_map.irq)); err |= __get_user(ifr.ifr_map.dma, &(uifr->ifr_ifru.ifru_map.dma)); err |= __get_user(ifr.ifr_map.port, &(uifr->ifr_ifru.ifru_map.port)); if (err) return -EFAULT; break; default: if (copy_from_user(&ifr, uifr, sizeof(struct ifreq32))) return -EFAULT; break; } old_fs = get_fs(); set_fs (KERNEL_DS); err = sys_ioctl (fd, cmd, (unsigned long)&ifr); set_fs (old_fs); if (!err) { switch (cmd) { case SIOCGIFFLAGS: case SIOCGIFMETRIC: case SIOCGIFMTU: case SIOCGIFMEM: case SIOCGIFHWADDR: case SIOCGIFINDEX: case SIOCGIFADDR: case SIOCGIFBRDADDR: case SIOCGIFDSTADDR: case SIOCGIFNETMASK: case SIOCGIFTXQLEN: if (copy_to_user(uifr, &ifr, sizeof(struct ifreq32))) return -EFAULT; break; case SIOCGIFMAP: err = copy_to_user(uifr, &ifr, sizeof(ifr.ifr_name)); err |= __put_user(ifr.ifr_map.mem_start, &(uifr->ifr_ifru.ifru_map.mem_start)); err |= __put_user(ifr.ifr_map.mem_end, &(uifr->ifr_ifru.ifru_map.mem_end)); err |= __put_user(ifr.ifr_map.base_addr, &(uifr->ifr_ifru.ifru_map.base_addr)); err |= __put_user(ifr.ifr_map.irq, &(uifr->ifr_ifru.ifru_map.irq)); err |= __put_user(ifr.ifr_map.dma, &(uifr->ifr_ifru.ifru_map.dma)); err |= __put_user(ifr.ifr_map.port, &(uifr->ifr_ifru.ifru_map.port)); if (err) err = -EFAULT; break; } } return err; }
/* * Description : get size of remaing data * Input : none * Output : success : data length fail : 0 */ int felica_uart_ioctrl(int *count) { mm_segment_t old_fs = get_fs(); int rc = 0; #ifdef FEATURE_DEBUG_LOW FELICA_DEBUG_MSG("[FELICA_UART] felica_uart_ioctrl - start \n"); #endif if(0 > fd) { FELICA_DEBUG_MSG("[FELICA_UART] felica_uart is not opened\n"); return rc; } set_fs(KERNEL_DS); rc = sys_ioctl(fd, TIOCINQ, (unsigned long)count); set_fs(old_fs); #ifdef FEATURE_DEBUG_LOW FELICA_DEBUG_MSG("[FELICA_UART] felica_uart_ioctrl - end \n"); #endif return rc; }
static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg) { struct ncp_privatedata_ioctl_32 n32; struct ncp_privatedata_ioctl n; mm_segment_t old_fs; int err; size_t tl; if (copy_from_user(&n32, (struct ncp_privatedata_ioctl_32*)arg, sizeof(n32))) return -EFAULT; n.len = tl = n32.len; if (tl) { n.data = kmalloc(tl, GFP_KERNEL); if (!n.data) return -ENOMEM; err = -EFAULT; if (copy_from_user(n.data, (void *)A(n32.data), tl)) goto out; } else { n.data = NULL; } old_fs = get_fs(); set_fs (KERNEL_DS); err = sys_ioctl (fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)&n); set_fs (old_fs); out: if (n.data) kfree(n.data); return err; }
static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg) { struct ncp_objectname_ioctl_32 n32; struct ncp_objectname_ioctl n; mm_segment_t old_fs; int err; size_t tl; if (copy_from_user(&n32, (struct ncp_objectname_ioctl_32*)arg, sizeof(n32))) return -EFAULT; n.auth_type = n32.auth_type; n.object_name_len = tl = n32.object_name_len; if (tl) { n.object_name = kmalloc(tl, GFP_KERNEL); if (!n.object_name) return -ENOMEM; err = -EFAULT; if (copy_from_user(n.object_name, (void *)A(n32.object_name), tl)) goto out; } else { n.object_name = NULL; } old_fs = get_fs(); set_fs (KERNEL_DS); err = sys_ioctl (fd, NCP_IOC_SETOBJECTNAME, (unsigned long)&n); set_fs (old_fs); out: if (n.object_name) kfree(n.object_name); return err; }
static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg) { mm_segment_t old_fs = get_fs(); struct ncp_fs_info_v2_32 n32; struct ncp_fs_info_v2 n; int err; if (copy_from_user(&n32, (struct ncp_fs_info_v2_32*)arg, sizeof(n32))) return -EFAULT; if (n32.version != NCP_GET_FS_INFO_VERSION_V2) return -EINVAL; n.version = NCP_GET_FS_INFO_VERSION_V2; set_fs(KERNEL_DS); err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n); set_fs(old_fs); if (!err) { n32.version = n.version; n32.mounted_uid = n.mounted_uid; n32.connection = n.connection; n32.buffer_size = n.buffer_size; n32.volume_number = n.volume_number; n32.directory_id = n.directory_id; n32.dummy1 = n.dummy1; n32.dummy2 = n.dummy2; n32.dummy3 = n.dummy3; err = copy_to_user((struct ncp_fs_info_v2_32*)arg, &n32, sizeof(n32)) ? -EFAULT : 0; } return err; }
static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long uarg, struct file *f) { struct blkpg_ioctl_arg a; struct blkpg_partition p; struct blkpg_ioctl_arg32 *arg = (void*)A(uarg); int err; mm_segment_t old_fs = get_fs(); err = get_user(a.op, &arg->op); err |= __get_user(a.flags, &arg->flags); err |= __get_user(a.datalen, &arg->datalen); err |= __get_user((long)a.data, &arg->data); if (err) return err; switch (a.op) { case BLKPG_ADD_PARTITION: case BLKPG_DEL_PARTITION: if (a.datalen < sizeof(struct blkpg_partition)) return -EINVAL; if (copy_from_user(&p, a.data, sizeof(struct blkpg_partition))) return -EFAULT; a.data = &p; set_fs (KERNEL_DS); err = sys_ioctl(fd, cmd, (unsigned long)&a); set_fs (old_fs); default: return -EINVAL; } return err; }
static int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg) { struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p)); struct fbcursor32 __user *argp = (void __user *)arg; compat_uptr_t addr; int ret; ret = copy_in_user(p, argp, 2 * sizeof (short) + 2 * sizeof(struct fbcurpos)); ret |= copy_in_user(&p->size, &argp->size, sizeof(struct fbcurpos)); ret |= copy_in_user(&p->cmap, &argp->cmap, 2 * sizeof(int)); ret |= get_user(addr, &argp->cmap.red); ret |= put_user(compat_ptr(addr), &p->cmap.red); ret |= get_user(addr, &argp->cmap.green); ret |= put_user(compat_ptr(addr), &p->cmap.green); ret |= get_user(addr, &argp->cmap.blue); ret |= put_user(compat_ptr(addr), &p->cmap.blue); ret |= get_user(addr, &argp->mask); ret |= put_user(compat_ptr(addr), &p->mask); ret |= get_user(addr, &argp->image); ret |= put_user(compat_ptr(addr), &p->image); if (ret) return -EFAULT; return sys_ioctl (fd, FBIOSCURSOR, (unsigned long)p); }
static int osf1_ioctl_i(struct lwp *l, const struct sys_ioctl_args *uap, register_t *retval, int cmd, int dir, int len) { switch (cmd) { case 12: /* OSF/1 SIOCSIFADDR */ case 14: /* OSF/1 SIOCSIFDSTADDR */ case 16: /* OSF/1 SIOCSIFFLAGS (XXX) */ case 17: /* OSF/1 SIOCGIFFLAGS (XXX) */ case 19: /* OSF/1 SIOCSIFBRDADDR */ case 22: /* OSF/1 SIOCSIFNETMASK */ case 23: /* OSF/1 SIOCGIFMETRIC */ case 24: /* OSF/1 SIOCSIFMETRIC */ case 25: /* OSF/1 SIOCDIFADDR */ case 33: /* OSF/1 SIOCGIFADDR */ case 34: /* OSF/1 SIOCGIFDSTADDR */ case 35: /* OSF/1 SIOCGIFBRDADDR */ case 37: /* OSF/1 SIOCGIFNETMASK */ /* same as in NetBSD */ break; default: return (ENOTTY); } return sys_ioctl(l, uap, retval); }
static int osf1_ioctl_t(struct lwp *l, const struct sys_ioctl_args *uap, register_t *retval, int cmd, int dir, int len) { switch (cmd) { #ifdef COMPAT_43 case 8: /* OSF/1 COMPAT_43 TIOCGETP (XXX) */ case 9: /* OSF/1 COMPAT_43 TIOCSETP (XXX) */ #endif case 19: /* OSF/1 TIOCGETA (XXX) */ case 20: /* OSF/1 TIOCSETA (XXX) */ case 21: /* OSF/1 TIOCSETAW (XXX) */ case 22: /* OSF/1 TIOCSETAF (XXX) */ case 26: /* OSF/1 TIOCGETD (XXX) */ case 27: /* OSF/1 TIOCSETD (XXX) */ case 97: /* OSF/1 TIOCSCTTY */ case 103: /* OSF/1 TIOCSWINSZ */ case 104: /* OSF/1 TIOCGWINSZ */ /* same as in NetBSD */ break; default: return (ENOTTY); } return sys_ioctl(l, uap, retval); }
static int drm32_free_bufs(unsigned int fd, unsigned int cmd, unsigned long arg) { drm32_buf_free_t __user *uarg = (drm32_buf_free_t __user *)arg; drm_buf_free_t karg; mm_segment_t old_fs; int __user *ulist; int ret; u32 tmp; if (get_user(karg.count, &uarg->count) || get_user(tmp, &uarg->list)) return -EFAULT; ulist = A(tmp); karg.list = kmalloc(karg.count * sizeof(int), GFP_KERNEL); if (!karg.list) return -ENOMEM; ret = -EFAULT; if (copy_from_user(karg.list, ulist, (karg.count * sizeof(int)))) goto out; old_fs = get_fs(); set_fs(KERNEL_DS); ret = sys_ioctl(fd, DRM_IOCTL_FREE_BUFS, (unsigned long) &karg); set_fs(old_fs); out: kfree(karg.list); return ret; }
int hpux_ioctl(int fd, unsigned long cmd, unsigned long arg) { int result = -EOPNOTSUPP; int type = _IOC_TYPE(cmd); switch (type) { case 'T': /* Our structures are now compatible with HPUX's */ result = sys_ioctl(fd, cmd, arg); break; case 't': result = hpux_ioctl_t(fd, cmd, arg); break; default: /* If my mother ever sees this, I hope she disowns me. * Take this out after NYLWE. */ result = sys_ioctl(fd, cmd, arg); } return result; }
static int do_ext2_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) { /* These are just misnamed, they actually get/put from/to user an int */ switch (cmd) { case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break; case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break; case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break; case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break; } return sys_ioctl(fd, cmd, arg); }
static inline int solaris_s(unsigned int fd, unsigned int cmd, u32 arg) { switch (cmd & 0xff) { case 0: /* SIOCSHIWAT */ case 2: /* SIOCSLOWAT */ return 0; /* We don't support them */ case 1: /* SIOCGHIWAT */ case 3: /* SIOCGLOWAT */ if (put_user (0, (u32 *)A(arg))) return -EFAULT; return 0; /* Lie */ case 7: /* SIOCATMARK */ return sys_ioctl(fd, SIOCATMARK, arg); case 8: /* SIOCSPGRP */ return sys_ioctl(fd, SIOCSPGRP, arg); case 9: /* SIOCGPGRP */ return sys_ioctl(fd, SIOCGPGRP, arg); } return -ENOSYS; }
static inline int tty_ioctl(int fd, int cmd, int *arg) { int ret; ret = sys_ioctl(fd, cmd, (unsigned long)arg); if (ret < 0) { if (ret != -ENOTTY) return ret; *arg = 0; } return 0; }
static void initialise_window () { #if defined(have_sys_ioctl) && defined(TIOCGWINSZ) struct winsize size; if (sys_ioctl (0, TIOCGWINSZ, (long)&size) == 0) { width = size.ws_col; height = size.ws_row; } #endif }
linux_ioctl_rtc(struct proc *p, struct linux_ioctl_args *args) #endif { switch (args->cmd & 0xffff) { case LINUX_RTC_PIE_ON: args->cmd=RTCIO_PIE_ON; #if __FreeBSD_version >= 900044 return sys_ioctl(p, (struct ioctl_args*)args); #else return ioctl(p, (struct ioctl_args*)args); #endif case LINUX_RTC_IRQP_SET: args->cmd=RTCIO_IRQP_SET; #if __FreeBSD_version >= 900044 return sys_ioctl(p, (struct ioctl_args*)args); #else return ioctl(p, (struct ioctl_args*)args); #endif } return (ENOIOCTL); }