2
* info_fbsd.cpp is part of the KDE program kcminfo. This displays
3
* various information about the system (hopefully a FreeBSD system)
6
* All of the devinfo bits were blatantly stolen from the devinfo utility
7
* provided with FreeBSD 5.0 (and later). No gross hacks were harmed
8
* during the creation of info_fbsd.cpp. Thanks Mike.
12
* all following functions should return true, when the Information
13
* was filled into the QTreeWidget. Returning false indicates that
14
* information was not available.
17
#include "config-infocenter.h" // HAVE_DEVINFO_H
18
#include <sys/types.h>
19
#include <sys/sysctl.h>
32
#include <QTextStream>
34
void ProcessChildren(QString name);
38
int print_irq(struct devinfo_rman *rman, void *arg);
39
int print_dma(struct devinfo_rman *rman, void *arg);
40
int print_ioports(struct devinfo_rman *rman, void *arg);
41
int print_resource(struct devinfo_res *res, void *arg);
45
bool GetInfo_IRQ(QTreeWidget* tree) {
47
/* systat lists the interrupts assigned to devices as well as how many were
48
generated. Parsing its output however is about as fun as a sandpaper
49
enema. The best idea would probably be to rip out the guts of systat.
50
Too bad it's not very well commented */
51
/* Oh neat, current now has a neat little utility called devinfo */
54
devinfo_foreach_rman(print_irq, tree);
61
bool GetInfo_DMA(QTreeWidget* tree) {
63
/* Oh neat, current now has a neat little utility called devinfo */
66
devinfo_foreach_rman(print_dma, tree);
73
bool GetInfo_IO_Ports(QTreeWidget* tree) {
75
/* Oh neat, current now has a neat little utility called devinfo */
78
devinfo_foreach_rman(print_ioports, tree);
85
bool GetInfo_SCSI(QTreeWidget* tree) {
90
if (!QFileInfo(QLatin1String("/sbin/camcontrol")).exists()) {
91
s = i18n("SCSI subsystem could not be queried: /sbin/camcontrol could not be found");
94
new QTreeWidgetItem(tree, list);
95
} else if ((pipe = popen("/sbin/camcontrol devlist 2>&1", "r")) == NULL) {
96
s = i18n("SCSI subsystem could not be queried: /sbin/camcontrol could not be executed");
99
new QTreeWidgetItem(tree, list);
102
/* This prints out a list of all the scsi devies, perhaps eventually we could
103
parse it as opposed to schlepping it into a listbox */
105
t = new QTextStream(pipe, QIODevice::ReadOnly);
113
new QTreeWidgetItem(tree, list);
120
if (!tree->topLevelItemCount())
126
bool GetInfo_PCI(QTreeWidget* tree) {
129
QTreeWidgetItem *olditem= NULL;
131
const QStringList headers(i18nc("@title:column Column name for PCI information", "Information"));
132
tree->setHeaderLabels(headers);
134
if (!QFileInfo(QLatin1String("/usr/sbin/pciconf")).exists()) {
136
list << i18n("Could not find any programs with which to query your system's PCI information");
137
new QTreeWidgetItem(tree, list);
140
cmd = "/usr/sbin/pciconf -l -v 2>&1";
143
// TODO: GetInfo_ReadfromPipe should be improved so that we could pass the program name and its
144
// arguments to it and remove most of the code below.
145
if ((pipe = popen(cmd.toLatin1(), "r")) == NULL) {
147
list << i18n("PCI subsystem could not be queried: %1 could not be executed", cmd);
148
olditem = new QTreeWidgetItem(olditem, list);
150
/* This prints out a list of all the pci devies, perhaps eventually we could
151
parse it as opposed to schlepping it into a listbox */
152
QTextStream outputStream(pipe, QIODevice::ReadOnly);
154
while (!outputStream.atEnd()) {
155
s = outputStream.readLine();
158
const QStringList list(s);
159
new QTreeWidgetItem(tree, list);
165
if (!tree->topLevelItemCount()) {
166
QString str = i18n("The PCI subsystem could not be queried, this may need root privileges.");
167
olditem = new QTreeWidgetItem(tree, olditem);
168
olditem->setText(0, str);
175
bool GetInfo_XServer_and_Video(QTreeWidget* tree) {
176
return GetInfo_XServer_Generic(tree);
179
#ifdef HAVE_DEVINFO_H
181
int print_irq(struct devinfo_rman *rman, void *arg) {
182
QTreeWidget* tree = (QTreeWidget *)arg;
183
if (strcmp(rman->dm_desc, "Interrupt request lines")==0) {
186
list << rman->dm_desc;
187
new QTreeWidgetItem(tree, list);
188
devinfo_foreach_rman_resource(rman, print_resource, arg);
193
int print_dma(struct devinfo_rman *rman, void *arg)
195
QTreeWidget* tree = (QTreeWidget *)arg;
196
if (strcmp(rman->dm_desc, "DMA request lines")==0) {
198
list << rman->dm_desc;
199
new QTreeWidgetItem(tree, list);
200
devinfo_foreach_rman_resource(rman, print_resource, arg);
205
int print_ioports(struct devinfo_rman *rman, void *arg)
207
QTreeWidget* tree = (QTreeWidget*) arg;
209
if (strcmp(rman->dm_desc, "I/O ports")==0) {
211
list << rman->dm_desc;
212
new QTreeWidgetItem(tree, list);
214
devinfo_foreach_rman_resource(rman, print_resource, arg);
216
else if (strcmp(rman->dm_desc, "I/O memory addresses")==0) {
218
list << rman->dm_desc;
219
new QTreeWidgetItem(tree, list);
221
devinfo_foreach_rman_resource(rman, print_resource, arg);
226
int print_resource(struct devinfo_res *res, void *arg)
228
struct devinfo_dev *dev;
229
struct devinfo_rman *rman;
232
QTreeWidget* tree = (QTreeWidget*) arg;
236
rman = devinfo_handle_to_rman(res->dr_rman);
237
hexmode = (rman->dm_size > 100) || (rman->dm_size == 0);
238
tmp.sprintf(hexmode ? "0x%lx" : "%lu", res->dr_start);
240
if (res->dr_size > 1) {
241
tmp.sprintf(hexmode ? "-0x%lx" : "-%lu",
242
res->dr_start + res->dr_size - 1);
246
dev = devinfo_handle_to_device(res->dr_device);
247
if ((dev != NULL) && (dev->dd_name[0] != 0)) {
248
tmp.sprintf(" (%s)", dev->dd_name);
250
tmp.sprintf(" ----");
256
new QTreeWidgetItem(tree, list);