trace(1): resolve all level-5 LLVM warnings
[minix3.git] / minix / usr.bin / trace / service / rs.c
blobc1bc3ad4d8e800bac4ecac8847eca838ca4f7385
2 #include "inc.h"
4 #include <minix/rs.h>
6 static const struct flags rss_flags[] = {
7 FLAG(RSS_COPY),
8 FLAG(RSS_REUSE),
9 FLAG(RSS_NOBLOCK),
10 FLAG(RSS_REPLICA),
11 FLAG(RSS_SELF_LU),
12 FLAG(RSS_SYS_BASIC_CALLS),
13 FLAG(RSS_VM_BASIC_CALLS),
14 FLAG(RSS_NO_BIN_EXP),
17 static void
18 put_struct_rs_start(struct trace_proc * proc, const char * name,
19 vir_bytes addr)
21 struct rs_start buf;
23 if (!put_open_struct(proc, name, 0, addr, &buf, sizeof(buf)))
24 return;
26 if (verbose > 0)
27 put_flags(proc, "rss_flags", rss_flags, COUNT(rss_flags),
28 "0x%x", buf.rss_flags);
29 put_buf(proc, "rss_cmd", 0, (vir_bytes)buf.rss_cmd, buf.rss_cmdlen);
30 put_buf(proc, "rss_progname", 0, (vir_bytes)buf.rss_progname,
31 buf.rss_prognamelen);
32 put_buf(proc, "rss_label", 0, (vir_bytes)buf.rss_label.l_addr,
33 buf.rss_label.l_len);
34 if (verbose > 0 || buf.rss_major != 0)
35 put_value(proc, "rss_major", "%d", buf.rss_major);
36 if (verbose > 0 || buf.devman_id != 0)
37 put_value(proc, "devman_id", "%d", buf.devman_id);
38 put_value(proc, "rss_uid", "%u", buf.rss_uid);
39 if (verbose > 0) {
40 put_endpoint(proc, "rss_sigmgr", buf.rss_sigmgr);
41 put_endpoint(proc, "rss_scheduler", buf.rss_sigmgr);
43 if (verbose > 1) {
44 put_value(proc, "rss_priority", "%d", buf.rss_priority);
45 put_value(proc, "rss_quantum", "%d", buf.rss_quantum);
47 if (verbose > 0) {
48 put_value(proc, "rss_period", "%ld", buf.rss_period);
49 put_buf(proc, "rss_script", 0, (vir_bytes)buf.rss_script,
50 buf.rss_scriptlen);
53 put_close_struct(proc, FALSE /*all*/); /* TODO: the remaining fields */
56 /* This function is shared between rs_up and rs_edit. */
57 static int
58 rs_up_out(struct trace_proc * proc, const message * m_out)
61 put_struct_rs_start(proc, "addr", (vir_bytes)m_out->m_rs_req.addr);
63 return CT_DONE;
67 * This function is shared between rs_down, rs_refresh, rs_restart, and
68 * rs_clone.
70 static int
71 rs_label_out(struct trace_proc * proc, const message * m_out)
75 * We are not using PF_STRING here, because unlike in most places
76 * (including rs_lookup), the string length does not include the
77 * terminating NULL character.
79 put_buf(proc, "label", 0, (vir_bytes)m_out->m_rs_req.addr,
80 m_out->m_rs_req.len);
82 return CT_DONE;
85 static int
86 rs_update_out(struct trace_proc * proc, const message * m_out)
90 * FIXME: this is a value from the wrong message union, and that is
91 * actually a minix bug.
93 put_struct_rs_start(proc, "addr", (vir_bytes)m_out->m_rs_req.addr);
95 /* TODO: interpret these fields */
96 put_value(proc, "state", "%d", m_out->m_rs_update.state);
97 put_value(proc, "maxtime", "%d", m_out->m_rs_update.prepare_maxtime);
99 return CT_DONE;
102 static int
103 rs_lookup_out(struct trace_proc * proc, const message * m_out)
106 put_buf(proc, "label", PF_STRING, (vir_bytes)m_out->m_rs_req.name,
107 m_out->m_rs_req.name_len);
109 return CT_DONE;
112 static void
113 rs_lookup_in(struct trace_proc * proc, const message * __unused m_out,
114 const message * m_in, int failed)
117 if (!failed)
118 put_endpoint(proc, NULL, m_in->m_rs_req.endpoint);
119 else
120 put_result(proc);
123 #define RS_CALL(c) [((RS_ ## c) - RS_RQ_BASE)]
125 static const struct call_handler rs_map[] = {
126 RS_CALL(UP) = HANDLER("rs_up", rs_up_out, default_in),
127 RS_CALL(DOWN) = HANDLER("rs_down", rs_label_out, default_in),
128 RS_CALL(REFRESH) = HANDLER("rs_refresh", rs_label_out, default_in),
129 RS_CALL(RESTART) = HANDLER("rs_restart", rs_label_out, default_in),
130 RS_CALL(SHUTDOWN) = HANDLER("rs_shutdown", default_out, default_in),
131 RS_CALL(CLONE) = HANDLER("rs_clone", rs_label_out, default_in),
132 RS_CALL(UPDATE) = HANDLER("rs_update", rs_update_out, default_in),
133 RS_CALL(EDIT) = HANDLER("rs_edit", rs_up_out, default_in),
134 RS_CALL(LOOKUP) = HANDLER("rs_lookup", rs_lookup_out, rs_lookup_in),
137 const struct calls rs_calls = {
138 .endpt = RS_PROC_NR,
139 .base = RS_RQ_BASE,
140 .map = rs_map,
141 .count = COUNT(rs_map)