Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 68faa63aaad81f4a289e4a03173ab4cf798deb53 Mon Sep 17 00:00:00 2001 |
| 2 | From: Azat Khuzhin <a3at.mail@gmail.com> |
| 3 | Date: Sat, 1 Nov 2014 22:24:32 +0300 |
| 4 | Subject: [PATCH 3/3] Fix 3-d argument for BLKROSET it must be 'const int *' |
| 5 | |
| 6 | Most of *SET ioctls have int type for 3-d argument, except BLKROSET. |
| 7 | So add bc_arg_type enum, build it into bool_comand and install arg_type |
| 8 | to bc_arg_int_ptr for BLKROSET only. |
| 9 | |
| 10 | Debian-bug-id: 641164 |
| 11 | Link: https://bugs.debian.org/641164 |
| 12 | |
| 13 | This patch is taken from |
| 14 | ftp://ftp.debian.org/debian/pool/main/b/blktool/blktool_4-7.debian.tar.xz |
| 15 | |
| 16 | Upstream-Status: Inappropriate [upstream is dead] |
| 17 | Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> |
| 18 | |
| 19 | --- |
| 20 | blktool.c | 11 +++++++++-- |
| 21 | blktool.h | 7 +++++++ |
| 22 | 2 files changed, 16 insertions(+), 2 deletions(-) |
| 23 | |
| 24 | diff --git a/blktool.c b/blktool.c |
| 25 | index 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 { |
| 53 | diff --git a/blktool.h b/blktool.h |
| 54 | index 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 | -- |
| 77 | 2.1.4 |
| 78 | |