2 * Copyright (c) 2012 The Chromium OS Authors.
3 * Written by Mike Frysinger <vapier@gentoo.org>.
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.
30 #include <sys/ioctl.h>
32 #include <linux/loop.h>
34 #include "xlat/loop_flags_options.h"
35 #include "xlat/loop_crypt_type_options.h"
38 loop_ioctl(struct tcb *tcp, const unsigned int code, long arg)
40 struct loop_info info;
41 struct loop_info64 info64;
50 if (!verbose(tcp) || umove(tcp, arg, &info) < 0)
53 tprintf(", {number=%d", info.lo_number);
56 tprintf(", device=%#lx, inode=%lu, rdevice=%#lx",
57 (unsigned long) info.lo_device,
59 (unsigned long) info.lo_rdevice);
62 tprintf(", offset=%#x", info.lo_offset);
64 if (!abbrev(tcp) || info.lo_encrypt_type != LO_CRYPT_NONE) {
65 tprints(", encrypt_type=");
66 printxval(loop_crypt_type_options, info.lo_encrypt_type,
68 tprintf(", encrypt_key_size=%d", info.lo_encrypt_key_size);
72 printflags(loop_flags_options, info.lo_flags, "LO_FLAGS_???");
75 print_quoted_string(info.lo_name, LO_NAME_SIZE,
78 if (!abbrev(tcp) || info.lo_encrypt_type != LO_CRYPT_NONE) {
79 tprints(", encrypt_key=");
80 print_quoted_string((void *) info.lo_encrypt_key,
85 tprintf(", init={%#lx, %#lx}"
86 ", reserved={%#x, %#x, %#x, %#x}}",
87 info.lo_init[0], info.lo_init[1],
88 info.reserved[0], info.reserved[1],
89 info.reserved[2], info.reserved[3]);
95 case LOOP_SET_STATUS64:
96 case LOOP_GET_STATUS64:
97 if (!verbose(tcp) || umove(tcp, arg, &info64) < 0)
103 tprintf("device=%" PRIu64 ", inode=%" PRIu64 ", "
104 "rdevice=%" PRIu64 ", offset=%#" PRIx64 ", "
105 "sizelimit=%" PRIu64 ", number=%" PRIu32,
106 (uint64_t) info64.lo_device,
107 (uint64_t) info64.lo_inode,
108 (uint64_t) info64.lo_rdevice,
109 (uint64_t) info64.lo_offset,
110 (uint64_t) info64.lo_sizelimit,
111 (uint32_t) info64.lo_number);
113 tprintf("offset=%#" PRIx64 ", number=%" PRIu32,
114 (uint64_t) info64.lo_offset,
115 (uint32_t) info64.lo_number);
118 if (!abbrev(tcp) || info64.lo_encrypt_type != LO_CRYPT_NONE) {
119 tprints(", encrypt_type=");
120 printxval(loop_crypt_type_options, info64.lo_encrypt_type,
122 tprintf(", encrypt_key_size=%" PRIu32,
123 info64.lo_encrypt_key_size);
127 printflags(loop_flags_options, info64.lo_flags, "LO_FLAGS_???");
129 tprints(", file_name=");
130 print_quoted_string((void *) info64.lo_file_name,
131 LO_NAME_SIZE, QUOTE_0_TERMINATED);
133 if (!abbrev(tcp) || info64.lo_encrypt_type != LO_CRYPT_NONE) {
134 tprints(", crypt_name=");
135 print_quoted_string((void *) info64.lo_crypt_name,
136 LO_NAME_SIZE, QUOTE_0_TERMINATED);
137 tprints(", encrypt_key=");
138 print_quoted_string((void *) info64.lo_encrypt_key,
143 tprintf(", init={%#" PRIx64 ", %#" PRIx64 "}}",
144 (uint64_t) info64.lo_init[0],
145 (uint64_t) info64.lo_init[1]);
152 #ifdef LOOP_SET_CAPACITY
153 case LOOP_SET_CAPACITY:
155 #ifdef LOOP_CTL_GET_FREE
156 /* newer loop-control stuff */
157 case LOOP_CTL_GET_FREE:
159 /* Takes no arguments */
165 /* newer loop-control stuff */
167 case LOOP_CTL_REMOVE:
169 /* These take simple args, so let default printer handle it */