kernels/linux-2.4.0/drivers/i2o/i2o_block.c
/*
 *	Issue device specific ioctl calls.
 */
Issue device specific ioctl calls.
Issue device specific ioctl calls .
static int i2ob_ioctl(struct inode *inode, struct file *file,
		     unsigned int cmd, unsigned long arg)
{
	struct i2ob_device *dev;
	int minor;
	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;
	if (!inode)
		return -EINVAL;
	minor = MINOR(inode->i_rdev);
	if (minor >= (MAX_I2OB<<4))
		return -ENODEV;
	dev = &i2ob_dev[minor];
	switch (cmd) {
		case BLKGETSIZE:
			return put_user(i2ob[minor].nr_sects, (long *) arg);
		case HDIO_GETGEO:
		{
			struct hd_geometry g;
			int u=minor&0xF0;
			i2o_block_biosparam(i2ob_sizes[u]<<1, 
				&g.cylinders, &g.heads, &g.sectors);
			g.start = i2ob[minor].start_sect;
			return copy_to_user((void *)arg,&g, sizeof(g))?-EFAULT:0;
		}
		case BLKRRPART:
			if(!capable(CAP_SYS_ADMIN))
				return -EACCES;
			return do_i2ob_revalidate(inode->i_rdev,1);
		case BLKFLSBUF:
		case BLKROSET:
		case BLKROGET:
		case BLKRASET:
		case BLKRAGET:
		case BLKPG:
			return blk_ioctl(inode->i_rdev, cmd, arg);
		default:
			return -EINVAL;
	}
}
static int i2ob_ioctl ( struct inode * inode , struct file * file , unsigned int cmd , unsigned long arg ) { struct i2ob_device * dev ; int minor ; if ( ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ; if ( ! inode ) return - EINVAL ; minor = MINOR ( inode -> i_rdev ) ; if ( minor >= ( MAX_I2OB << 4 ) ) return - ENODEV ; dev = & i2ob_dev [ minor ] ; switch ( cmd ) { case BLKGETSIZE : return put_user ( i2ob [ minor ] . nr_sects , ( long * ) arg ) ; case HDIO_GETGEO : { struct hd_geometry g ; int u = minor & 0xF0 ; i2o_block_biosparam ( i2ob_sizes [ u ] << 1 , & g . cylinders , & g . heads , & g . sectors ) ; g . start = i2ob [ minor ] . start_sect ; return copy_to_user ( ( void * ) arg , & g , sizeof ( g ) ) ? - EFAULT : 0 ; } case BLKRRPART : if ( ! capable ( CAP_SYS_ADMIN ) ) return - EACCES ; return do_i2ob_revalidate ( inode -> i_rdev , 1 ) ; case BLKFLSBUF : case BLKROSET : case BLKROGET : case BLKRASET : case BLKRAGET : case BLKPG : return blk_ioctl ( inode -> i_rdev , cmd , arg ) ; default : return - EINVAL ; } }
Issue device specific ioctl calls.
Issue device specific ioctl calls .
/* Anyone capable of this syscall can do *real bad* things */