loop: mpersify struct loop_info and loop_ioctl function

struct loop_info contains fields of type long, so it definitely should
have been mpersified.

* defs.h (loop_ioctl): Remove prototype.
* loop.c (struct_loop_info): New typedef.
Include DEF_MPERS_TYPE(struct_loop_info) and MPERS_DEFS.
(decode_loop_info): Replace struct loop_info with struct_loop_info.
Cast lo_inode, lo_init[0], and lo_init[1] to kernel_ulong_t and print
them using appropriate format specifiers.
(loop_ioctl): Wrap into MPERS_PRINTER_DECL.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
Eugene Syromyatnikov 2016-12-19 03:15:27 +03:00 committed by Dmitry V. Levin
parent 52e3c75a1c
commit f0026a3818
2 changed files with 14 additions and 8 deletions

1
defs.h
View File

@ -670,7 +670,6 @@ name ## _ioctl(struct tcb *, unsigned int request, kernel_ulong_t arg)
DECL_IOCTL(dm);
DECL_IOCTL(file);
DECL_IOCTL(fs_x);
DECL_IOCTL(loop);
DECL_IOCTL(ptp);
DECL_IOCTL(scsi);
DECL_IOCTL(sock);

21
loop.c
View File

@ -29,13 +29,19 @@
#include <linux/ioctl.h>
#include <linux/loop.h>
typedef struct loop_info struct_loop_info;
#include DEF_MPERS_TYPE(struct_loop_info)
#include MPERS_DEFS
#include "xlat/loop_flags_options.h"
#include "xlat/loop_crypt_type_options.h"
static void
decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
{
struct loop_info info;
struct_loop_info info;
tprints(", ");
if (umove_or_printaddr(tcp, addr, &info))
@ -46,7 +52,7 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
if (!abbrev(tcp)) {
tprints(", lo_device=");
print_dev_t(info.lo_device);
tprintf(", lo_inode=%lu", info.lo_inode);
tprintf(", lo_inode=%" PRI_klu, (kernel_ulong_t) info.lo_inode);
tprints(", lo_rdevice=");
print_dev_t(info.lo_rdevice);
}
@ -74,9 +80,10 @@ decode_loop_info(struct tcb *const tcp, const kernel_ulong_t addr)
}
if (!abbrev(tcp))
tprintf(", lo_init=[%#lx, %#lx]"
tprintf(", lo_init=[%#" PRI_klx ", %#" PRI_klx "]"
", reserved=[%#x, %#x, %#x, %#x]}",
info.lo_init[0], info.lo_init[1],
(kernel_ulong_t) info.lo_init[0],
(kernel_ulong_t) info.lo_init[1],
info.reserved[0], info.reserved[1],
info.reserved[2], info.reserved[3]);
else
@ -141,9 +148,9 @@ decode_loop_info64(struct tcb *const tcp, const kernel_ulong_t addr)
tprints(", ...}");
}
int
loop_ioctl(struct tcb *const tcp, const unsigned int code,
const kernel_ulong_t arg)
MPERS_PRINTER_DECL(int, loop_ioctl,
struct tcb *tcp, const unsigned int code,
const kernel_ulong_t arg)
{
if (!verbose(tcp))
return RVAL_DECODED;