示例#1
0
static int tbio_ioctl(struct inode *ino, struct file *file,
		      unsigned int cmd, unsigned long arg)
{
	int err;
//      request_queue_t *q;

	//q = bdev_get_queue(Device.bdev);

	printk("ttbio: ioctl 0x%x 0x%lx\n", cmd, arg);

	switch (cmd) {
	case LTP_TBIO_DO_IO:
		{
			err = bd_claim(Device.bdev, current);
			if (err) {
				printk("tbio:bd_claim\n");
				break;
			}

			err =
			    tbio_io(Device.bdev, (struct tbio_interface *)arg);
			bd_release(Device.bdev);
		}
		break;

	case LTP_TBIO_CLONE:
		err = test_bio_clone();
		break;
	case LTP_TBIO_ADD_PAGE:
		err = test_bio_add_page();
		break;
	case LTP_TBIO_ALLOC:
		err = test_bio_alloc();
		break;
	case LTP_TBIO_GET_NR_VECS:
		err = test_bio_get_nr_vecs();
		break;
	case LTP_TBIO_PUT:
		err = test_bio_put(tbiop);
		break;
	case LTP_TBIO_SPLIT:
		{
			err = bd_claim(Device.bdev, current);
			if (err) {
				printk("tbio:bd_claim\n");
				break;
			}

			err =
			    test_bio_split(Device.bdev,
					   (struct tbio_interface *)arg);
			bd_release(Device.bdev);

		}
		break;
		//case LTP_TBIO_PAIR_RELEASE:     err = test_bio_pair_release();break;

	}
	return 0;
}
示例#2
0
文件: ltp_tbio.c 项目: ArnoldWu/ltp
static int tbio_ioctl(struct block_device *blk, fmode_t mode,
	unsigned cmd, unsigned long arg)
{
	int err = 0;

	tbio_dev.bdev = blkdev_get_by_path(
		DEVICE_NAME, FMODE_READ | FMODE_WRITE, NULL);

	switch (cmd) {
	case LTP_TBIO_DO_IO:
		prk_info("TEST-CASE: LTP_TBIO_DO_IO:");
		err = tbio_io(tbio_dev.bdev, (struct tbio_interface *)arg);
	break;
	case LTP_TBIO_CLONE:
		prk_info("TEST-CASE: LTP_TBIO_CLONE:");
		err = test_bio_clone();
		break;
	case LTP_TBIO_ADD_PAGE:
		prk_info("TEST-CASE: LTP_TBIO_ADD_PAGE:");
		err = test_bio_add_page();
		break;
	case LTP_TBIO_ALLOC:
		prk_info("TEST-CASE: LTP_TBIO_ALLOC:");
		err = test_bio_alloc();
		break;
	case LTP_TBIO_GET_NR_VECS:
		prk_info("TEST-CASE: LTP_TBIO_GET_NR_VECS:");
		err = test_bio_get_nr_vecs();
		break;
	case LTP_TBIO_PUT:
		prk_info("TEST-CASE: LTP_TBIO_PUT:");
		err = test_bio_put(tbiop);
		break;
	case LTP_TBIO_SPLIT:
		prk_info("TEST-CASE: LTP_TBIO_SPLIT:");
		err = test_bio_split(tbio_dev.bdev,
			(struct tbio_interface *)arg);
	break;
	}

	prk_info("TEST-CASE DONE");
	blkdev_put(tbio_dev.bdev, FMODE_READ | FMODE_WRITE);
	return err;
}