2 * Copyright (c) 2009, 2010 Jeff Mahoney <jeffm@suse.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <linux/blkpg.h>
32 /* ioctls <= 114 are present in Linux 2.4. The following ones have been
33 * added since then and headers containing them may not be available on
36 #define BLKTRACE_BDEV_SIZE 32
37 struct blk_user_trace_setup {
38 char name[BLKTRACE_BDEV_SIZE]; /* output */
39 uint16_t act_mask; /* input */
40 uint32_t buf_size; /* input */
41 uint32_t buf_nr; /* input */
48 # define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
51 # define BLKTRACESTART _IO(0x12,116)
54 # define BLKTRACESTOP _IO(0x12,117)
56 #ifndef BLKTRACETEARDOWN
57 # define BLKTRACETEARDOWN _IO(0x12,118)
60 # define BLKDISCARD _IO(0x12,119)
63 # define BLKIOMIN _IO(0x12,120)
66 # define BLKIOOPT _IO(0x12,121)
69 # define BLKALIGNOFF _IO(0x12,122)
72 # define BLKPBSZGET _IO(0x12,123)
74 #ifndef BLKDISCARDZEROES
75 # define BLKDISCARDZEROES _IO(0x12,124)
78 # define BLKSECDISCARD _IO(0x12,125)
81 # define BLKROTATIONAL _IO(0x12,126)
84 # define BLKZEROOUT _IO(0x12,127)
87 # define BLKDAXGET _IO(0x12,129)
90 #include "xlat/blkpg_ops.h"
93 print_blkpg_req(struct tcb *tcp, const struct blkpg_ioctl_arg *blkpg)
95 struct blkpg_partition p;
98 printxval(blkpg_ops, blkpg->op, "BLKPG_???");
100 tprintf(", flags=%d, datalen=%d, data=",
101 blkpg->flags, blkpg->datalen);
103 if (!umove_or_printaddr(tcp, (long) blkpg->data, &p)) {
104 tprintf("{start=%lld, length=%lld, pno=%d, devname=",
105 p.start, p.length, p.pno);
106 print_quoted_string(p.devname, sizeof(p.devname),
108 tprints(", volname=");
109 print_quoted_string(p.volname, sizeof(p.volname),
117 block_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
120 /* take arg as a value, not as a pointer */
123 tprintf(", %lu", arg);
126 /* take a signed int */
130 printnum_int(tcp, arg, "%d");
133 /* return an unsigned short */
139 printnum_short(tcp, arg, "%hu");
142 /* return a signed int */
151 printnum_int(tcp, arg, "%d");
154 /* return an unsigned int */
158 case BLKDISCARDZEROES:
162 printnum_int(tcp, arg, "%u");
165 /* return a signed long */
171 printnum_slong(tcp, arg);
174 /* returns an unsigned long */
179 printnum_ulong(tcp, arg);
182 #ifdef HAVE_BLKGETSIZE64
183 /* returns an uint64_t */
188 printnum_int64(tcp, arg, "%" PRIu64);
192 /* takes a pair of uint64_t */
197 printpair_int64(tcp, arg, "%" PRIx64);
200 /* More complex types */
202 struct blkpg_ioctl_arg blkpg;
205 if (!umove_or_printaddr(tcp, arg, &blkpg))
206 print_blkpg_req(tcp, &blkpg);
212 struct blk_user_trace_setup buts;
215 if (umove_or_printaddr(tcp, arg, &buts))
217 tprintf("{act_mask=%u, buf_size=%u, "
218 "buf_nr=%u, start_lba=%" PRIu64 ", "
219 "end_lba=%" PRIu64 ", pid=%u",
220 (unsigned)buts.act_mask, buts.buf_size,
221 buts.buf_nr, buts.start_lba,
222 buts.end_lba, buts.pid);
225 struct blk_user_trace_setup buts;
227 if (!syserror(tcp) && !umove(tcp, arg, &buts)) {
229 print_quoted_string(buts.name, sizeof(buts.name),
241 case BLKTRACETEARDOWN:
247 return RVAL_DECODED | 1;