1 /*
2 * Copyright (c)2004 The DragonFly Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
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
14 * distribution.
15 *
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.
19 *
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.
32 */
33
34 /*
35 * fn_diagnostic.c
36 * Diagnostic functions for installer.
37 * $Id: fn_diagnostic.c,v 1.21 2005/03/13 01:53:58 cpressey Exp $
38 */
39
40 #include <sys/types.h>
41
42 #include <dirent.h>
43 #include <stdarg.h>
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <string.h>
47
48 #ifdef ENABLE_NLS
49 #include <libintl.h>
50 #define _(String) gettext (String)
51 #else
52 #define _(String) (String)
53 #endif
54
55 #include "libaura/mem.h"
56 #include "libaura/buffer.h"
57
58 #include "libdfui/dfui.h"
59
60 #include "libinstaller/commands.h"
61 #include "libinstaller/confed.h"
62 #include "libinstaller/diskutil.h"
63 #include "libinstaller/functions.h"
64 #include "libinstaller/uiutil.h"
65
66 #include "fn.h"
67 #include "pathnames.h"
68
69 /*** DIAGNOSTIC FUNCTIONS ***/
70
71 void
fn_show_dmesg(struct i_fn_args * a)72 fn_show_dmesg(struct i_fn_args *a)
73 {
74 struct aura_buffer *e;
75 struct dfui_form *f;
76 struct dfui_response *r;
77
78 e = aura_buffer_new(1024);
79 aura_buffer_cat_file(e, "%s%s", a->os_root, cmd_name(a, "DMESG_BOOT"));
80
81 f = dfui_form_create(
82 "dmesg",
83 _("System Startup Messages (dmesg)"),
84 aura_buffer_buf(e),
85 "",
86
87 "p", "role", "informative",
88 "p", "minimum_width", "72",
89 "p", "monospaced", "true",
90
91 "a", "ok", _("OK"), "", "",
92 "p", "accelerator", "ESC",
93
94 NULL
95 );
96
97 if (!dfui_be_present(a->c, f, &r))
98 abort_backend();
99
100 dfui_form_free(f);
101 dfui_response_free(r);
102
103 aura_buffer_free(e);
104 }
105
106 void
fn_show_pciconf(struct i_fn_args * a)107 fn_show_pciconf(struct i_fn_args *a)
108 {
109 struct aura_buffer *e;
110 struct dfui_form *f;
111 struct dfui_response *r;
112
113 e = aura_buffer_new(1024);
114 aura_buffer_cat_pipe(e, "pciconf -l -v");
115
116 f = dfui_form_create(
117 "pciconf",
118 _("PCI Devices"),
119 aura_buffer_buf(e),
120 "",
121
122 "p", "role", "informative",
123 "p", "minimum_width", "72",
124 "p", "monospaced", "true",
125
126 "a", "ok", _("OK"), "", "",
127 "p", "accelerator", "ESC",
128
129 NULL
130 );
131
132 if (!dfui_be_present(a->c, f, &r))
133 abort_backend();
134
135 dfui_form_free(f);
136 dfui_response_free(r);
137
138 aura_buffer_free(e);
139 }
140
141 void
fn_show_natacontrol(struct i_fn_args * a)142 fn_show_natacontrol(struct i_fn_args *a)
143 {
144 struct aura_buffer *e;
145 struct dfui_form *f;
146 struct dfui_response *r;
147
148 e = aura_buffer_new(1024);
149 aura_buffer_cat_pipe(e, "natacontrol list");
150
151 f = dfui_form_create(
152 "natacontrol",
153 _("ATA Devices"),
154 aura_buffer_buf(e),
155 "",
156
157 "p", "role", "informative",
158 "p", "minimum_width", "72",
159 "p", "monospaced", "true",
160
161 "a", "ok", _("OK"), "", "",
162 "p", "accelerator", "ESC",
163
164 NULL
165 );
166
167 if (!dfui_be_present(a->c, f, &r))
168 abort_backend();
169
170 dfui_form_free(f);
171 dfui_response_free(r);
172
173 aura_buffer_free(e);
174 }
175
176 void
show_ifconfig(struct dfui_connection * c,char * ifname)177 show_ifconfig(struct dfui_connection *c, char *ifname)
178 {
179 struct aura_buffer *e;
180
181 e = aura_buffer_new(1024);
182 aura_buffer_cat_pipe(e, "/sbin/ifconfig %s", ifname);
183 inform(c, "%s", aura_buffer_buf(e));
184 aura_buffer_free(e);
185 }
186