|
30 | 30 |
|
31 | 31 | #include "defs.h"
|
32 | 32 | #include <fcntl.h>
|
33 |
| -#include <sys/stat.h> |
34 |
| -#include <sys/wait.h> |
35 |
| -#include <sys/resource.h> |
36 |
| -#include <sys/utsname.h> |
37 | 33 |
|
38 |
| -/* Bits of module.flags. */ |
39 |
| - |
40 |
| -#define MOD_UNINITIALIZED 0 |
41 |
| -#define MOD_RUNNING 1 |
42 |
| -#define MOD_DELETED 2 |
43 |
| -#define MOD_AUTOCLEAN 4 |
44 |
| -#define MOD_VISITED 8 |
45 |
| -#define MOD_USED_ONCE 16 |
46 |
| -#define MOD_JUST_FREED 32 |
47 |
| -#define MOD_INITIALIZING 64 |
48 |
| - |
49 |
| -/* Values for query_module's which. */ |
50 |
| - |
51 |
| -#define QM_MODULES 1 |
52 |
| -#define QM_DEPS 2 |
53 |
| -#define QM_REFS 3 |
54 |
| -#define QM_SYMBOLS 4 |
55 |
| -#define QM_INFO 5 |
56 |
| - |
57 |
| -struct module_symbol |
58 |
| -{ |
59 |
| - unsigned long value; |
60 |
| - const char *name; |
61 |
| -}; |
62 |
| - |
63 |
| -struct module_info |
64 |
| -{ |
65 |
| - unsigned long addr; |
66 |
| - unsigned long size; |
67 |
| - unsigned long flags; |
68 |
| - long usecount; |
69 |
| -}; |
70 |
| - |
71 |
| -#include "xlat/qm_which.h" |
72 |
| -#include "xlat/modflags.h" |
73 | 34 | #include "xlat/delete_module_flags.h"
|
74 | 35 |
|
75 |
| -SYS_FUNC(query_module) |
76 |
| -{ |
77 |
| - if (entering(tcp)) { |
78 |
| - printstr(tcp, tcp->u_arg[0], -1); |
79 |
| - tprints(", "); |
80 |
| - printxval(qm_which, tcp->u_arg[1], "QM_???"); |
81 |
| - tprints(", "); |
82 |
| - } else { |
83 |
| - size_t ret; |
84 |
| - |
85 |
| - if (!verbose(tcp) || syserror(tcp) || |
86 |
| - umove(tcp, tcp->u_arg[4], &ret) < 0) { |
87 |
| - tprintf("%#lx, %lu, %#lx", tcp->u_arg[2], |
88 |
| - tcp->u_arg[3], tcp->u_arg[4]); |
89 |
| - } else if (tcp->u_arg[1]==QM_INFO) { |
90 |
| - struct module_info mi; |
91 |
| - if (umove(tcp, tcp->u_arg[2], &mi) < 0) { |
92 |
| - tprintf("%#lx, ", tcp->u_arg[2]); |
93 |
| - } else { |
94 |
| - tprintf("{address=%#lx, size=%lu, flags=", |
95 |
| - mi.addr, mi.size); |
96 |
| - printflags(modflags, mi.flags, "MOD_???"); |
97 |
| - tprintf(", usecount=%lu}, ", mi.usecount); |
98 |
| - } |
99 |
| - tprintf("%lu", (unsigned long)ret); |
100 |
| - } else if ((tcp->u_arg[1]==QM_MODULES) || |
101 |
| - (tcp->u_arg[1]==QM_DEPS) || |
102 |
| - (tcp->u_arg[1]==QM_REFS)) { |
103 |
| - tprints("{"); |
104 |
| - if (!abbrev(tcp)) { |
105 |
| - char* data = malloc(tcp->u_arg[3]); |
106 |
| - char* mod = data; |
107 |
| - size_t idx; |
108 |
| - |
109 |
| - if (!data) { |
110 |
| - error_msg("Out of memory"); |
111 |
| - tprintf(" /* %lu entries */ ", (unsigned long)ret); |
112 |
| - } else { |
113 |
| - if (umoven(tcp, tcp->u_arg[2], |
114 |
| - tcp->u_arg[3], data) < 0) { |
115 |
| - tprintf(" /* %lu entries */ ", (unsigned long)ret); |
116 |
| - } else { |
117 |
| - for (idx = 0; idx < ret; idx++) { |
118 |
| - tprintf("%s%s", |
119 |
| - (idx ? ", " : ""), |
120 |
| - mod); |
121 |
| - mod += strlen(mod)+1; |
122 |
| - } |
123 |
| - } |
124 |
| - free(data); |
125 |
| - } |
126 |
| - } else |
127 |
| - tprintf(" /* %lu entries */ ", (unsigned long)ret); |
128 |
| - tprintf("}, %lu", (unsigned long)ret); |
129 |
| - } else if (tcp->u_arg[1]==QM_SYMBOLS) { |
130 |
| - tprints("{"); |
131 |
| - if (!abbrev(tcp)) { |
132 |
| - char* data = malloc(tcp->u_arg[3]); |
133 |
| - struct module_symbol* sym = (struct module_symbol*)data; |
134 |
| - size_t idx; |
135 |
| - |
136 |
| - if (!data) { |
137 |
| - error_msg("Out of memory"); |
138 |
| - tprintf(" /* %lu entries */ ", (unsigned long)ret); |
139 |
| - } else { |
140 |
| - if (umoven(tcp, tcp->u_arg[2], |
141 |
| - tcp->u_arg[3], data) < 0) { |
142 |
| - tprintf(" /* %lu entries */ ", (unsigned long)ret); |
143 |
| - } else { |
144 |
| - for (idx = 0; idx < ret; idx++) { |
145 |
| - tprintf("%s{name=%s, value=%lu}", |
146 |
| - (idx ? " " : ""), |
147 |
| - data+(long)sym->name, |
148 |
| - sym->value); |
149 |
| - sym++; |
150 |
| - } |
151 |
| - } |
152 |
| - free(data); |
153 |
| - } |
154 |
| - } else |
155 |
| - tprintf(" /* %lu entries */ ", (unsigned long)ret); |
156 |
| - tprintf("}, %ld", (unsigned long)ret); |
157 |
| - } else { |
158 |
| - printstr(tcp, tcp->u_arg[2], tcp->u_arg[3]); |
159 |
| - tprintf(", %#lx", tcp->u_arg[4]); |
160 |
| - } |
161 |
| - } |
162 |
| - return 0; |
163 |
| -} |
164 |
| - |
165 | 36 | SYS_FUNC(create_module)
|
166 | 37 | {
|
167 | 38 | printpath(tcp, tcp->u_arg[0]);
|
|
0 commit comments