aio_write_f(int argc, char **argv)

{

	char *p;

	int count = 0;

	int nr_iov, i, c;

	int pattern = 0xcd;

	struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));

	BlockDriverAIOCB *acb;



	while ((c = getopt(argc, argv, "CqP:")) != EOF) {

		switch (c) {

		case 'C':

			ctx->Cflag = 1;

			break;

		case 'q':

			ctx->qflag = 1;

			break;

		case 'P':

			pattern = atoi(optarg);

			break;

		default:

			return command_usage(&aio_write_cmd);

		}

	}



	if (optind > argc - 2)

		return command_usage(&aio_write_cmd);



	ctx->offset = cvtnum(argv[optind]);

	if (ctx->offset < 0) {

		printf("non-numeric length argument -- %s\n", argv[optind]);

		return 0;

	}

	optind++;



	if (ctx->offset & 0x1ff) {

		printf("offset %lld is not sector aligned\n",

			(long long)ctx->offset);

		return 0;

	}



	if (count & 0x1ff) {

		printf("count %d is not sector aligned\n",

			count);

		return 0;

	}



	for (i = optind; i < argc; i++) {

	        size_t len;



		len = cvtnum(argv[optind]);

		if (len < 0) {

			printf("non-numeric length argument -- %s\n", argv[i]);

			return 0;

		}

		count += len;

	}



	nr_iov = argc - optind;

	qemu_iovec_init(&ctx->qiov, nr_iov);

	ctx->buf = p = qemu_io_alloc(count, pattern);

	for (i = 0; i < nr_iov; i++) {

	        size_t len;



		len = cvtnum(argv[optind]);

		if (len < 0) {

			printf("non-numeric length argument -- %s\n",

				argv[optind]);

			return 0;

		}



		qemu_iovec_add(&ctx->qiov, p, len);

		p += len;

		optind++;

	}



	gettimeofday(&ctx->t1, NULL);

	acb = bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov,

			      ctx->qiov.size >> 9, aio_write_done, ctx);

	if (!acb)

		return -EIO;



	return 0;

}

aio_write_f(int argc, char **argv)

{

	char *p;

	int count = 0;

	int nr_iov, i, c;

	int pattern = 0xcd;

	struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));

	BlockDriverAIOCB *acb;



	while ((c = getopt(argc, argv, "CqP:")) != EOF) {

		switch (c) {

		case 'C':

			ctx->Cflag = 1;

			break;

		case 'q':

			ctx->qflag = 1;

			break;

		case 'P':

			pattern = atoi(optarg);

			break;

		default:

			return command_usage(&aio_write_cmd);

		}

	}



	if (optind > argc - 2)

		return command_usage(&aio_write_cmd);



	ctx->offset = cvtnum(argv[optind]);

	if (ctx->offset < 0) {

		printf("non-numeric length argument -- %s\n", argv[optind]);

		return 0;

	}

	optind++;



	if (ctx->offset & 0x1ff) {

		printf("offset %lld is not sector aligned\n",

			(long long)ctx->offset);

		return 0;

	}



	if (count & 0x1ff) {

		printf("count %d is not sector aligned\n",

			count);

		return 0;

	}



	for (i = optind; i < argc; i++) {

	        size_t len;



		len = cvtnum(argv[optind]);

		if (len < 0) {

			printf("non-numeric length argument -- %s\n", argv[i]);

			return 0;

		}

		count += len;

	}



	nr_iov = argc - optind;

	qemu_iovec_init(&ctx->qiov, nr_iov);

	ctx->buf = p = qemu_io_alloc(count, pattern);

	for (i = 0; i < nr_iov; i++) {

	        size_t len;



		len = cvtnum(argv[optind]);

		if (len < 0) {

			printf("non-numeric length argument -- %s\n",

				argv[optind]);

			return 0;

		}



		qemu_iovec_add(&ctx->qiov, p, len);

		p += len;

		optind++;

	}



	gettimeofday(&ctx->t1, NULL);

	acb = bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov,

			      ctx->qiov.size >> 9, aio_write_done, ctx);

	if (!acb)

		return -EIO;



	return 0;

}

FUNC_0(int VAR_0, char **VAR_1)

{

	char *VAR_2;

	int VAR_3 = 0;

	int VAR_4, VAR_5, VAR_6;

	int VAR_7 = 0xcd;

	struct aio_ctx *VAR_8 = calloc(1, sizeof(struct aio_ctx));

	BlockDriverAIOCB *acb;



	while ((VAR_6 = getopt(VAR_0, VAR_1, "CqP:")) != EOF) {

		switch (VAR_6) {

		case 'C':

			VAR_8->Cflag = 1;

			break;

		case 'q':

			VAR_8->qflag = 1;

			break;

		case 'P':

			VAR_7 = atoi(optarg);

			break;

		default:

			return command_usage(&aio_write_cmd);

		}

	}



	if (optind > VAR_0 - 2)

		return command_usage(&aio_write_cmd);



	VAR_8->offset = cvtnum(VAR_1[optind]);

	if (VAR_8->offset < 0) {

		printf("non-numeric length argument -- %s\n", VAR_1[optind]);

		return 0;

	}

	optind++;



	if (VAR_8->offset & 0x1ff) {

		printf("offset %lld is not sector aligned\n",

			(long long)VAR_8->offset);

		return 0;

	}



	if (VAR_3 & 0x1ff) {

		printf("VAR_3 %d is not sector aligned\n",

			VAR_3);

		return 0;

	}



	for (VAR_5 = optind; VAR_5 < VAR_0; VAR_5++) {

	        size_t len;



		len = cvtnum(VAR_1[optind]);

		if (len < 0) {

			printf("non-numeric length argument -- %s\n", VAR_1[VAR_5]);

			return 0;

		}

		VAR_3 += len;

	}



	VAR_4 = VAR_0 - optind;

	qemu_iovec_init(&VAR_8->qiov, VAR_4);

	VAR_8->buf = VAR_2 = qemu_io_alloc(VAR_3, VAR_7);

	for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {

	        size_t len;



		len = cvtnum(VAR_1[optind]);

		if (len < 0) {

			printf("non-numeric length argument -- %s\n",

				VAR_1[optind]);

			return 0;

		}



		qemu_iovec_add(&VAR_8->qiov, VAR_2, len);

		VAR_2 += len;

		optind++;

	}



	gettimeofday(&VAR_8->t1, NULL);

	acb = bdrv_aio_writev(bs, VAR_8->offset >> 9, &VAR_8->qiov,

			      VAR_8->qiov.size >> 9, aio_write_done, VAR_8);

	if (!acb)

		return -EIO;



	return 0;

}

FUNC_0(int VAR_0, char **VAR_1)
{ char *VAR_2; int VAR_3 = 0; int VAR_4, VAR_5, VAR_6; int VAR_7 = 0xcd; struct aio_ctx *VAR_8 = calloc(1, sizeof(struct aio_ctx)); BlockDriverAIOCB *acb; while ((VAR_6 = getopt(VAR_0, VAR_1, "CqP:")) != EOF) { switch (VAR_6) { case 'C':
VAR_8->Cflag = 1; break; case 'q':
VAR_8->qflag = 1; break; case 'P':
VAR_7 = atoi(optarg); break; default:
return command_usage(&aio_write_cmd); } } if (optind > VAR_0 - 2)
return command_usage(&aio_write_cmd); VAR_8->offset = cvtnum(VAR_1[optind]); if (VAR_8->offset < 0) { printf("non-numeric length argument -- %s\n", VAR_1[optind]); return 0; } optind++; if (VAR_8->offset & 0x1ff) { printf("offset %lld is not sector aligned\n",
(long long)VAR_8->offset); return 0; } if (VAR_3 & 0x1ff) { printf("VAR_3 %d is not sector aligned\n",
VAR_3); return 0; } for (VAR_5 = optind; VAR_5 < VAR_0; VAR_5++) { size_t len; len = cvtnum(VAR_1[optind]); if (len < 0) { printf("non-numeric length argument -- %s\n", VAR_1[VAR_5]); return 0; } VAR_3 += len; } VAR_4 = VAR_0 - optind; qemu_iovec_init(&VAR_8->qiov, VAR_4); VAR_8->buf = VAR_2 = qemu_io_alloc(VAR_3, VAR_7); for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) { size_t len; len = cvtnum(VAR_1[optind]); if (len < 0) { printf("non-numeric length argument -- %s\n",
VAR_1[optind]); return 0; } qemu_iovec_add(&VAR_8->qiov, VAR_2, len); VAR_2 += len; optind++; } gettimeofday(&VAR_8->t1, NULL); acb = bdrv_aio_writev(bs, VAR_8->offset >> 9, &VAR_8->qiov,
VAR_8->qiov.size >> 9, aio_write_done, VAR_8); if (!acb)
return -EIO; return 0; }