]> granicus.if.org Git - strace/commitdiff
loop: add fallback definitions for LOOP_* ioctl command constants
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 19 Dec 2016 00:11:18 +0000 (03:11 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 29 Dec 2016 00:36:05 +0000 (00:36 +0000)
Since these are architecture-independent and have been added over the
kernel's lifetime, it makes sense to have these definitions in strace
itself.

* xlat/loop_cmds.in: New file.
* loop.c: Include "xlat/loop_cmds.h".
(loop_ioctl): Eliminate conditional compilation based on availability
of LOOP_* constant definitions.

loop.c
xlat/loop_cmds.in [new file with mode: 0644]

diff --git a/loop.c b/loop.c
index ebb518bcabdd8e1a7a1bafc7e7ba3c05450e3b26..2ade8e7a3a01470e828c9bdf2987eb0648f0956f 100644 (file)
--- a/loop.c
+++ b/loop.c
@@ -35,6 +35,7 @@ typedef struct loop_info struct_loop_info;
 
 #include MPERS_DEFS
 
+#include "xlat/loop_cmds.h"
 #include "xlat/loop_flags_options.h"
 #include "xlat/loop_crypt_type_options.h"
 
@@ -173,13 +174,9 @@ MPERS_PRINTER_DECL(int, loop_ioctl,
                break;
 
        case LOOP_CLR_FD:
-#ifdef LOOP_SET_CAPACITY
        case LOOP_SET_CAPACITY:
-#endif
-#ifdef LOOP_CTL_GET_FREE
        /* newer loop-control stuff */
        case LOOP_CTL_GET_FREE:
-#endif
                /* Takes no arguments */
                break;
 
@@ -189,19 +186,15 @@ MPERS_PRINTER_DECL(int, loop_ioctl,
                printfd(tcp, arg);
                break;
 
-#ifdef LOOP_CTL_ADD
        /* newer loop-control stuff */
        case LOOP_CTL_ADD:
        case LOOP_CTL_REMOVE:
                tprintf(", %d", (int) arg);
                break;
-#endif
 
-#ifdef LOOP_SET_DIRECT_IO
        case LOOP_SET_DIRECT_IO:
                tprintf(", %" PRI_klu, arg);
                break;
-#endif
 
        default:
                return RVAL_DECODED;
diff --git a/xlat/loop_cmds.in b/xlat/loop_cmds.in
new file mode 100644 (file)
index 0000000..6faca51
--- /dev/null
@@ -0,0 +1,13 @@
+LOOP_SET_FD            0x4C00
+LOOP_CLR_FD            0x4C01
+LOOP_SET_STATUS                0x4C02
+LOOP_GET_STATUS                0x4C03
+LOOP_SET_STATUS64      0x4C04
+LOOP_GET_STATUS64      0x4C05
+LOOP_CHANGE_FD         0x4C06
+LOOP_SET_CAPACITY      0x4C07
+LOOP_SET_DIRECT_IO     0x4C08
+LOOP_CTL_ADD           0x4C80
+LOOP_CTL_REMOVE                0x4C81
+LOOP_CTL_GET_FREE      0x4C82
+#stop