[PATCH 21/21] dm: rewrite structure decoding

2016-10-09 Thread Eugene Syromyatnikov
Rewrite structure decoding in attempt to make it more in line with how structures and arrays are decoded in strace. * Replace single structure retrieval with on-demand retrieval. It allows limiting amount of memory being allocated (suppose ioctl with data_size = -1) * Check for abbrev in st

[PATCH 18/21] tests/ioctl_dm: Allow passing size and data_start to init_s

2016-10-09 Thread Eugene Syromyatnikov
--- tests/ioctl_dm.c | 34 -- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index 6967ca2..c120ed2 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -21,32 +21,30 @@ static struct s { } u; } s;

[PATCH 19/21] dm: Add check whether command uses parameters

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c | 25 ++--- tests/ioctl_dm.c |2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dm.c b/dm.c index caffc55..a48aa72 100644 --- a/dm.c +++ b/dm.c @@ -281,6 +281,23 @@ dm_decode_string(const struct dm_ioctl *ioc, const char *extra,

[PATCH 08/21] dm: Use static constants for offset sizes

2016-10-09 Thread Eugene Syromyatnikov
This may improve readability an leads to more compact code. --- dm.c | 58 +++--- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/dm.c b/dm.c index 66b615d..adfa97e 100644 --- a/dm.c +++ b/dm.c @@ -102,12 +102,14 @@ static void

[PATCH 20/21] dm: Fix printing of version field

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c |6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index a48aa72..ff9e8ad 100644 --- a/dm.c +++ b/dm.c @@ -342,7 +342,11 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) return 1; } - tprintf("%s{ve

[PATCH 17/21] dm: Add data_size and data_offset fields to output

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c |4 +++- tests/ioctl_dm.c | 41 - 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/dm.c b/dm.c index 5c908c9..caffc55 100644 --- a/dm.c +++ b/dm.c @@ -327,7 +327,6 @@ dm_known_ioctl(struct tcb *tcp, const unsigned i

[PATCH 14/21] dm: replace abbrev branching with goto

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c | 78 ++ 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/dm.c b/dm.c index 73a9b57..814d7d2 100644 --- a/dm.c +++ b/dm.c @@ -350,52 +350,54 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long a

[PATCH 16/21] dm: Add comment regarding intended fall-through in switch statement

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c |1 + 1 file changed, 1 insertion(+) diff --git a/dm.c b/dm.c index 289bc0d..5c908c9 100644 --- a/dm.c +++ b/dm.c @@ -60,6 +60,7 @@ dm_decode_values(struct tcb *tcp, const unsigned int code, case DM_DEV_SUSPEND: if (ioc->flags & DM_SUSPEND_FLAG

[PATCH 11/21] dm: Compare entering field values with exiting ones

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c | 74 -- tests/ioctl_dm.c | 26 +++ 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/dm.c b/dm.c index f23a65d..b6fb11d 100644 --- a/dm.c +++ b/dm.c @@ -282,28 +282,62 @@ dm_decode_string(c

[PATCH 12/21] dm: Add inttypes.h, include reorder

2016-10-09 Thread Eugene Syromyatnikov
Build failed otherwise on RHEL 5. --- dm.c |3 ++- tests/ioctl_dm.c |1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index b6fb11d..a11196f 100644 --- a/dm.c +++ b/dm.c @@ -2,8 +2,9 @@ #ifdef HAVE_LINUX_DM_IOCTL_H -# include +# include # i

[PATCH 10/21] dm: use => instead of , for splitting output structure from input

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c |4 ++-- tests/ioctl_dm.c | 12 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dm.c b/dm.c index 3ee74c3..f23a65d 100644 --- a/dm.c +++ b/dm.c @@ -288,8 +288,8 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) i

[PATCH 13/21] dm: Move printing of dm_ioctl fields before allocation of extra data

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dm.c b/dm.c index a11196f..73a9b57 100644 --- a/dm.c +++ b/dm.c @@ -335,6 +335,10 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) goto skip; } + dm_decode_d

[PATCH 15/21] dm: Additional data_size/data_start checks

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c |8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index 814d7d2..289bc0d 100644 --- a/dm.c +++ b/dm.c @@ -293,7 +293,8 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) if (!ioc) return 0; - if (u

[PATCH 09/21] dm: Remove char * cast

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm.c b/dm.c index adfa97e..3ee74c3 100644 --- a/dm.c +++ b/dm.c @@ -286,7 +286,7 @@ dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg) char *extra = NULL; uint32_t extra_size = 0; -

[PATCH 05/21] xlat: Add values for dm_flags

2016-10-09 Thread Eugene Syromyatnikov
Otherwise build fails on some old distros which lack DM_DATA_OUT_FLAG and other flags (excerpt from RHEL 5 build log): [ 66s] dm.c: In function 'dm_known_ioctl': [ 66s] dm.c:311: error: 'DM_DATA_OUT_FLAG' undeclared (first use in this function) [ 66s] dm.c:311: error: (Each undeclared ident

[PATCH 07/21] dm: Add definitions for ioctl commands not implemented initially

2016-10-09 Thread Eugene Syromyatnikov
dm.c [!DM_LIST_VERSIONS] (DM_LIST_VERSIONS): New definition. [!DM_TARGET_MSG] (DM_TARGET_MSG): Likewise. [!DM_DEV_SET_GEOMETRY] (DM_DEV_SET_GEOMETRY): Likewise. --- dm.c | 13 + 1 file changed, 13 insertions(+) diff --git a/dm.c b/dm.c index 79bb7c7..66b615d 100644 --- a/dm.c +++ b/

[PATCH 06/21] dm: Some future-proofing by means of compile-time DM_VERSION_MAJOR check

2016-10-09 Thread Eugene Syromyatnikov
* dm.c: Add check whether DM_VERSION_MAJOR equals to 4, provide empty dm_ioctl if check fails. --- dm.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dm.c b/dm.c index ebdfc44..79bb7c7 100644 --- a/dm.c +++ b/dm.c @@ -5,6 +5,8 @@ # include # include +# i

[PATCH 03/21] tests: Working around bounds check

2016-10-09 Thread Eugene Syromyatnikov
When building with -Wp,-D_FORTIFY_SOURCE=2, dompiler produces the following warning: In file included from /usr/include/string.h:638:0, from ioctl_dm.c:4: In function ‘strcpy’, inlined from ‘main’ at ioctl_dm.c:57:8: /usr/include/bits/string3.h:104:3: warning: call to __builti

[PATCH 04/21] dm: Minor output tweaks

2016-10-09 Thread Eugene Syromyatnikov
Trying to make it more C-like and in line with common practices regarding structure printing. --- dm.c | 21 + tests/ioctl_dm.c |2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dm.c b/dm.c index d81983d..ebdfc44 100644 --- a/dm.c +++ b/dm

[PATCH 02/21] dm: whitespace fixes

2016-10-09 Thread Eugene Syromyatnikov
--- dm.c | 87 +++--- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/dm.c b/dm.c index 33a3972..d81983d 100644 --- a/dm.c +++ b/dm.c @@ -2,8 +2,8 @@ #ifdef HAVE_LINUX_DM_IOCTL_H -#include -#include +# include +#

[PATCH 01/21] tests/ioctl_dm: Formatting

2016-10-09 Thread Eugene Syromyatnikov
--- tests/ioctl_dm.c | 42 +++--- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index f4c3c8b..a5945ae 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -40,38 +40,66 @@ main(void) s.ioc.data_s

[PATCH 00/21] Some possible additions to the DM ioctl patch for strace

2016-10-09 Thread Eugene Syromyatnikov
Hello. I've took the liberty to look at the patch and I'd like to propose some changes to it. Can you please review them from the DM side of things? I'm not quite sure I've understood all the specifics of the interface correctly, it's quite peculiar. I'm also preparing a patch for the DM ioctl de