2 * Copyright (c) 2007 Vladimir Nadvornik <nadvornik@suse.cz>
3 * Copyright (c) 2007-2018 Dmitry V. Levin <ldv@altlinux.org>
6 * SPDX-License-Identifier: LGPL-2.1-or-later
15 #define XLAT_MACROS_ONLY
16 # include "xlat/scsi_sg_commands.h"
17 #undef XLAT_MACROS_ONLY
18 #include "xlat/sg_scsi_reset.h"
21 decode_sg_io(struct tcb *const tcp, const uint32_t iid,
22 const kernel_ulong_t arg)
26 return decode_sg_io_v3(tcp, arg);
28 return decode_sg_io_v4(tcp, arg);
31 return RVAL_IOCTL_DECODED;
39 decode_sg_scsi_id(struct tcb *const tcp, const kernel_ulong_t arg)
47 if (!umove_or_printaddr(tcp, arg, &id)) {
54 ", d_queue_depth=%hd}",
63 return RVAL_IOCTL_DECODED;
66 #endif /* HAVE_SCSI_SG_H */
69 scsi_ioctl(struct tcb *const tcp, const unsigned int code,
70 const kernel_ulong_t arg)
78 if (umove_or_printaddr(tcp, arg, &iid)) {
81 return decode_sg_io(tcp, iid, arg);
84 uint32_t *piid = get_tcb_priv_data(tcp);
86 decode_sg_io(tcp, *piid, arg);
92 /* returns struct sg_scsi_id */
94 return decode_sg_scsi_id(tcp, arg);
95 /* returns struct sg_req_info */
96 case SG_GET_REQUEST_TABLE:
97 return decode_sg_req_info(tcp, arg);
98 #endif /* HAVE_SCSI_SG_H */
100 /* takes a value by pointer */
101 case SG_SCSI_RESET: {
104 if (!umove_or_printaddr(tcp, arg, &val)) {
106 if (val & SG_SCSI_RESET_NO_ESCALATE) {
107 printxval(sg_scsi_reset,
108 SG_SCSI_RESET_NO_ESCALATE, 0);
111 printxval(sg_scsi_reset,
112 val & ~SG_SCSI_RESET_NO_ESCALATE,
113 "SG_SCSI_RESET_???");
120 /* takes a signed int by pointer */
121 case SG_NEXT_CMD_LEN:
122 case SG_SET_COMMAND_Q:
124 case SG_SET_FORCE_LOW_DMA:
125 case SG_SET_FORCE_PACK_ID:
126 case SG_SET_KEEP_ORPHAN:
127 case SG_SET_RESERVED_SIZE:
130 printnum_int(tcp, arg, "%d");
133 /* returns a signed int by pointer */
134 case SG_EMULATED_HOST:
135 case SG_GET_ACCESS_COUNT:
136 case SG_GET_COMMAND_Q:
137 case SG_GET_KEEP_ORPHAN:
139 case SG_GET_NUM_WAITING:
141 case SG_GET_RESERVED_SIZE:
142 case SG_GET_SG_TABLESIZE:
143 case SG_GET_TRANSFORM:
144 case SG_GET_VERSION_NUM:
148 printnum_int(tcp, arg, "%d");
151 /* takes an integer by value */
152 case SG_SET_TRANSFORM:
153 tprintf(", %#x", (unsigned int) arg);
164 return RVAL_IOCTL_DECODED;