Beispiel #1
0
int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned int arg)
{
	struct file * filp;
	int dev, mode;

	if (fd >= NR_OPEN || !(filp = current->filp[fd]))
		return -EBADF;
	if (filp->f_inode->i_pipe)
		return (filp->f_mode & 1) ? pipe_ioctl(filp->f_inode, cmd, arg) : -EBADF;
	mode = filp->f_inode->i_mode;
	if (!S_ISCHR(mode) && !S_ISBLK(mode))
		return -EINVAL;
	dev = filp->f_inode->i_zone[0];
	if (MAJOR(dev) >= NRDEVS)
		return -ENODEV;
	if (!ioctl_table[MAJOR(dev)])
		return -ENOTTY;
	return ioctl_table[MAJOR(dev)](dev, cmd, arg);
}
Beispiel #2
0
static int IMFS_fifo_ioctl(
    rtems_libio_t   *iop,
    ioctl_command_t  command,
    void            *buffer
)
{
    int err;

    if (command == FIONBIO) {
        if (buffer == NULL)
            err = -EFAULT;
        else {
            if (*(int *)buffer)
                iop->flags |= LIBIO_FLAGS_NO_DELAY;
            else
                iop->flags &= ~LIBIO_FLAGS_NO_DELAY;
            return 0;
        }
    }
    else
        err = pipe_ioctl(LIBIO2PIPE(iop), command, buffer, iop);

    IMFS_FIFO_RETURN(err);
}