2 * Copyright (c)2004 The DragonFly Project. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * Neither the name of the DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
36 * Diagnostic functions for installer.
37 * $Id: fn_diagnostic.c,v 1.21 2005/03/13 01:53:58 cpressey Exp $
40 #include <sys/types.h>
50 #define _(String) gettext (String)
52 #define _(String) (String)
55 #include "libaura/mem.h"
56 #include "libaura/buffer.h"
58 #include "libdfui/dfui.h"
60 #include "libinstaller/commands.h"
61 #include "libinstaller/confed.h"
62 #include "libinstaller/diskutil.h"
63 #include "libinstaller/functions.h"
64 #include "libinstaller/package.h"
65 #include "libinstaller/uiutil.h"
68 #include "pathnames.h"
70 /*** DIAGNOSTIC FUNCTIONS ***/
73 fn_memtest(struct i_fn_args *a)
76 struct dfui_response *r;
77 struct dfui_dataset *ds, *new_ds;
78 struct commands *cmds;
80 const char *memtestsize;
85 _("Memory test - Enter the size in values such as 400M, 1G."),
88 "f", "memtestsize", _("Memory test size"),
89 _("Enter the amount of memory you would like to check:"), "",
91 "a", "ok", _("OK"), "", "",
92 "a", "cancel", _("Cancel Memory Test"), "", "",
93 "p", "accelerator", "ESC",
98 ds = dfui_dataset_new();
99 dfui_dataset_celldata_add(ds, "memtestsize", "");
100 dfui_form_dataset_add(f, ds);
102 if (!dfui_be_present(a->c, f, &r))
105 if (strcmp(dfui_response_get_action_id(r), "ok") == 0) {
106 new_ds = dfui_response_dataset_get_first(r);
107 memtestsize = dfui_dataset_get_value(new_ds, "memtestsize");
108 cmds = commands_new();
109 cmd = command_add(cmds,
110 "cd %s && %s%s %s 1 --log",
112 a->os_root, cmd_name(a, "MEMTEST"),
114 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
115 cmd = command_add(cmds,
116 "%s%s -E -v '^Unable to malloc' %smemtest.log > %smemtest.log.new",
117 a->os_root, cmd_name(a, "GREP"),
119 cmd = command_add(cmds, "%s%s %smemtest.log.new %smemtest.log",
120 a->os_root, cmd_name(a, "MV"),
122 cmd = command_add(cmds,
123 "%s%s -E -v '^Allocated.*failed' %smemtest.log > %smemtest.log.new",
124 a->os_root, cmd_name(a, "GREP"),
126 cmd = command_add(cmds, "%s%s %smemtest.log.new %smemtest.log",
127 a->os_root, cmd_name(a, "MV"),
129 if (commands_execute(a, cmds)) {
132 cmds = commands_new();
133 cmd = command_add(cmds, "%s%s -f %smemtest.log",
134 a->os_root, cmd_name(a, "RM"),
136 commands_execute(a, cmds);
138 inform(a->c, _("Memory test could not be run."));
144 dfui_response_free(r);
148 view_memtest_log(struct i_fn_args *a)
150 struct aura_buffer *error_log;
152 struct dfui_response *r;
154 error_log = aura_buffer_new(1024);
155 aura_buffer_cat_file(error_log, "%smemtest.log", a->tmp);
157 f = dfui_form_create(
160 aura_buffer_buf(error_log),
163 "p", "role", "informative",
164 "p", "minimum_width", "72",
165 "p", "monospaced", "true",
167 "a", "ok", _("OK"), "", "",
168 "p", "accelerator", "ESC",
173 if (!dfui_be_present(a->c, f, &r))
177 dfui_response_free(r);
179 aura_buffer_free(error_log);
183 fn_show_dmesg(struct i_fn_args *a)
185 struct aura_buffer *e;
187 struct dfui_response *r;
189 e = aura_buffer_new(1024);
190 aura_buffer_cat_file(e, "%s%s", a->os_root, cmd_name(a, "DMESG_BOOT"));
192 f = dfui_form_create(
194 _("System Startup Messages (dmesg)"),
198 "p", "role", "informative",
199 "p", "minimum_width", "72",
200 "p", "monospaced", "true",
202 "a", "ok", _("OK"), "", "",
203 "p", "accelerator", "ESC",
208 if (!dfui_be_present(a->c, f, &r))
212 dfui_response_free(r);
218 fn_show_pciconf(struct i_fn_args *a)
220 struct aura_buffer *e;
222 struct dfui_response *r;
224 e = aura_buffer_new(1024);
225 aura_buffer_cat_pipe(e, "pciconf -l -v");
227 f = dfui_form_create(
233 "p", "role", "informative",
234 "p", "minimum_width", "72",
235 "p", "monospaced", "true",
237 "a", "ok", _("OK"), "", "",
238 "p", "accelerator", "ESC",
243 if (!dfui_be_present(a->c, f, &r))
247 dfui_response_free(r);
253 fn_show_pnpinfo(struct i_fn_args *a)
255 struct aura_buffer *e;
257 struct dfui_response *r;
259 e = aura_buffer_new(1024);
260 aura_buffer_cat_pipe(e, "pnpinfo");
262 f = dfui_form_create(
264 _("ISA PnP Devices"),
268 "p", "role", "informative",
269 "p", "minimum_width", "72",
270 "p", "monospaced", "true",
272 "a", "ok", _("OK"), "", "",
273 "p", "accelerator", "ESC",
278 if (!dfui_be_present(a->c, f, &r))
282 dfui_response_free(r);
288 fn_show_natacontrol(struct i_fn_args *a)
290 struct aura_buffer *e;
292 struct dfui_response *r;
294 e = aura_buffer_new(1024);
295 aura_buffer_cat_pipe(e, "natacontrol list");
297 f = dfui_form_create(
303 "p", "role", "informative",
304 "p", "minimum_width", "72",
305 "p", "monospaced", "true",
307 "a", "ok", _("OK"), "", "",
308 "p", "accelerator", "ESC",
313 if (!dfui_be_present(a->c, f, &r))
317 dfui_response_free(r);
323 show_ifconfig(struct dfui_connection *c, char *ifname)
325 struct aura_buffer *e;
327 e = aura_buffer_new(1024);
328 aura_buffer_cat_pipe(e, "/sbin/ifconfig %s", ifname);
329 inform(c, aura_buffer_buf(e));