1From 68faa63aaad81f4a289e4a03173ab4cf798deb53 Mon Sep 17 00:00:00 2001
2From: Azat Khuzhin <a3at.mail@gmail.com>
3Date: Sat, 1 Nov 2014 22:24:32 +0300
4Subject: [PATCH 3/3] Fix 3-d argument for BLKROSET it must be 'const int *'
5
6Most of *SET ioctls have int type for 3-d argument, except BLKROSET.
7So add bc_arg_type enum, build it into bool_comand and install arg_type
8to bc_arg_int_ptr for BLKROSET only.
9
10Debian-bug-id: 641164
11Link: https://bugs.debian.org/641164
12
13This patch is taken from
14ftp://ftp.debian.org/debian/pool/main/b/blktool/blktool_4-7.debian.tar.xz
15
16Upstream-Status: Inappropriate [upstream is dead]
17Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
18
19---
20 blktool.c | 11 +++++++++--
21 blktool.h |  7 +++++++
22 2 files changed, 16 insertions(+), 2 deletions(-)
23
24diff --git a/blktool.c b/blktool.c
25index fbefecd..221a195 100644
26--- a/blktool.c
27+++ b/blktool.c
28@@ -85,7 +85,7 @@ static struct bool_command bool_cmd_tbl[] = {
29 	{ { DEF_BOOL("pio-data"), dc_ata, DEF_HDIO(32BIT) },
30 	  "16-bit", "32-bit" },
31 	{ { DEF_BOOL("readonly"), dc_any, IOCNAME(BLKROGET), IOCNAME(BLKROSET) },
32-	  DEF_BOOLSTR },
33+	  DEF_BOOLSTR, bc_arg_int_ptr },
34 	{ { DEF_BOOL("unmask-irq"), dc_ata, DEF_HDIO(UNMASKINTR) },
35 	  DEF_BOOLSTR },
36 	{ { "wcache", ct_bool, handle_wcache, dc_any,
37@@ -171,7 +171,14 @@ static void handle_bool(int argc, char **argv, struct command *cmd)
38
39 	} else if ((argc == 4) && (cmd->write_ioctl_name != NULL)) {
40 		do_32 = parse_bool(argc, argv, bcm);
41-		if (ioctl(blkdev, cmd->write_ioctl, do_32))
42+
43+		int ret;
44+		if (bcm->arg_type == bc_arg_int_ptr) {
45+			ret = ioctl(blkdev, cmd->write_ioctl, &do_32);
46+		} else {
47+			ret = ioctl(blkdev, cmd->write_ioctl, do_32);
48+		}
49+		if (ret)
50 			pdie(cmd->write_ioctl_name, 1);
51 	}
52 	else {
53diff --git a/blktool.h b/blktool.h
54index fce4387..85add83 100644
55--- a/blktool.h
56+++ b/blktool.h
57@@ -85,11 +85,18 @@ struct command {
58 	const char		*write_ioctl_name;
59 };
60
61+enum bc_arg_type {
62+	bc_arg_int,
63+	bc_arg_int_ptr,
64+};
65+
66 struct bool_command {
67 	struct command		cmd;
68
69 	const char		*str_false;
70 	const char		*str_true;
71+
72+	enum bc_arg_type arg_type;
73 };
74
75 struct class_operations {
76--
772.1.4
78
79