}
}
+/**
+ * Decode arg parameter of the ioctl call.
+ *
+ * @return There are two flags of the return value important for the purposes of
+ * processing by SYS_FUNC(ioctl):
+ * - RVAL_IOCTL_DECODED: indicates that ioctl decoder code
+ * has printed arg parameter;
+ * - RVAL_DECODED: indicates that decoding is done.
+ * As a result, the following behaviour is expected:
+ * - on entering:
+ * - 0: decoding should be continued on exiting;
+ * - RVAL_IOCTL_DECODED: decoding on exiting is not needed
+ * and decoder has printed arg value;
+ * - RVAL_DECODED: decoding on exiting is not needed
+ * and generic handler should print arg value.
+ * - on exiting:
+ * - 0: generic handler should print arg value;
+ * - RVAL_IOCTL_DECODED: decoder has printed arg value.
+ *
+ * Note that it makes no sense to return just RVAL_DECODED on exiting,
+ * but, of course, it is not prohibited (for example, it may be useful
+ * in cases where the return path is common on entering and on exiting
+ * the syscall).
+ *
+ * SYS_FUNC(ioctl) converts RVAL_IOCTL_DECODED flag to RVAL_DECODED,
+ * and passes all other bits of ioctl_decode return value unchanged.
+ */
static int
ioctl_decode(struct tcb *tcp)
{
ret = ioctl_decode(tcp) | RVAL_DECODED;
}
- if (ret & RVAL_DECODED) {
- ret &= ~RVAL_DECODED;
- if (ret)
- --ret;
- else
- tprintf(", %#" PRI_klx, tcp->u_arg[2]);
+ if (ret & RVAL_IOCTL_DECODED) {
+ ret &= ~RVAL_IOCTL_DECODED;
ret |= RVAL_DECODED;
- } else {
- if (ret)
- --ret;
+ } else if (ret & RVAL_DECODED) {
+ tprintf(", %#" PRI_klx, tcp->u_arg[2]);
}
return ret;