return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0;
}
-const struct_ioctlent *
+static const struct_ioctlent *
ioctl_lookup(const unsigned int code)
{
struct_ioctlent *iop;
return iop;
}
-const struct_ioctlent *
+static const struct_ioctlent *
ioctl_next_match(const struct_ioctlent *iop)
{
const unsigned int code = iop->code;
return NULL;
}
-void
+static void
ioctl_print_code(const unsigned int code)
{
tprints("_IOC(");
return 0;
}
-int
+static int
ioctl_decode_command_number(unsigned int arg)
{
switch (_IOC_TYPE(arg)) {
}
}
-int
+static int
ioctl_decode(struct tcb *tcp, unsigned int code, long arg)
{
switch (_IOC_TYPE(code)) {
}
return 0;
}
+
+SYS_FUNC(ioctl)
+{
+ const struct_ioctlent *iop;
+
+ if (entering(tcp)) {
+ printfd(tcp, tcp->u_arg[0]);
+ tprints(", ");
+ if (!ioctl_decode_command_number(tcp->u_arg[1])) {
+ iop = ioctl_lookup(tcp->u_arg[1]);
+ if (iop) {
+ tprints(iop->symbol);
+ while ((iop = ioctl_next_match(iop)))
+ tprintf(" or %s", iop->symbol);
+ } else {
+ ioctl_print_code(tcp->u_arg[1]);
+ }
+ }
+ ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
+ }
+ else {
+ int ret = ioctl_decode(tcp, tcp->u_arg[1], tcp->u_arg[2]);
+ if (!ret)
+ tprintf(", %#lx", tcp->u_arg[2]);
+ else
+ return ret - 1;
+ }
+ return 0;
+}