2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <sys/resource.h>
36 #include <sys/utsname.h>
39 /* Bits of module.flags. */
41 #define MOD_UNINITIALIZED 0
44 #define MOD_AUTOCLEAN 4
46 #define MOD_USED_ONCE 16
47 #define MOD_JUST_FREED 32
48 #define MOD_INITIALIZING 64
50 /* Values for query_module's which. */
72 static const struct xlat which[] = {
74 { QM_MODULES, "QM_MODULES" },
75 { QM_DEPS, "QM_DEPS" },
76 { QM_REFS, "QM_REFS" },
77 { QM_SYMBOLS, "QM_SYMBOLS" },
78 { QM_INFO, "QM_INFO" },
82 static const struct xlat modflags[] = {
83 { MOD_UNINITIALIZED, "MOD_UNINITIALIZED" },
84 { MOD_RUNNING, "MOD_RUNNING" },
85 { MOD_DELETED, "MOD_DELETED" },
86 { MOD_AUTOCLEAN, "MOD_AUTOCLEAN" },
87 { MOD_VISITED, "MOD_VISITED" },
88 { MOD_USED_ONCE, "MOD_USED_ONCE" },
89 { MOD_JUST_FREED, "MOD_JUST_FREED" },
94 sys_query_module(struct tcb *tcp)
97 printstr(tcp, tcp->u_arg[0], -1);
99 printxval(which, tcp->u_arg[1], "QM_???");
104 if (!verbose(tcp) || syserror(tcp) ||
105 umove(tcp, tcp->u_arg[4], &ret) < 0) {
106 tprintf("%#lx, %lu, %#lx", tcp->u_arg[2],
107 tcp->u_arg[3], tcp->u_arg[4]);
108 } else if (tcp->u_arg[1]==QM_INFO) {
109 struct module_info mi;
110 if (umove(tcp, tcp->u_arg[2], &mi) < 0) {
111 tprintf("%#lx, ", tcp->u_arg[2]);
113 tprintf("{address=%#lx, size=%lu, flags=",
115 printflags(modflags, mi.flags, "MOD_???");
116 tprintf(", usecount=%lu}, ", mi.usecount);
118 tprintf("%lu", (unsigned long)ret);
119 } else if ((tcp->u_arg[1]==QM_MODULES) ||
120 (tcp->u_arg[1]==QM_DEPS) ||
121 (tcp->u_arg[1]==QM_REFS)) {
124 char* data = malloc(tcp->u_arg[3]);
129 fprintf(stderr, "out of memory\n");
130 tprintf(" /* %lu entries */ ", (unsigned long)ret);
132 if (umoven(tcp, tcp->u_arg[2],
133 tcp->u_arg[3], data) < 0) {
134 tprintf(" /* %lu entries */ ", (unsigned long)ret);
136 for (idx = 0; idx < ret; idx++) {
140 mod += strlen(mod)+1;
146 tprintf(" /* %lu entries */ ", (unsigned long)ret);
147 tprintf("}, %lu", (unsigned long)ret);
148 } else if (tcp->u_arg[1]==QM_SYMBOLS) {
151 char* data = malloc(tcp->u_arg[3]);
152 struct module_symbol* sym = (struct module_symbol*)data;
156 fprintf(stderr, "out of memory\n");
157 tprintf(" /* %lu entries */ ", (unsigned long)ret);
159 if (umoven(tcp, tcp->u_arg[2],
160 tcp->u_arg[3], data) < 0) {
161 tprintf(" /* %lu entries */ ", (unsigned long)ret);
163 for (idx = 0; idx < ret; idx++) {
164 tprintf("%s{name=%s, value=%lu}",
166 data+(long)sym->name,
174 tprintf(" /* %lu entries */ ", (unsigned long)ret);
175 tprintf("}, %ld", (unsigned long)ret);
177 printstr(tcp, tcp->u_arg[2], tcp->u_arg[3]);
178 tprintf(", %#lx", tcp->u_arg[4]);
185 sys_create_module(struct tcb *tcp)
188 printpath(tcp, tcp->u_arg[0]);
189 tprintf(", %lu", tcp->u_arg[1]);
195 sys_init_module(struct tcb *tcp)
198 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
199 printstr(tcp, tcp->u_arg[2], -1);