]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/hwinfo/hwinfo.c
8b32957f35080ab66e50f8d010aa1b1549477668
14 static int get_probe_flags(int, char **, hd_data_t
*);
15 static void progress2(char *, char *);
17 // ##### temporary solution, fix it later!
18 str_list_t
*read_file(char *file_name
, unsigned start_line
, unsigned lines
);
19 str_list_t
*search_str_list(str_list_t
*sl
, char *str
);
20 str_list_t
*add_str_list(str_list_t
**sl
, char *str
);
21 char *new_str(const char *);
23 static unsigned deb
= 0;
24 static char *log_file
= "";
25 static char *list
= NULL
;
26 static int listplus
= 0;
29 static int is_short
= 0;
31 static char *showconfig
= NULL
;
32 static char *saveconfig
= NULL
;
33 static hd_hw_item_t hw_item
[100] = { };
34 static int hw_items
= 0;
36 int braille_install_info(hd_data_t
*hd_data
);
37 int x11_install_info(hd_data_t
*hd_data
);
38 int oem_install_info(hd_data_t
*hd_data
);
39 void dump_packages(hd_data_t
*hd_data
);
41 void do_hw(hd_data_t
*hd_data
, FILE *f
, hd_hw_item_t hw_item
);
42 void do_hw_multi(hd_data_t
*hd_data
, FILE *f
, hd_hw_item_t
*hw_items
);
43 void do_short(hd_data_t
*hd_data
, hd_t
*hd
, FILE *f
);
44 void do_test(hd_data_t
*hd_data
);
46 void dump_db_raw(hd_data_t
*hd_data
);
47 void dump_db(hd_data_t
*hd_data
);
48 void do_chroot(hd_data_t
*hd_data
, char *dir
);
49 void ask_db(hd_data_t
*hd_data
, char *query
);
50 void get_mapping(hd_data_t
*hd_data
);
59 struct option options
[] = {
60 { "special", 1, NULL
, 1 },
61 { "help", 0, NULL
, 'h' },
62 { "debug", 1, NULL
, 'd' },
63 { "version", 0, NULL
, 400 },
64 { "log", 1, NULL
, 'l' },
65 { "packages", 0, NULL
, 'p' },
66 { "test", 0, NULL
, 300 },
67 { "format", 1, NULL
, 301 },
68 { "show-config", 1, NULL
, 302 },
69 { "save-config", 1, NULL
, 303 },
70 { "short", 0, NULL
, 304 },
71 { "fast", 0, NULL
, 305 },
72 { "dump-db", 1, NULL
, 306 },
73 { "dump-db-raw", 1, NULL
, 307 },
74 { "separate", 0, NULL
, 308 },
75 { "root", 1, NULL
, 309 },
76 { "db", 1, NULL
, 310 },
77 { "only", 1, NULL
, 311 },
78 { "listmd", 0, NULL
, 312 },
79 { "map", 0, NULL
, 313 },
80 { "kernel-version", 1, NULL
, 314 },
81 { "cdrom", 0, NULL
, 1000 + hw_cdrom
},
82 { "floppy", 0, NULL
, 1000 + hw_floppy
},
83 { "disk", 0, NULL
, 1000 + hw_disk
},
84 { "network", 0, NULL
, 1000 + hw_network
},
85 { "display", 0, NULL
, 1000 + hw_display
},
86 { "gfxcard", 0, NULL
, 1000 + hw_display
},
87 { "framebuffer", 0, NULL
, 1000 + hw_framebuffer
},
88 { "monitor", 0, NULL
, 1000 + hw_monitor
},
89 { "camera", 0, NULL
, 1000 + hw_camera
},
90 { "mouse", 0, NULL
, 1000 + hw_mouse
},
91 { "joystick", 0, NULL
, 1000 + hw_joystick
},
92 { "keyboard", 0, NULL
, 1000 + hw_keyboard
},
93 { "chipcard", 0, NULL
, 1000 + hw_chipcard
},
94 { "sound", 0, NULL
, 1000 + hw_sound
},
95 { "isdn", 0, NULL
, 1000 + hw_isdn
},
96 { "modem", 0, NULL
, 1000 + hw_modem
},
97 { "storage-ctrl", 0, NULL
, 1000 + hw_storage_ctrl
},
98 { "storage_ctrl", 0, NULL
, 1000 + hw_storage_ctrl
},
99 { "netcard", 0, NULL
, 1000 + hw_network_ctrl
},
100 { "netcards", 0, NULL
, 1000 + hw_network_ctrl
}, // outdated, just kept for comaptibility
101 { "network-ctrl", 0, NULL
, 1000 + hw_network_ctrl
},
102 { "network_ctrl", 0, NULL
, 1000 + hw_network_ctrl
},
103 { "printer", 0, NULL
, 1000 + hw_printer
},
104 { "tv", 0, NULL
, 1000 + hw_tv
},
105 { "dvb", 0, NULL
, 1000 + hw_dvb
},
106 { "scanner", 0, NULL
, 1000 + hw_scanner
},
107 { "braille", 0, NULL
, 1000 + hw_braille
},
108 { "sys", 0, NULL
, 1000 + hw_sys
},
109 { "bios", 0, NULL
, 1000 + hw_bios
},
110 { "cpu", 0, NULL
, 1000 + hw_cpu
},
111 { "partition", 0, NULL
, 1000 + hw_partition
},
112 { "usb-ctrl", 0, NULL
, 1000 + hw_usb_ctrl
},
113 { "usb_ctrl", 0, NULL
, 1000 + hw_usb_ctrl
},
114 { "usb", 0, NULL
, 1000 + hw_usb
},
115 { "pci", 0, NULL
, 1000 + hw_pci
},
116 { "isapnp", 0, NULL
, 1000 + hw_isapnp
},
117 { "scsi", 0, NULL
, 1000 + hw_scsi
},
118 { "ide", 0, NULL
, 1000 + hw_ide
},
119 { "bridge", 0, NULL
, 1000 + hw_bridge
},
120 { "hub", 0, NULL
, 1000 + hw_hub
},
121 { "memory", 0, NULL
, 1000 + hw_memory
},
122 { "manual", 0, NULL
, 1000 + hw_manual
},
123 { "pcmcia", 0, NULL
, 1000 + hw_pcmcia
},
124 { "pcmcia_ctrl", 0, NULL
, 1000 + hw_pcmcia_ctrl
},
125 { "ieee1394", 0, NULL
, 1000 + hw_ieee1394
},
126 { "ieee1394_ctrl", 0, NULL
, 1000 + hw_ieee1394_ctrl
},
127 { "firewire", 0, NULL
, 1000 + hw_ieee1394
},
128 { "firewire_ctrl", 0, NULL
, 1000 + hw_ieee1394_ctrl
},
129 { "hotplug", 0, NULL
, 1000 + hw_hotplug
},
130 { "hotplug_ctrl", 0, NULL
, 1000 + hw_hotplug_ctrl
},
131 { "zip", 0, NULL
, 1000 + hw_zip
},
132 { "pppoe", 0, NULL
, 1000 + hw_pppoe
},
133 { "dsl", 0, NULL
, 1000 + hw_dsl
},
134 { "wlan", 0, NULL
, 1000 + hw_wlan
},
135 { "redasd", 0, NULL
, 1000 + hw_redasd
},
136 { "block", 0, NULL
, 1000 + hw_block
},
137 { "tape", 0, NULL
, 1000 + hw_tape
},
138 { "vbe", 0, NULL
, 1000 + hw_vbe
},
139 { "bluetooth", 0, NULL
, 1000 + hw_bluetooth
},
140 { "all", 0, NULL
, 2000 },
141 { "reallyall", 0, NULL
, 2001 },
142 { "smp", 0, NULL
, 2002 },
143 { "arch", 0, NULL
, 2003 },
144 { "uml", 0, NULL
, 2004 },
150 * Just scan the hardware and dump all info.
152 int main(int argc
, char **argv
)
158 unsigned first_probe
= 1;
160 hd_data
= calloc(1, sizeof *hd_data
);
161 hd_data
->progress
= isatty(1) ? progress2
: NULL
;
162 hd_data
->debug
=~(HD_DEB_DRIVER_INFO
| HD_DEB_HDDB
);
164 for(i
= 0; i
< argc
; i
++) {
165 if(strstr(argv
[i
], "--") == argv
[i
]) break;
169 /* new style interface */
173 while((i
= getopt_long(argc
, argv
, "hd:l:p", options
, NULL
)) != -1) {
176 if(!strcmp(optarg
, "braille")) {
177 braille_install_info(hd_data
);
179 else if(!strcmp(optarg
, "x11")) {
180 x11_install_info(hd_data
);
182 else if(!strcmp(optarg
, "oem")) {
183 oem_install_info(hd_data
);
192 hd_data
->debug
= strtol(optarg
, NULL
, 0);
200 dump_packages(hd_data
);
208 hd_data
->flags
.dformat
= strtol(optarg
, NULL
, 0);
224 hd_data
->flags
.fast
= 1;
228 opt
.db_idx
= strtoul(optarg
, NULL
, 0);
233 opt
.db_idx
= strtoul(optarg
, NULL
, 0);
234 dump_db_raw(hd_data
);
238 /* basically for debugging */
247 ask_db(hd_data
, optarg
);
251 if(*optarg
) add_str_list(&hd_data
->only
, optarg
);
255 hd_data
->flags
.list_md
= 1;
259 get_mapping(hd_data
);
263 if(*optarg
) setenv("LIBHD_KERNELVERSION", optarg
, 1);
267 printf("%s\n", hd_version());
271 if(hw_items
< (int) (sizeof hw_item
/ sizeof *hw_item
) - 1)
272 hw_item
[hw_items
++] = i
- 1000;
280 if(hw_items
< (int) (sizeof hw_item
/ sizeof *hw_item
) - 1)
281 hw_item
[hw_items
++] = i
;
290 if(!hw_items
&& is_short
) hw_item
[hw_items
++] = 2000; /* all */
292 if(hw_items
>= 0 || showconfig
|| saveconfig
) {
294 if(!strcmp(log_file
, "-")) {
298 f
= fopen(log_file
, "w+");
302 if(opt
.root
) do_chroot(hd_data
, opt
.root
);
304 if(opt
.separate
|| hw_items
<= 1) {
305 for(i
= 0; i
< hw_items
; i
++) {
306 if(i
) fputc('\n', f
? f
: stdout
);
307 do_hw(hd_data
, f
, hw_item
[i
]);
311 hw_item
[hw_items
] = 0;
312 do_hw_multi(hd_data
, f
, hw_item
);
317 hd
= hd_read_config(hd_data
, showconfig
);
319 hd_dump_entry(hd_data
, hd
, f
? f
: stdout
);
320 hd
= hd_free_hd_list(hd
);
323 fprintf(f
? f
: stdout
, "No config data: %s\n", showconfig
);
328 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
329 if(!strcmp(hd
->unique_id
, saveconfig
)) {
330 i
= hd_write_config(hd_data
, hd
);
331 fprintf(f
? f
: stdout
, "%s: %s\n",
333 i
? "Error writing config data" : "config saved"
339 fprintf(f
? f
: stdout
, "No such hardware: %s\n", saveconfig
);
347 hd_free_hd_data(hd_data
);
353 /* old style interface */
357 if(argc
== 1 && !strcmp(*argv
, "-h")) {
363 if(first_probe
) /* only for the 1st probing */
364 hd_set_probe_feature(hd_data
, pr_default
);
366 hd_clear_probe_feature(hd_data
, pr_all
);
369 if((i
= get_probe_flags(argc
, argv
, hd_data
)) < 0) return 1;
370 deb
= hd_data
->debug
;
371 argc
-= i
; argv
+= i
;
373 if(opt
.root
&& first_probe
) do_chroot(hd_data
, opt
.root
);
376 if(hd_data
->progress
) printf("\r%64s\r", "");
382 if(!strcmp(log_file
, "-")) {
386 f
= fopen(log_file
, "w+");
390 if((hd_data
->debug
& HD_DEB_SHOW_LOG
) && hd_data
->log
) {
392 fprintf(f
? f
: stdout
,
393 "============ start hardware log ============\n"
396 fprintf(f
? f
: stdout
,
397 "============ start debug info ============\n%s=========== end debug info ============\n",
402 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
403 hd_dump_entry(hd_data
, hd
, f
? f
: stdout
);
407 fprintf(f
? f
: stdout
,
408 "============ end hardware log ============\n"
414 if(!strcmp(list
, "cdrom")) i
= hw_cdrom
;
415 if(!strcmp(list
, "disk")) i
= hw_disk
;
416 if(!strcmp(list
, "floppy")) i
= hw_floppy
;
417 if(!strcmp(list
, "network")) i
= hw_network
;
418 if(!strcmp(list
, "display")) i
= hw_display
;
419 if(!strcmp(list
, "monitor")) i
= hw_monitor
;
420 if(!strcmp(list
, "mouse")) i
= hw_mouse
;
421 if(!strcmp(list
, "keyboard")) i
= hw_keyboard
;
422 if(!strcmp(list
, "sound")) i
= hw_sound
;
423 if(!strcmp(list
, "isdn")) i
= hw_isdn
;
424 if(!strcmp(list
, "dsl")) i
= hw_dsl
;
425 if(!strcmp(list
, "modem")) i
= hw_modem
;
426 if(!strcmp(list
, "storage_ctrl")) i
= hw_storage_ctrl
;
427 if(!strcmp(list
, "network_ctrl")) i
= hw_network_ctrl
;
428 if(!strcmp(list
, "netcards")) i
= hw_network_ctrl
;
429 if(!strcmp(list
, "printer")) i
= hw_printer
;
430 if(!strcmp(list
, "tv")) i
= hw_tv
;
431 if(!strcmp(list
, "scanner")) i
= hw_scanner
;
432 if(!strcmp(list
, "braille")) i
= hw_braille
;
433 if(!strcmp(list
, "sys")) i
= hw_sys
;
434 if(!strcmp(list
, "cpu")) i
= hw_cpu
;
437 hd
= hd_list(hd_data
, i
, listplus
, NULL
);
439 printf("-- %s list --\n", list
);
440 for(; hd
; hd
= hd
->next
) hd_dump_entry(hd_data
, hd
, stdout
);
441 printf("-- %s list end --\n", list
);
442 hd
= hd_free_hd_list(hd
);
448 hd_free_hd_data(hd_data
);
455 void do_hw(hd_data_t
*hd_data
, FILE *f
, hd_hw_item_t hw_item
)
458 int smp
= -1, uml
= 0, i
;
460 enum boot_arch b_arch
;
461 enum cpu_arch c_arch
;
467 smp
= hd_smp_support(hd_data
);
474 switch((int) hw_item
) {
475 case 2000: i
= pr_default
; break;
476 case 2001: i
= pr_all
; break;
477 case 2003: i
= pr_cpu
; break;
480 hd_clear_probe_feature(hd_data
, pr_all
);
481 hd_set_probe_feature(hd_data
, i
);
488 uml
= hd_is_uml(hd_data
);
492 hd0
= hd_list(hd_data
, hw_item
, 1, NULL
);
495 if(hd_data
->progress
) {
496 printf("\r%64s\r", "");
501 if((hd_data
->debug
& HD_DEB_SHOW_LOG
) && hd_data
->log
) {
503 "============ start hardware log ============\n"
506 "============ start debug info ============\n%s=========== end debug info ============\n",
511 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
512 hd_dump_entry(hd_data
, hd
, f
);
516 "============ end hardware log ============\n"
520 if(hw_item
== 2002) {
521 fprintf(f
? f
: stdout
,
523 smp
< 0 ? "unknown" : smp
> 0 ? "yes" : "no"
525 if(smp
> 0) fprintf(f
? f
: stdout
, " (%u cpus)", smp
);
526 fprintf(f
? f
: stdout
, "\n");
528 else if(hw_item
== 2003) {
529 c_arch
= hd_cpu_arch(hd_data
);
530 b_arch
= hd_boot_arch(hd_data
);
546 s
= "UltraSparc (64)";
609 fprintf(f
? f
: stdout
, "Arch: %s/%s\n", s
, t
);
611 else if(hw_item
== 2004) {
612 fprintf(f
? f
: stdout
, "UML: %s\n", uml
? "yes" : "no");
616 /* always to stdout */
617 do_short(hd_data
, hd0
, stdout
);
618 if(f
) do_short(hd_data
, hd0
, f
);
621 for(hd
= hd0
; hd
; hd
= hd
->next
) {
622 hd_dump_entry(hd_data
, hd
, f
? f
: stdout
);
627 if(hw_item
== hw_display
&& hd0
) {
628 fprintf(f
? f
: stdout
, "\nPrimary display adapter: #%u\n", hd_display_adapter(hd_data
));
631 if(hd0
!= hd_data
->hd
) hd_free_hd_list(hd0
);
635 void do_hw_multi(hd_data_t
*hd_data
, FILE *f
, hd_hw_item_t
*hw_items
)
639 hd0
= hd_list2(hd_data
, hw_items
, 1);
641 if(hd_data
->progress
) {
642 printf("\r%64s\r", "");
647 if((hd_data
->debug
& HD_DEB_SHOW_LOG
) && hd_data
->log
) {
649 "============ start hardware log ============\n"
652 "============ start debug info ============\n%s=========== end debug info ============\n",
657 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
658 hd_dump_entry(hd_data
, hd
, f
);
662 "============ end hardware log ============\n"
667 /* always to stdout */
668 do_short(hd_data
, hd0
, stdout
);
669 if(f
) do_short(hd_data
, hd0
, f
);
672 for(hd
= hd0
; hd
; hd
= hd
->next
) {
673 hd_dump_entry(hd_data
, hd
, f
? f
: stdout
);
677 hd_free_hd_list(hd0
);
681 void do_short(hd_data_t
*hd_data
, hd_t
*hd
, FILE *f
)
689 for(item
= 1; item
< hw_all
; item
++) {
691 s
= hd_hw_item_name(item
);
694 if(item
== hw_sys
) continue;
696 for(hd1
= hd
; hd1
; hd1
= hd1
->next
) {
697 if(hd1
->hw_class
== item
) {
698 if(!i
++) fprintf(f
, "%s:\n", s
);
699 fprintf(f
, " %-20s %s\n",
700 hd1
->unix_dev_name
? hd1
->unix_dev_name
: "",
701 hd1
->model
? hd1
->model
: "???"
712 char *vendor
, *model
, *driver
;
715 static scanner_t scanner_data
[] = {
716 { "Abaton", "SCAN 300/GS", "abaton" },
717 { "Abaton", "SCAN 300/S", "abaton" },
718 { "Acer", "300f", "SnapScan" },
719 { "Acer", "310s", "SnapScan" },
720 { "Acer", "610plus", "SnapScan" },
721 { "Acer", "610s", "SnapScan" },
722 { "Acer", "Prisa 1240", "SnapScan" },
723 { "Acer", "Prisa 3300", "SnapScan" },
724 { "Acer", "Prisa 4300", "SnapScan" },
725 { "Acer", "Prisa 5300", "SnapScan" },
726 { "Acer", "Prisa 620s", "SnapScan" },
727 { "Acer", "Prisa 620u", "SnapScan" },
728 { "Acer", "Prisa 620ut", "SnapScan" },
729 { "Acer", "Prisa 640bu", "SnapScan" },
730 { "Acer", "Prisa 640u", "SnapScan" },
731 { "Agfa", "Arcus II", "microtek" },
732 { "Agfa", "DuoScan", "microtek" },
733 { "Agfa", "FOCUS COLOR", "agfafocus" },
734 { "Agfa", "FOCUS GS SCANNER", "agfafocus" },
735 { "Agfa", "FOCUS II", "agfafocus" },
736 { "Agfa", "FOCUS LINEART SCANNER", "agfafocus" },
737 { "Agfa", "SnapScan 1212u", "SnapScan" },
738 { "Agfa", "SnapScan 1236s", "SnapScan" },
739 { "Agfa", "SnapScan 1236u", "SnapScan" },
740 { "Agfa", "SnapScan 300", "SnapScan" },
741 { "Agfa", "SnapScan 310", "SnapScan" },
742 { "Agfa", "SnapScan 600", "SnapScan" },
743 { "Agfa", "SnapScan e20", "SnapScan" },
744 { "Agfa", "SnapScan e25", "SnapScan" },
745 { "Agfa", "SnapScan e40", "SnapScan" },
746 { "Agfa", "SnapScan e50", "SnapScan" },
747 { "Agfa", "SnapScan e60", "SnapScan" },
748 { "Agfa", "StudioScan", "microtek" },
749 { "Agfa", "StudioScan II", "microtek" },
750 { "Agfa", "StudioScan IIsi", "microtek" },
751 { "Apple", "APPLE SCANNER", "apple" },
752 { "Apple", "COLORONESCANNER", "apple" },
753 { "Apple", "ONESCANNER", "apple" },
754 { "Artec", "A6000C", "artec" },
755 { "Artec", "A6000C PLUS", "artec" },
756 { "Artec", "AM12S", "artec" },
757 { "Artec", "AT12", "artec" },
758 { "Artec", "AT3", "artec" },
759 { "Artec", "AT6", "artec" },
760 { "Artec", "ColorOneScanner", "artec" },
761 { "Avision", "AV 620 CS", "avision" },
762 { "Avision", "AV 6240", "avision" },
763 { "Avision", "AV 630 CS", "avision" },
764 { "B&H SCSI", "COPISCAN II 2135", "bh" },
765 { "B&H SCSI", "COPISCAN II 2137", "bh" },
766 { "B&H SCSI", "COPISCAN II 2137A", "bh" },
767 { "B&H SCSI", "COPISCAN II 2138A", "bh" },
768 { "B&H SCSI", "COPISCAN II 3238", "bh" },
769 { "B&H SCSI", "COPISCAN II 3338", "bh" },
770 { "B&H SCSI", "COPISCAN II 6338", "bh" },
771 { "BlackWidow", "BW4800SP", "artec" },
772 { "Canon", "CANOSCAN 2700F", "canon" },
773 { "Canon", "CANOSCAN 300", "canon" },
774 { "Canon", "CANOSCAN 600", "canon" },
775 { "Devcom", "9636PRO", "pie" },
776 { "Devcom", "9636S", "pie" },
777 { "EDGE", "KTX-9600US", "umax" },
778 { "Epson", "ES-8500", "epson" },
779 { "Epson", "EXPRESSION 1600", "epson" },
780 { "Epson", "EXPRESSION 1680", "epson" },
781 { "Epson", "EXPRESSION 636", "epson" },
782 { "Epson", "EXPRESSION 800", "epson" },
783 { "Epson", "FILMSCAN 200", "epson" },
784 { "Epson", "GT-5500", "epson" },
785 { "Epson", "GT-7000", "epson" },
786 { "Epson", "GT-8000", "epson" },
787 { "Epson", "PERFECTION 1200PHOTO", "epson" },
788 { "Epson", "PERFECTION 1200S", "epson" },
789 { "Epson", "PERFECTION 1200U", "epson" },
790 { "Epson", "PERFECTION 1240", "epson" },
791 { "Epson", "PERFECTION 1640", "epson" },
792 { "Epson", "PERFECTION 1650", "epson" },
793 { "Epson", "PERFECTION 610", "epson" },
794 { "Epson", "PERFECTION 636S", "epson" },
795 { "Epson", "PERFECTION 636U", "epson" },
796 { "Epson", "PERFECTION 640", "epson" },
797 { "Epson", "PERFECTION1200", "epson" },
798 { "Epson", "Perfection 600", "umax" },
799 { "Escom", "Image Scanner 256", "umax" },
800 { "Escort", "Galleria 600", "umax" },
801 { "Fujitsu", "M3091DCD", "m3091" },
802 { "Fujitsu", "M3096G", "m3096g" },
803 { "Fujitsu", "SP15C", "sp15c" },
804 { "Genius", "ColorPage-HR5 Pro", "umax" },
805 { "Guillemot", "Maxi Scan A4 Deluxe", "SnapScan" },
806 { "HP", "HP OFFICEJET K SERIES", "hp" },
807 { "HP", "HP OFFICEJET V SERIES", "hp" },
808 { "HP", "HP PHOTOSMART PHOTOSCANNER", "hp" },
809 { "HP", "HP PSC 700 SERIES", "hp" },
810 { "HP", "HP PSC 900 SERIES", "hp" },
811 { "HP", "HP SCANJET 3C", "hp" },
812 { "HP", "HP SCANJET 3P", "hp" },
813 { "HP", "HP SCANJET 4100C", "hp" },
814 { "HP", "HP SCANJET 4C", "hp" },
815 { "HP", "HP SCANJET 4P", "hp" },
816 { "HP", "HP SCANJET 5200C", "hp" },
817 { "HP", "HP SCANJET 6100C", "hp" },
818 { "HP", "HP SCANJET 6200C", "hp" },
819 { "HP", "HP SCANJET 6250C", "hp" },
820 { "HP", "HP SCANJET 6300C", "hp" },
821 { "HP", "HP SCANJET 6350C", "hp" },
822 { "HP", "HP SCANJET 6390C", "hp" },
823 { "HP", "HP SCANJET IIC", "hp" },
824 { "HP", "HP SCANJET IICX", "hp" },
825 { "HP", "HP SCANJET IIP", "hp" },
826 { "HP", "HP ScanJet 5p", "hp" },
827 { "HP", "HP4200", "hp4200" },
828 { "Highscreen", "Scanboostar Premium", "umax" },
829 { "Linotype Hell", "Jade", "umax" },
830 { "Linotype Hell", "Jade2", "umax" },
831 { "Linotype Hell", "Linoscan 1400", "umax" },
832 { "Linotype Hell", "Opal", "umax" },
833 { "Linotype Hell", "Opal Ultra", "umax" },
834 { "Linotype Hell", "Saphir", "umax" },
835 { "Linotype Hell", "Saphir HiRes", "umax" },
836 { "Linotype Hell", "Saphir Ultra", "umax" },
837 { "Linotype Hell", "Saphir Ultra II", "umax" },
838 { "Linotype Hell", "Saphir2", "umax" },
839 { "Microtek", "Phantom 636", "microtek2" },
840 { "Microtek", "ScanMaker 330", "microtek2" },
841 { "Microtek", "ScanMaker 3600", "sm3600" },
842 { "Microtek", "ScanMaker 630", "microtek2" },
843 { "Microtek", "ScanMaker 636", "microtek2" },
844 { "Microtek", "ScanMaker 9600XL", "microtek2" },
845 { "Microtek", "ScanMaker E3plus", "microtek2" },
846 { "Microtek", "ScanMaker V300", "microtek2" },
847 { "Microtek", "ScanMaker V310", "microtek2" },
848 { "Microtek", "ScanMaker V600", "microtek2" },
849 { "Microtek", "ScanMaker V6USL", "microtek2" },
850 { "Microtek", "ScanMaker X6", "microtek2" },
851 { "Microtek", "ScanMaker X6EL", "microtek2" },
852 { "Microtek", "ScanMaker X6USB", "microtek2" },
853 { "Microtek", "Scanmaker 35", "microtek" },
854 { "Microtek", "Scanmaker 35t+", "microtek" },
855 { "Microtek", "Scanmaker 45t", "microtek" },
856 { "Microtek", "Scanmaker 600G", "microtek" },
857 { "Microtek", "Scanmaker 600G S", "microtek" },
858 { "Microtek", "Scanmaker 600GS", "microtek" },
859 { "Microtek", "Scanmaker 600S", "microtek" },
860 { "Microtek", "Scanmaker 600Z", "microtek" },
861 { "Microtek", "Scanmaker 600Z S", "microtek" },
862 { "Microtek", "Scanmaker 600ZS", "microtek" },
863 { "Microtek", "Scanmaker E2", "microtek" },
864 { "Microtek", "Scanmaker E3", "microtek" },
865 { "Microtek", "Scanmaker E6", "microtek" },
866 { "Microtek", "Scanmaker II", "microtek" },
867 { "Microtek", "Scanmaker IIG", "microtek" },
868 { "Microtek", "Scanmaker IIHR", "microtek" },
869 { "Microtek", "Scanmaker III", "microtek" },
870 { "Microtek", "Scanmaker IISP", "microtek" },
871 { "Microtek", "SlimScan C6", "microtek2" },
872 { "Mustek", "1200 CU", "mustek_usb" },
873 { "Mustek", "1200 CU Plus", "mustek_usb" },
874 { "Mustek", "1200 UB", "mustek_usb" },
875 { "Mustek", "600 CU", "mustek_usb" },
876 { "Mustek", "Paragon 1200 A3 Pro", "mustek" },
877 { "Mustek", "Paragon 1200 III SP", "mustek" },
878 { "Mustek", "Paragon 1200 LS", "mustek" },
879 { "Mustek", "Paragon 1200 SP Pro", "mustek" },
880 { "Mustek", "Paragon 600 II CD", "mustek" },
881 { "Mustek", "Paragon 800 II SP", "mustek" },
882 { "Mustek", "Paragon MFC-600S", "mustek" },
883 { "Mustek", "Paragon MFC-800S", "mustek" },
884 { "Mustek", "Paragon MFS-12000CX", "mustek" },
885 { "Mustek", "Paragon MFS-12000SP", "mustek" },
886 { "Mustek", "Paragon MFS-1200SP", "mustek" },
887 { "Mustek", "Paragon MFS-6000CX", "mustek" },
888 { "Mustek", "Paragon MFS-6000SP", "mustek" },
889 { "Mustek", "Paragon MFS-8000SP", "mustek" },
890 { "Mustek", "ScanExpress 12000SP", "mustek" },
891 { "Mustek", "ScanExpress 12000SP Plus", "mustek" },
892 { "Mustek", "ScanExpress 6000SP", "mustek" },
893 { "Mustek", "ScanExpress A3 SP", "mustek" },
894 { "Mustek", "ScanMagic 600 II SP", "mustek" },
895 { "Mustek", "ScanMagic 9636S", "mustek" },
896 { "Mustek", "ScanMagic 9636S Plus", "mustek" },
897 { "NEC", "PC-IN500/4C", "nec" },
898 { "Nikon", "AX-210", "umax" },
899 { "Nikon", "LS-1000", "coolscan" },
900 { "Nikon", "LS-20", "coolscan" },
901 { "Nikon", "LS-2000", "coolscan" },
902 { "Nikon", "LS-30", "coolscan" },
903 { "Pie", "9630S", "pie" },
904 { "Pie", "ScanAce 1230S", "pie" },
905 { "Pie", "ScanAce 1236S", "pie" },
906 { "Pie", "ScanAce 630S", "pie" },
907 { "Pie", "ScanAce 636S", "plustek" },
908 { "Pie", "ScanAce II", "pie" },
909 { "Pie", "ScanAce II Plus", "pie" },
910 { "Pie", "ScanAce III", "pie" },
911 { "Pie", "ScanAce III Plus", "pie" },
912 { "Pie", "ScanAce Plus", "pie" },
913 { "Pie", "ScanAce ScanMedia", "pie" },
914 { "Pie", "ScanAce ScanMedia II", "pie" },
915 { "Pie", "ScanAce V", "pie" },
916 { "Plustek", "OpticPro 19200S", "artec" },
917 { "Polaroid", "DMC", "dmc" },
918 { "Ricoh", "Ricoh IS50", "ricoh" },
919 { "Ricoh", "Ricoh IS60", "ricoh" },
920 { "Scanport", "SQ4836", "microtek2" },
921 { "Sharp", "9036 Flatbed scanner", "sharp" },
922 { "Sharp", "JX-250", "sharp" },
923 { "Sharp", "JX-320", "sharp" },
924 { "Sharp", "JX-330", "sharp" },
925 { "Sharp", "JX-350", "sharp" },
926 { "Sharp", "JX-610", "sharp" },
927 { "Siemens", "9036 Flatbed scanner", "s9036" },
928 { "Siemens", "FOCUS COLOR PLUS", "agfafocus" },
929 { "Siemens", "ST400", "st400" },
930 { "Siemens", "ST800", "st400" },
931 { "Tamarack", "Artiscan 12000C", "tamarack" },
932 { "Tamarack", "Artiscan 6000C", "tamarack" },
933 { "Tamarack", "Artiscan 8000C", "tamarack" },
934 { "Trust", "Compact Scan USB 19200", "mustek_usb" },
935 { "Trust", "Imagery 1200 SP", "mustek" },
936 { "Trust", "Imagery 4800 SP", "mustek" },
937 { "Trust", "SCSI Connect 19200", "mustek" },
938 { "Trust", "SCSI excellence series 19200", "mustek" },
939 { "UMAX", "Astra 1200S", "umax" },
940 { "UMAX", "Astra 1220S", "umax" },
941 { "UMAX", "Astra 2100S", "umax" },
942 { "UMAX", "Astra 2200", "umax" },
943 { "UMAX", "Astra 2200 S", "umax" },
944 { "UMAX", "Astra 2200 U", "umax" },
945 { "UMAX", "Astra 2400S", "umax" },
946 { "UMAX", "Astra 600S", "umax" },
947 { "UMAX", "Astra 610S", "umax" },
948 { "UMAX", "Gemini D-16", "umax" },
949 { "UMAX", "Mirage D-16L", "umax" },
950 { "UMAX", "Mirage II", "umax" },
951 { "UMAX", "Mirage IIse", "umax" },
952 { "UMAX", "PL-II", "umax" },
953 { "UMAX", "PSD", "umax" },
954 { "UMAX", "PowerLook", "umax" },
955 { "UMAX", "PowerLook 2000", "umax" },
956 { "UMAX", "PowerLook 3000", "umax" },
957 { "UMAX", "PowerLook III", "umax" },
958 { "UMAX", "Supervista S-12", "umax" },
959 { "UMAX", "UC 1200S", "umax" },
960 { "UMAX", "UC 1200SE", "umax" },
961 { "UMAX", "UC 1260", "umax" },
962 { "UMAX", "UC 630", "umax" },
963 { "UMAX", "UC 840", "umax" },
964 { "UMAX", "UG 630", "umax" },
965 { "UMAX", "UG 80", "umax" },
966 { "UMAX", "UMAX S-12", "umax" },
967 { "UMAX", "UMAX S-12G", "umax" },
968 { "UMAX", "UMAX S-6E", "umax" },
969 { "UMAX", "UMAX S-6EG", "umax" },
970 { "UMAX", "UMAX VT600", "umax" },
971 { "UMAX", "Vista S6", "umax" },
972 { "UMAX", "Vista S6E", "umax" },
973 { "UMAX", "Vista-S8", "umax" },
974 { "UMAX", "Vista-T630", "umax" },
975 { "Ultima", "A6000C", "artec" },
976 { "Ultima", "A6000C PLUS", "artec" },
977 { "Ultima", "AM12S", "artec" },
978 { "Ultima", "AT12", "artec" },
979 { "Ultima", "AT3", "artec" },
980 { "Ultima", "AT6", "artec" },
981 { "Ultima", "ColorOneScanner", "artec" },
982 { "Vobis", "HighScan", "microtek2" },
983 { "Vobis", "Scanboostar Premium", "umax" },
984 { "Vuego", "Close SnapScan 310 compatible.", "SnapScan" }
987 static char *scanner_info(hd_t
*hd
)
991 if(!hd
->vendor
.name
|| !hd
->device
.name
) return NULL
;
993 for(i
= 0; (unsigned) i
< sizeof scanner_data
/ sizeof *scanner_data
; i
++) {
995 !strcasecmp(scanner_data
[i
].vendor
, hd
->vendor
.name
) &&
996 !strcasecmp(scanner_data
[i
].model
, hd
->device
.name
)
998 return scanner_data
[i
].driver
;
1007 void do_test(hd_data_t
*hd_data
)
1014 int i
, wheels
, buttons
;
1018 hd_hw_item_t item
, items
[] = {
1019 hw_display
, hw_monitor
, hw_tv
, hw_sound
, hw_mouse
, hw_disk
, hw_cdrom
,
1020 hw_floppy
, hw_modem
, hw_isdn
, hw_scanner
, hw_camera
1023 hd_set_probe_feature(hd_data
, pr_default
);
1026 f
= fopen("/tmp/hw_overview.log", "w");
1028 for(i
= 0; (unsigned) i
< sizeof items
/ sizeof *items
; i
++) {
1030 hd0
= hd_list(hd_data
, item
, 0, NULL
);
1036 fprintf(f
, "Disk\n");
1037 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1039 for(res
= hd
->res
; res
; res
= res
->next
) {
1040 if(res
->any
.type
== res_size
&& res
->size
.unit
== size_unit_sectors
) {
1041 ul
= (uint64_t) res
->size
.val1
* (res
->size
.val2
?: 0x200);
1042 u
= ((ul
>> 29) + 1) >> 1;
1046 fprintf(f
, " %s", hd
->model
);
1049 if(s
) fprintf(f
, "%s, ", s
);
1050 fprintf(f
, "%u GB)", u
);
1058 fprintf(f
, "CD-ROM\n");
1059 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1061 fprintf(f
, " %s (", hd
->model
);
1062 if(s
) fprintf(f
, "%s, ", s
);
1063 fprintf(f
, "%s)", hd
->prog_if
.name
?: "CD-ROM");
1070 fprintf(f
, "Monitor\n");
1071 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1073 if(!strcmp(hd
->unique_id
, "rdCR.EY_qmtb9YY0")) s
= "not detected";
1074 fprintf(f
, " %s\n", s
);
1080 fprintf(f
, "GFX Card\n");
1081 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1084 for(di
= hd
->driver_info
; di
; di
= di
->next
) {
1085 if(di
->any
.type
== di_x11
) {
1086 if(!s1
) s1
= di
->x11
.server
;
1087 if(di
->x11
.x3d
&& !u
) {
1088 s1
= di
->x11
.server
;
1094 s1
= "not supported";
1097 fprintf(f
, " %s (%s", hd
->model
, s1
);
1098 if(u
) fprintf(f
, ", 3D support");
1106 fprintf(f
, "Mouse\n");
1107 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1108 buttons
= wheels
= -1; // make gcc happy
1110 for(di
= hd
->driver_info
; di
; di
= di
->next
) {
1111 if(di
->any
.type
== di_mouse
) {
1112 buttons
= di
->mouse
.buttons
;
1113 wheels
= di
->mouse
.wheels
;
1119 s
= "not supported";
1120 buttons
= wheels
= -1;
1122 fprintf(f
, " %s (%s", hd
->model
, s
);
1123 if(buttons
>= 0) fprintf(f
, ", %d buttons", buttons
);
1124 if(wheels
>= 0) fprintf(f
, ", %d wheels", wheels
);
1132 fprintf(f
, "TV Card\n");
1133 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1135 for(di
= hd
->driver_info
; di
; di
= di
->next
) {
1137 (di
->any
.type
== di_any
|| di
->any
.type
== di_module
) &&
1141 s
= di
->any
.hddb0
->str
;
1146 s
= "not supported";
1148 fprintf(f
, " %s (%s)\n", hd
->model
, s
);
1154 fprintf(f
, "Sound Card\n");
1155 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1157 for(di
= hd
->driver_info
; di
; di
= di
->next
) {
1159 (di
->any
.type
== di_any
|| di
->any
.type
== di_module
) &&
1163 s
= di
->any
.hddb0
->str
;
1168 s
= "not supported";
1170 fprintf(f
, " %s (%s)\n", hd
->model
, s
);
1176 fprintf(f
, "Digital Camera/WebCam\n");
1177 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1178 fprintf(f
, " %s\n", hd
->model
);
1184 fprintf(f
, "Floppy/Zip Drive\n");
1185 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1186 fprintf(f
, " %s\n", hd
->model
);
1192 fprintf(f
, "Modem\n");
1193 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1194 fprintf(f
, " %s\n", hd
->model
);
1200 fprintf(f
, "ISDN\n");
1201 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1202 fprintf(f
, " %s (%ssupported)\n", hd
->model
, hd
->driver_info
? "" : "not ");
1208 fprintf(f
, "Scanner\n");
1209 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1210 s
= scanner_info(hd
);
1211 if(!s
) s
= "not supported";
1212 fprintf(f
, " %s (%s)\n", hd
->model
, s
);
1221 hd_free_hd_list(hd0
);
1227 f
= fopen("/tmp/hw_detail.log", "w");
1231 "============ start detailed hardware log ============\n"
1234 "============ start debug info ============\n%s=========== end debug info ============\n",
1239 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
1240 hd_dump_entry(hd_data
, hd
, f
);
1244 "============ end detailed hardware log ============\n"
1249 fprintf(stderr
, "\n");
1257 for(hd
= hd_list(hd_data
, hw_cdrom
, 1, hd0
); hd
; hd
= hd
->next
) {
1258 fprintf(stderr
, "cdrom: %s, %s\n", hd
->unix_dev_name
, hd
->model
);
1261 for(hd
= hd_list(hd_data
, hw_cdrom
, 1, hd0
); hd
; hd
= hd
->next
) {
1262 fprintf(stderr
, "cdrom: %s, %s\n", hd
->unix_dev_name
, hd
->model
);
1269 hd
= hd_list(hd_data
, hw_disk
, 1, NULL
);
1270 hd_free_hd_list(hd
);
1271 hd_free_hd_data(hd_data
);
1273 hd
= hd_list(hd_data
, hw_cdrom
, 1, NULL
);
1274 hd_free_hd_list(hd
);
1275 hd_free_hd_data(hd_data
);
1277 hd
= hd_list(hd_data
, hw_storage_ctrl
, 1, NULL
);
1278 hd_free_hd_list(hd
);
1279 hd_free_hd_data(hd_data
);
1281 hd
= hd_list(hd_data
, hw_display
, 1, NULL
);
1282 hd_free_hd_list(hd
);
1283 hd_free_hd_data(hd_data
);
1286 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
1287 hd_dump_entry(hd_data
, hd
, stdout
);
1290 printf("%s\n", hd_data
->log
);
1298 hd0
= hd_list(hd_data
, hw_sound
, 1, NULL
);
1299 hd0
= hd_list(hd_data
, hw_sound
, 1, NULL
);
1301 for(hd
= hd0
; hd
; hd
= hd
->next
) {
1302 hd_dump_entry(hd_data
, hd
, stdout
);
1306 hd_data
->log
= free_mem(hd_data
->log
);
1307 dump_hddb_data(hd_data
, hd_data
->hddb_dev
, "hddb_dev, final");
1308 if(hd_data
->log
) printf("%s", hd_data
->log
);
1318 hd
= hd_list(hd_data
, hw_sys
, 1, NULL
);
1320 for(di
= hd
->driver_info
; di
; di
= di
->next
) {
1321 if(di
->any
.type
== di_module
) {
1322 for(sl
= di
->module
.names
; sl
; sl
= sl
->next
) printf("%s\n", sl
->str
);
1333 "Usage: hwinfo [options]\n"
1334 "Probe for hardware.\n"
1335 " --short just a short listing\n"
1336 " --log logfile write info to logfile\n"
1337 " --debug level set debuglevel\n"
1338 " --version show libhd version\n"
1339 " --dump-db n dump hardware data base, 0: external, 1: internal\n"
1340 " --hw_item probe for hw_item\n"
1341 " hw_item is one of:\n"
1342 " all, bios, block, bluetooth, braille, bridge, camera, cdrom, chipcard, cpu,\n"
1343 " disk, dsl, dvb, floppy, framebuffer, gfxcard, hub, ide, isapnp, isdn,\n"
1344 " joystick, keyboard, memory, modem, monitor, mouse, netcard, network,\n"
1345 " partition, pci, pcmcia, pcmcia-ctrl, pppoe, printer, scanner, scsi, smp,\n"
1346 " sound, storage-ctrl, sys, tape, tv, usb, usb-ctrl, vbe, wlan, zip\n\n"
1347 " Note: debug info is shown only in the log file. (If you specify a\n"
1348 " log file the debug level is implicitly set to a reasonable value.)\n"
1354 * Parse command line options.
1356 int get_probe_flags(int argc
, char **argv
, hd_data_t
*hd_data
)
1360 for(i
= 0; i
< argc
; i
++) {
1363 if(!strcmp(s
, ".")) {
1368 if(!strncmp(s
, t
, strlen(t
))) {
1369 hd_data
->debug
= strtol(s
+ strlen(t
), NULL
, 0);
1374 if(!strncmp(s
, t
, strlen(t
))) {
1375 list
= s
+ strlen(t
);
1380 if(!strncmp(s
, t
, strlen(t
))) {
1381 list
= s
+ strlen(t
);
1387 if(!strncmp(s
, t
, strlen(t
))) {
1388 log_file
= s
+ strlen(t
);
1393 if(!strncmp(s
, t
, strlen(t
))) {
1394 add_str_list(&hd_data
->only
, s
+ strlen(t
));
1399 if(!strncmp(s
, t
, strlen(t
))) {
1400 opt
.root
= s
+ strlen(t
);
1410 if((j
= hd_probe_feature_by_name(s
))) {
1412 hd_set_probe_feature(hd_data
, j
);
1414 hd_clear_probe_feature(hd_data
, j
);
1418 fprintf(stderr
, "oops: don't know what to do with \"%s\"\n", s
);
1426 * A simple progress function.
1428 void progress2(char *pos
, char *msg
)
1430 if(!test
) printf("\r%64s\r", "");
1431 printf("> %s: %s", pos
, msg
);
1432 if(test
) printf("\n");
1437 #define INSTALL_INF "/etc/install.inf"
1439 int braille_install_info(hd_data_t
*hd_data
)
1443 char *braille
= NULL
;
1444 char *braille_dev
= NULL
;
1445 str_list_t
*sl0
, *sl
;
1448 hd
= hd_list(hd_data
, hw_braille
, 1, NULL
);
1450 if(hd_data
->progress
) {
1451 printf("\r%64s\r", "");
1455 for(; hd
; hd
= hd
->next
) {
1457 hd
->base_class
.id
== bc_braille
&& /* is a braille display */
1458 hd
->unix_dev_name
&& /* and has a device name */
1459 (braille
= hd
->device
.name
)
1461 braille_dev
= hd
->unix_dev_name
;
1469 printf("found a %s at %s\n", braille
, braille_dev
);
1471 sl0
= read_file(INSTALL_INF
, 0, 0);
1472 f
= fopen(INSTALL_INF
, "w");
1474 perror(INSTALL_INF
);
1478 for(sl
= sl0
; sl
; sl
= sl
->next
) {
1480 strstr(sl
->str
, "Braille:") != sl
->str
&&
1481 strstr(sl
->str
, "Brailledevice:") != sl
->str
1483 fprintf(f
, "%s", sl
->str
);
1487 fprintf(f
, "Braille: %s\n", braille
);
1488 fprintf(f
, "Brailledevice: %s\n", braille_dev
);
1497 * get VGA parameter from /proc/cmdline
1503 char buf
[256], *s
, *t
;
1506 if((f
= fopen("/proc/cmdline", "r"))) {
1507 if(fgets(buf
, sizeof buf
, f
)) {
1509 while((s
= strsep(&t
, " "))) {
1510 if(sscanf(s
, "vga=%i", &i
) == 1) fb_mode
= i
;
1511 if(strstr(s
, "vga=normal") == s
) fb_mode
= 0;
1517 return fb_mode
> 0x10 ? fb_mode
: 0;
1519 /* this is the only valid test for active framebuffer ... */
1522 if((f
= fopen("/dev/fb", "r"))) {
1533 * read "x11i=" entry from /proc/cmdline
1538 char buf
[256], *s
, *t
;
1539 static char x11i
[64] = { };
1541 if(*x11i
) return x11i
;
1543 if((f
= fopen("/proc/cmdline", "r"))) {
1544 if(fgets(buf
, sizeof buf
, f
)) {
1546 while((s
= strsep(&t
, " "))) {
1547 if(sscanf(s
, "x11i=%60s", x11i
) == 1) break;
1558 * Assumes xf86_ver to be either "3" or "4" (or empty).
1560 char *get_xserver(hd_data_t
*hd_data
, char **version
, char **busid
, driver_info_t
**x11_driver
)
1562 static char display
[16];
1563 static char xf86_ver
[2];
1565 char c
, *x11i
= get_x11i();
1571 *display
= *xf86_ver
= *id
= c
= 0;
1572 *version
= xf86_ver
;
1576 if(*x11i
== '3' || *x11i
== '4') {
1580 if(*x11i
>= 'A' && *x11i
<= 'Z') {
1583 if(*x11i
>= 'a' && *x11i
<= 'z') {
1587 strncpy(display
, x11i
, sizeof display
- 1);
1588 display
[sizeof display
- 1] = 0;
1593 if(c
) { xf86_ver
[0] = c
; xf86_ver
[1] = 0; }
1595 hd
= hd_get_device_by_idx(hd_data
, hd_display_adapter(hd_data
));
1597 if(hd
&& hd
->bus
.id
== bus_pci
)
1598 sprintf(id
, "%d:%d:%d", hd
->slot
>> 8, hd
->slot
& 0xff, hd
->func
);
1600 if(!hd
|| *display
) return display
;
1602 for(di
= hd
->driver_info
; di
; di
= di
->next
) {
1603 if(di
->any
.type
== di_x11
&& di
->x11
.server
&& di
->x11
.xf86_ver
&& !di
->x11
.x3d
) {
1604 if(c
== 0 || c
== di
->x11
.xf86_ver
[0]) {
1605 xf86_ver
[0] = di
->x11
.xf86_ver
[0];
1607 strncpy(display
, di
->x11
.server
, sizeof display
- 1);
1608 display
[sizeof display
- 1] = 0;
1615 if(*display
) return display
;
1617 if(c
== 0) c
= '4'; /* default to XF 4, if nothing else is known */
1621 strcpy(display
, c
== '3' ? "FBDev" : "fbdev");
1626 int x11_install_info(hd_data_t
*hd_data
)
1631 int fb_mode
, kbd_ok
= 0;
1632 unsigned yast2_color
= 0;
1633 char *xkbrules
= NULL
, *xkbmodel
= NULL
, *xkblayout
= NULL
;
1634 char *xserver
, *version
, *busid
;
1635 driver_info_t
*x11_driver
;
1636 str_list_t
*sl0
, *sl
;
1639 /* get color info */
1640 hd_set_probe_feature(hd_data
, pr_cpu
);
1641 hd_set_probe_feature(hd_data
, pr_prom
);
1645 fb_mode
= get_fb_mode();
1647 hd_list(hd_data
, hw_display
, 1, NULL
);
1649 for(hd
= hd_list(hd_data
, hw_keyboard
, 1, NULL
); hd
; hd
= hd
->next
) {
1651 di
= hd
->driver_info
;
1652 if(di
&& di
->any
.type
== di_kbd
) {
1653 xkbrules
= di
->kbd
.XkbRules
;
1654 xkbmodel
= di
->kbd
.XkbModel
;
1655 xkblayout
= di
->kbd
.XkbLayout
;
1661 xserver
= get_xserver(hd_data
, &version
, &busid
, &x11_driver
);
1663 switch(hd_mac_color(hd_data
)) {
1665 yast2_color
= 0x5a4add;
1668 yast2_color
= 0x32cd32;
1671 yast2_color
= 0xff7f50;
1674 yast2_color
= 0x000000;
1677 yast2_color
= 0x7f7f7f;
1681 if(hd_data
->progress
) {
1682 printf("\r%64s\r", "");
1686 sl0
= read_file(INSTALL_INF
, 0, 0);
1687 f
= fopen(INSTALL_INF
, "w");
1689 perror(INSTALL_INF
);
1693 for(sl
= sl0
; sl
; sl
= sl
->next
) {
1695 strstr(sl
->str
, "Framebuffer:") != sl
->str
&&
1696 strstr(sl
->str
, "XServer:") != sl
->str
&&
1697 strstr(sl
->str
, "XVersion:") != sl
->str
&&
1698 strstr(sl
->str
, "XBusID:") != sl
->str
&&
1699 strstr(sl
->str
, "X11i:") != sl
->str
&&
1700 strstr(sl
->str
, "Keyboard:") != sl
->str
&&
1701 strstr(sl
->str
, "XkbRules:") != sl
->str
&&
1702 strstr(sl
->str
, "XkbModel:") != sl
->str
&&
1703 strstr(sl
->str
, "XkbLayout:") != sl
->str
&&
1704 strstr(sl
->str
, "XF86Ext:") != sl
->str
&&
1705 strstr(sl
->str
, "XF86Raw:") != sl
->str
1707 fprintf(f
, "%s", sl
->str
);
1711 fprintf(f
, "Keyboard: %d\n", kbd_ok
);
1712 if(fb_mode
) fprintf(f
, "Framebuffer: 0x%04x\n", fb_mode
);
1713 if(x11i
) fprintf(f
, "X11i: %s\n", x11i
);
1714 if(xserver
&& *xserver
) {
1715 fprintf(f
, "XServer: %s\n", xserver
);
1716 if(*version
) fprintf(f
, "XVersion: %s\n", version
);
1717 if(*busid
) fprintf(f
, "XBusID: %s\n", busid
);
1719 if(xkbrules
&& *xkbrules
) fprintf(f
, "XkbRules: %s\n", xkbrules
);
1720 if(xkbmodel
&& *xkbmodel
) fprintf(f
, "XkbModel: %s\n", xkbmodel
);
1721 if(xkblayout
&& *xkblayout
) fprintf(f
, "XkbLayout: %s\n", xkblayout
);
1724 for(sl
= x11_driver
->x11
.extensions
; sl
; sl
= sl
->next
) {
1725 if(*sl
->str
) fprintf(f
, "XF86Ext: Load\t\t\"%s\"\n", sl
->str
);
1727 for(sl
= x11_driver
->x11
.options
; sl
; sl
= sl
->next
) {
1728 if(*sl
->str
) fprintf(f
, "XF86Raw: Option\t\"%s\"\n", sl
->str
);
1730 for(sl
= x11_driver
->x11
.raw
; sl
; sl
= sl
->next
) {
1731 if(*sl
->str
) fprintf(f
, "XF86Raw: %s\n", sl
->str
);
1741 char *xserver3map
[] =
1747 #if defined(__i386__) || defined(__alpha__) || defined(__ia64__)
1751 #if defined(__i386__) || defined(__alpha__)
1752 "MACH64", "xmach64",
1760 "SUNMONO", "xsunmono",
1765 "VMWARE", "xvmware",
1771 void dump_packages(hd_data_t
*hd_data
)
1776 hd_data
->progress
= NULL
;
1779 sl
= get_hddb_packages(hd_data
);
1781 for(i
= 0; xserver3map
[i
]; i
+= 2) {
1782 if (!search_str_list(sl
, xserver3map
[i
+ 1]))
1783 add_str_list(&sl
, new_str(xserver3map
[i
+ 1]));
1786 for(; sl
; sl
= sl
->next
) {
1787 printf("%s\n", sl
->str
);
1793 struct x11pack
*next
;
1797 int oem_install_info(hd_data_t
*hd_data
)
1801 str_list_t
*x11packs
= 0;
1802 str_list_t
*sl0
, *sl
;
1806 driver_info_x11_t
*di
, *drvinfo
;
1808 hd_set_probe_feature(hd_data
, pr_pci
);
1810 pcmcia
= hd_has_pcmcia(hd_data
);
1812 for(hd
= hd_list(hd_data
, hw_display
, 1, NULL
); hd
; hd
= hd
->next
) {
1813 for(str
= hd
->requires
; str
; str
= str
->next
) {
1814 if(!search_str_list(x11packs
, str
->str
)) {
1815 add_str_list(&x11packs
, str
->str
);
1818 drvinfo
= (driver_info_x11_t
*) hd
->driver_info
;
1819 for (di
= drvinfo
; di
; di
= (driver_info_x11_t
*)di
->next
) {
1820 if (di
->type
!= di_x11
)
1822 if (di
->xf86_ver
[0] == '3') {
1823 char *server
= di
->server
;
1825 for (i
= 0; xserver3map
[i
]; i
+= 2)
1826 if (!strcmp(xserver3map
[i
], server
))
1829 if (!search_str_list(x11packs
, xserver3map
[i
+ 1]))
1830 add_str_list(&x11packs
, xserver3map
[i
+ 1]);
1836 if(hd_data
->progress
) {
1837 printf("\r%64s\r", "");
1841 sl0
= read_file(INSTALL_INF
, 0, 0);
1842 f
= fopen(INSTALL_INF
, "w");
1844 perror(INSTALL_INF
);
1847 for(sl
= sl0
; sl
; sl
= sl
->next
) {
1849 strstr(sl
->str
, "X11Packages:") != sl
->str
&&
1850 strstr(sl
->str
, "Pcmcia:") != sl
->str
1852 fprintf(f
, "%s", sl
->str
);
1856 fprintf(f
, "X11Packages: ");
1857 for (sl
= x11packs
; sl
; sl
= sl
->next
) {
1860 fprintf(f
, "%s", sl
->str
);
1865 fprintf(f
, "Pcmcia: %d\n", pcmcia
);
1871 void dump_db_raw(hd_data_t
*hd_data
)
1873 hd_data
->progress
= NULL
;
1874 hd_clear_probe_feature(hd_data
, pr_all
);
1877 if(opt
.db_idx
>= sizeof hd_data
->hddb2
/ sizeof *hd_data
->hddb2
) return;
1879 hddb_dump_raw(hd_data
->hddb2
[opt
.db_idx
], stdout
);
1883 void dump_db(hd_data_t
*hd_data
)
1885 hd_data
->progress
= NULL
;
1886 hd_clear_probe_feature(hd_data
, pr_all
);
1889 if(opt
.db_idx
>= sizeof hd_data
->hddb2
/ sizeof *hd_data
->hddb2
) return;
1891 hddb_dump(hd_data
->hddb2
[opt
.db_idx
], stdout
);
1895 void do_chroot(hd_data_t
*hd_data
, char *dir
)
1900 ADD2LOG("chroot %s: %s\n", dir
, i
? strerror(errno
) : "ok");
1906 void ask_db(hd_data_t
*hd_data
, char *query
)
1910 str_list_t
*sl
, *query_sl
;
1911 unsigned tag
= 0, u
, cnt
;
1914 setenv("hwprobe", "-all", 1);
1917 hd
= add_hd_entry(hd_data
, __LINE__
, 0);
1919 query_sl
= hd_split(' ', query
);
1921 for(sl
= query_sl
; sl
; sl
= sl
->next
) {
1922 if(!strcmp(sl
->str
, "pci")) { tag
= TAG_PCI
; continue; }
1923 if(!strcmp(sl
->str
, "usb")) { tag
= TAG_USB
; continue; }
1924 if(!strcmp(sl
->str
, "pnp")) { tag
= TAG_EISA
; continue; }
1925 if(!strcmp(sl
->str
, "isapnp")) { tag
= TAG_EISA
; continue; }
1926 if(!strcmp(sl
->str
, "special")) { tag
= TAG_SPECIAL
; continue; }
1927 if(!strcmp(sl
->str
, "pcmcia")) { tag
= TAG_PCMCIA
; continue; }
1929 if(sscanf(sl
->str
, "class=%i%n", &u
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1930 hd
->base_class
.id
= u
>> 16;
1931 hd
->sub_class
.id
= (u
>> 8) & 0xff;
1932 hd
->prog_if
.id
= u
& 0xff;
1936 if(sscanf(sl
->str
, "vendor=%i%n", &u
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1937 hd
->vendor
.id
= MAKE_ID(tag
, u
);
1941 if(sscanf(sl
->str
, "vendor=%3s%n", buf
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1942 u
= name2eisa_id(buf
);
1943 if(u
) hd
->vendor
.id
= u
;
1948 if(sscanf(sl
->str
, "device=%i%n", &u
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1949 hd
->device
.id
= MAKE_ID(tag
, u
);
1953 if(sscanf(sl
->str
, "subvendor=%i%n", &u
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1954 hd
->sub_vendor
.id
= MAKE_ID(tag
, u
);
1958 if(sscanf(sl
->str
, "subvendor=%3s%n", buf
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1959 u
= name2eisa_id(buf
);
1960 if(u
) hd
->sub_vendor
.id
= u
;
1965 if(sscanf(sl
->str
, "subdevice=%i%n", &u
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1966 hd
->sub_device
.id
= MAKE_ID(tag
, u
);
1970 if(sscanf(sl
->str
, "revision=%i%n", &u
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1971 hd
->revision
.id
= u
;
1975 if(sscanf(sl
->str
, "serial=%255s%n", buf
, &cnt
) >= 1 && !sl
->str
[cnt
]) {
1976 hd
->serial
= new_str(buf
);
1982 free_str_list(query_sl
);
1984 hddb_add_info(hd_data
, hd
);
1986 for(di
= hd
->driver_info
; di
; di
= di
->next
) {
1987 if(di
->any
.type
== di_module
&& di
->module
.modprobe
) {
1988 for(sl
= di
->module
.names
; sl
; sl
= sl
->next
) {
1989 printf("%s%c", sl
->str
, sl
->next
? ' ' : '\n');
1996 int is_same_block_dev(hd_t
*hd1
, hd_t
*hd2
)
1998 if(!hd1
|| !hd2
|| hd1
== hd2
) return 0;
2001 hd1
->base_class
.id
!= hd2
->base_class
.id
||
2002 hd1
->sub_class
.id
!= hd2
->sub_class
.id
2008 strcmp(hd1
->model
, hd2
->model
)
2011 if(hd1
->revision
.name
|| hd2
->revision
.name
) {
2013 !hd1
->revision
.name
||
2014 !hd2
->revision
.name
||
2015 strcmp(hd1
->revision
.name
, hd2
->revision
.name
)
2019 if(hd1
->serial
|| hd2
->serial
) {
2023 strcmp(hd1
->serial
, hd2
->serial
)
2031 hd_t
*get_same_block_dev(hd_t
*hd_list
, hd_t
*hd
, hd_status_value_t status
)
2033 for(; hd_list
; hd_list
= hd_list
->next
) {
2034 if(hd_list
->status
.available
!= status
) continue;
2035 if(is_same_block_dev(hd_list
, hd
)) return hd_list
;
2042 void get_mapping(hd_data_t
*hd_data
)
2044 hd_t
*hd_manual
, *hd
, *hd2
;
2049 unsigned maps
= 0, u
;
2051 hd_hw_item_t hw_items
[] = { hw_disk
, hw_cdrom
, 0 };
2053 hd_data
->progress
= NULL
;
2055 hd_data
->flags
.list_all
= 1;
2057 hd_manual
= hd_list2(hd_data
, hw_items
, 1);
2058 for(hd
= hd_manual
; hd
&& maps
< sizeof map
/ sizeof *map
; hd
= hd
->next
) {
2059 if(!hd
->unix_dev_name
) continue;
2061 if(hd
->status
.available
== status_yes
) {
2062 /* check if we already have an active device with the same name */
2063 for(broken
= u
= 0; u
< maps
; u
++) {
2064 if(!strcmp(map
[u
].hd
->unix_dev_name
, hd
->unix_dev_name
)) {
2069 if(broken
) continue;
2071 /* ensure we really can tell different devices apart */
2072 if(get_same_block_dev(hd_manual
, hd
, status_yes
)) {
2074 map
[maps
].unknown
= 1;
2083 /* ok, we have a list of all new devs */
2085 for(u
= 0; u
< maps
; u
++) {
2086 if(map
[u
].unknown
) {
2087 printf("%s\n", map
[u
].hd
->unix_dev_name
);
2091 for(hd2
= hd_manual
; (hd2
= get_same_block_dev(hd2
, map
[u
].hd
, status_no
)); hd2
= hd2
->next
) {
2092 if(hd2
->unix_dev_name
&& strcmp(map
[u
].hd
->unix_dev_name
, hd2
->unix_dev_name
)) {
2093 printf("%s\t%s", first
? map
[u
].hd
->unix_dev_name
: "", hd2
->unix_dev_name
);
2097 if(!first
) printf("\n");