14
* @defgroup LIBHDint Internal utilities
15
* @ingroup libhdInternals
16
* @brief Internal utility functions
21
static void int_hotplug(hd_data_t *hd_data);
22
static void int_cdrom(hd_data_t *hd_data);
23
#if defined(__i386__) || defined (__x86_64__)
24
static int set_bios_id(hd_data_t *hd_data, hd_t *hd_ref, int bios_id);
25
static int bios_ctrl_order(hd_data_t *hd_data, unsigned *sctrl, int sctrl_len);
26
static void int_bios(hd_data_t *hd_data);
28
static void int_media_check(hd_data_t *hd_data);
29
static int contains_word(char *str, char *str2);
30
static int is_zip(hd_t *hd);
31
static void int_floppy(hd_data_t *hd_data);
32
static void int_fix_usb_scsi(hd_data_t *hd_data);
33
static void int_mouse(hd_data_t *hd_data);
34
static void new_id(hd_data_t *hd_data, hd_t *hd);
35
static void int_modem(hd_data_t *hd_data);
36
static void int_wlan(hd_data_t *hd_data);
37
static void int_udev(hd_data_t *hd_data);
38
static void int_devicenames(hd_data_t *hd_data);
39
#if defined(__i386__) || defined (__x86_64__)
40
static void int_softraid(hd_data_t *hd_data);
42
#if defined(__i386__) || defined (__x86_64__)
43
static void int_system(hd_data_t *hd_data);
44
static void int_legacy_geo(hd_data_t *hd_data);
46
static void int_find_parent(hd_data_t *hd_data);
47
static void int_add_driver_modules(hd_data_t *hd_data);
50
void hd_scan_int(hd_data_t *hd_data)
54
if(!hd_probe_feature(hd_data, pr_int)) return;
56
hd_data->module = mod_int;
59
remove_hd_entries(hd_data);
61
PROGRESS(2, 0, "cdrom");
64
PROGRESS(3, 0, "media");
65
int_media_check(hd_data);
67
PROGRESS(4, 0, "floppy");
70
#if defined(__i386__) || defined (__x86_64__)
71
PROGRESS(5, 0, "bios");
75
PROGRESS(6, 0, "mouse");
78
#if defined(__i386__) || defined (__x86_64__)
79
PROGRESS(15, 0, "system info");
83
PROGRESS(7, 0, "hdb");
84
hd_data->flags.keep_kmods = 1;
85
for(hd = hd_data->hd; hd; hd = hd->next) {
86
hddb_add_info(hd_data, hd);
88
hd_data->flags.keep_kmods = 0;
90
PROGRESS(7, 1, "modules");
91
int_add_driver_modules(hd_data);
93
PROGRESS(8, 0, "usbscsi");
94
int_fix_usb_scsi(hd_data);
96
PROGRESS(9, 0, "hotplug");
99
PROGRESS(10, 0, "modem");
102
PROGRESS(11, 0, "wlan");
105
PROGRESS(12, 0, "udev");
108
PROGRESS(13, 0, "device names");
109
int_devicenames(hd_data);
111
#if defined(__i386__) || defined (__x86_64__)
112
PROGRESS(14, 0, "soft raid");
113
int_softraid(hd_data);
115
PROGRESS(15, 0, "geo");
116
int_legacy_geo(hd_data);
119
PROGRESS(16, 0, "parent");
120
int_find_parent(hd_data);
124
* Identify hotpluggable devices.
126
void int_hotplug(hd_data_t *hd_data)
131
for(hd = hd_data->hd; hd; hd = hd->next) {
132
if(hd->bus.id == bus_usb || hd->usb_guid) {
133
hd->hotplug = hp_usb;
135
if((prop = hal_get_bool(hd->hal_prop, "storage.hotpluggable")) && prop->val.b) {
136
hd->is.hotpluggable = 1;
142
* Add more info to CDROM entries.
144
void int_cdrom(hd_data_t *hd_data)
149
for(hd = hd_data->hd; hd; hd = hd->next) {
151
hd->base_class.id == bc_storage_device &&
152
hd->sub_class.id == sc_sdev_cdrom
154
if(!hd->prog_if.id && hd->device.name && strstr(hd->device.name, "DVD")) hd->is.dvd = 1;
156
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.cdr")) && prop->val.b) {
159
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.cdrw")) && prop->val.b) {
162
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.dvdr")) && prop->val.b) {
165
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.dvdrw")) && prop->val.b) {
168
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.dvdram")) && prop->val.b) {
171
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.dvdplusr")) && prop->val.b) {
174
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.dvdplusrw")) && prop->val.b) {
177
if((prop = hal_get_bool(hd->hal_prop, "storage.cdrom.dvdplusrdl")) && prop->val.b) {
181
if(hd->is.dvd) hd->prog_if.id = 3;
186
#if defined(__i386__) || defined (__x86_64__)
188
int set_bios_id(hd_data_t *hd_data, hd_t *hd_ref, int bios_id)
193
if(!hd_ref || !hd_ref->unix_dev_name) return 0;
195
for(hd = hd_data->hd; hd; hd = hd->next) {
197
hd->base_class.id == bc_storage_device &&
198
hd->sub_class.id == sc_sdev_disk &&
200
!strcmp(hd->unix_dev_name, hd_ref->unix_dev_name)
202
str_printf(&hd->rom_id, 0, "0x%02x", bios_id);
211
int bios_ctrl_order(hd_data_t *hd_data, unsigned *sctrl, int sctrl_len)
215
int i, j, k, sctrl2_len = 0;
216
unsigned pci_slot, pci_func;
217
unsigned *sctrl2 = NULL, *sctrl3 = NULL;
220
for(bt = NULL, hd = hd_data->hd; hd; hd = hd->next) {
222
hd->base_class.id == bc_internal &&
223
hd->sub_class.id == sc_int_bios &&
225
hd->detail->type == hd_detail_bios &&
226
(bt = hd->detail->bios.data)
232
if(!bt || !bt->bios32.ok || !bt->bios32.compaq) return 0;
234
sctrl2 = new_mem((sizeof bt->bios32.cpq_ctrl / sizeof *bt->bios32.cpq_ctrl) * sizeof *sctrl2);
236
for(i = 0; (unsigned) i < sizeof bt->bios32.cpq_ctrl / sizeof *bt->bios32.cpq_ctrl; i++) {
238
bt->bios32.cpq_ctrl[i].id &&
239
!(bt->bios32.cpq_ctrl[i].misc & 0x40) /* bios support ??????? */
241
pci_slot = PCI_SLOT(bt->bios32.cpq_ctrl[i].devfn) + (bt->bios32.cpq_ctrl[i].bus << 8);
242
pci_func = PCI_FUNC(bt->bios32.cpq_ctrl[i].devfn);
243
for(hd = hd_data->hd; hd; hd = hd->next) {
244
if(hd->bus.id == bus_pci && hd->slot == pci_slot && hd->func == pci_func) {
245
sctrl2[sctrl2_len++] = hd->idx;
252
if(sctrl2_len) order_info = 1;
254
for(i = 0; i < sctrl2_len; i++) {
255
ADD2LOG(" bios ord %d: %d\n", i, sctrl2[i]);
260
sctrl3 = new_mem(sctrl_len * sizeof *sctrl3);
263
for(i = 0; i < sctrl2_len; i++) {
264
for(j = 0; j < sctrl_len; j++) {
265
if(sctrl[j] == sctrl2[i]) {
266
sctrl3[k++] = sctrl[j];
273
for(i = 0; i < sctrl_len; i++) {
274
if(sctrl[i] && k < sctrl_len) sctrl3[k++] = sctrl[i];
277
memcpy(sctrl, sctrl3, sctrl_len * sizeof *sctrl);
286
void int_bios(hd_data_t *hd_data)
289
unsigned *sctrl, *sctrl2;
291
int bios_id, list_sorted;
293
/* don't do anything if there is useful edd info */
294
if(hd_data->flags.edd_used) return;
296
for(i = 0, hd = hd_data->hd; hd; hd = hd->next) {
298
hd->base_class.id == bc_storage_device &&
299
hd->sub_class.id == sc_sdev_disk
307
sctrl = new_mem(i * sizeof *sctrl);
309
/* sctrl: list of storage controllers with disks */
311
for(sctrl_len = 0, hd = hd_data->hd; hd; hd = hd->next) {
313
hd->base_class.id == bc_storage_device &&
314
hd->sub_class.id == sc_sdev_disk
316
for(i = 0; i < sctrl_len; i++) {
317
if(sctrl[i] == hd->attached_to) break;
319
if(i == sctrl_len) sctrl[sctrl_len++] = hd->attached_to;
323
/* sort list, if possible */
325
list_sorted = bios_ctrl_order(hd_data, sctrl, sctrl_len);
327
hd_boot = hd_get_device_by_idx(hd_data, hd_boot_disk(hd_data, &i));
329
/* if we know the boot device, make this controller the first */
331
if(hd_boot && hd_boot->attached_to && i == 1) {
332
for(i = 0; i < sctrl_len; i++) {
333
if(sctrl[i] == hd_boot->attached_to) break;
336
sctrl2 = new_mem(sctrl_len * sizeof *sctrl2);
337
*sctrl2 = hd_boot->attached_to;
338
for(i = 0, j = 1; i < sctrl_len; i++) {
339
if(sctrl[i] != hd_boot->attached_to) sctrl2[j++] = sctrl[i];
349
if(hd_boot) ADD2LOG(" bios boot dev: %d\n", hd_boot->idx);
350
for(i = 0; i < sctrl_len; i++) {
351
ADD2LOG(" bios ctrl %d: %d\n", i, sctrl[i]);
354
/* remove existing entries */
356
for(hd = hd_data->hd; hd; hd = hd->next) {
358
hd->base_class.id == bc_storage_device &&
359
hd->sub_class.id == sc_sdev_disk
361
hd->rom_id = free_mem(hd->rom_id);
365
if(!list_sorted && !hd_boot && sctrl_len > 1) {
366
/* we have no info at all */
369
else if(!list_sorted && hd_boot && sctrl_len > 2) {
370
/* we know which controller has the boot device */
379
bios_id += set_bios_id(hd_data, hd_boot, bios_id);
382
/* assign all the others */
384
for(i = 0; i < sctrl_len; i++) {
385
for(hd = hd_data->hd; hd; hd = hd->next) {
387
hd->base_class.id == bc_storage_device &&
388
hd->sub_class.id == sc_sdev_disk &&
389
hd->attached_to == sctrl[i] &&
392
bios_id += set_bios_id(hd_data, hd, bios_id);
402
void int_bios(hd_data_t *hd_data)
405
int i, start, bios = 0x80;
407
char ide_name[] = "/dev/hda";
408
char scsi_name[] = "/dev/sda";
411
hd_boot = hd_get_device_by_idx(hd_data, hd_boot_disk(hd_data, &i));
414
free_mem(hd_boot->rom_id);
415
hd_boot->rom_id = new_str("0x80");
418
if(!hd_boot || i != 1) return;
420
if(strstr(hd_boot->unix_dev_name, "/dev/sd") == hd_boot->unix_dev_name) {
422
start = hd_boot->unix_dev_name[sizeof "/dev/sd" - 1] - 'a';
424
else if(strstr(hd_boot->unix_dev_name, "/dev/hd") == hd_boot->unix_dev_name) {
426
start = hd_boot->unix_dev_name[sizeof "/dev/hd" - 1] - 'a';
432
if(start < 0) return;
434
for(hd = hd_data->hd; hd; hd = hd->next) {
436
hd->base_class.id == bc_storage_device &&
437
hd->sub_class.id == sc_sdev_disk
439
hd->rom_id = free_mem(hd->rom_id);
443
s = ide_1st ? ide_name : scsi_name;
445
for(i = start; i < 26; i++) {
446
s[strlen(s) - 1] = 'a' + i;
447
bios += set_bios_id(hd_data, s, bios);
450
for(i = 0; i < start; i++) {
451
s[strlen(s) - 1] = 'a' + i;
452
bios += set_bios_id(hd_data, s, bios);
455
s = ide_1st ? scsi_name : ide_name;
457
for(i = 0; i < 26; i++) {
458
s[strlen(s) - 1] = 'a' + i;
459
bios += set_bios_id(hd_data, s, bios);
463
#endif /* defined(__i386__) || defined (__x86_64__) */
466
* Try to read block 0 for block devices.
468
void int_media_check(hd_data_t *hd_data)
473
for(hd = hd_data->hd; hd; hd = hd->next) {
474
if(!hd_report_this(hd_data, hd)) continue;
476
hd->base_class.id == bc_storage_device &&
478
/* hd->sub_class.id == sc_sdev_cdrom || */ /* cf. cdrom.c */
479
hd->sub_class.id == sc_sdev_disk ||
480
hd->sub_class.id == sc_sdev_floppy
485
hd->status.available != status_no
488
PROGRESS(4, ++j, hd->unix_dev_name);
489
hd->block0 = read_block0(hd_data, hd->unix_dev_name, &i);
490
hd->is.notready = hd->block0 ? 0 : 1;
497
* Check if str has str2 in it.
499
int contains_word(char *str, char *str2)
501
int i, len, len2, found = 0;
504
if(!str2 || !*str2 || !str || !*str) return 0;
511
for(i = 0; i < len; i++) {
512
if(str[i] >= 'a' && str[i] <= 'z') str[i] -= 'a' - 'A';
515
for(s = str; (s = strstr(s, str2)); s++) {
517
(s == str || s[-1] < 'A' || s[-1] > 'Z') &&
518
(s[len2] < 'A' || s[len2] > 'Z')
532
* Check for zip drive.
537
hd->base_class.id == bc_storage_device &&
539
hd->sub_class.id == sc_sdev_disk ||
540
hd->sub_class.id == sc_sdev_floppy
545
contains_word(hd->vendor.name, "IOMEGA") ||
546
contains_word(hd->sub_vendor.name, "IOMEGA") ||
547
contains_word(hd->device.name, "IOMEGA") ||
548
contains_word(hd->sub_device.name, "IOMEGA")
550
contains_word(hd->device.name, "ZIP") ||
551
contains_word(hd->sub_device.name, "ZIP")
563
* Turn some drives into floppies.
565
void int_floppy(hd_data_t *hd_data)
570
for(hd = hd_data->hd; hd; hd = hd->next) {
571
if(is_zip(hd)) hd->is.zip = 1;
573
hd->base_class.id == bc_storage_device &&
574
hd->sub_class.id == sc_sdev_disk
577
hd->sub_class.id = sc_sdev_floppy;
581
/* make everything a floppy that is 1440k */
582
for(res = hd->res; res; res = res->next) {
584
res->any.type == res_size &&
585
res->size.unit == size_unit_sectors &&
586
res->size.val1 == 2880 &&
587
res->size.val2 == 512
589
hd->sub_class.id = sc_sdev_floppy;
601
* Remove usb entries that are handled by usb-storage.
603
void int_fix_usb_scsi(hd_data_t *hd_data)
605
hd_t *hd_scsi, *hd_usb;
607
for(hd_usb = hd_data->hd; hd_usb; hd_usb= hd_usb->next) {
609
hd_usb->bus.id == bus_usb &&
611
search_str_list(hd_usb->drivers, "usb-storage")
613
for(hd_scsi = hd_data->hd; hd_scsi; hd_scsi = hd_scsi->next) {
615
hd_scsi->bus.id == bus_scsi &&
616
hd_scsi->sysfs_device_link &&
617
search_str_list(hd_scsi->drivers, "usb-storage")
619
if(!strncmp(hd_scsi->sysfs_device_link, hd_usb->sysfs_id, strlen(hd_usb->sysfs_id))) {
620
hd_set_hw_class(hd_scsi, hw_usb);
622
free_mem(hd_scsi->unique_id);
623
hd_scsi->unique_id = hd_usb->unique_id;
624
hd_usb->unique_id = NULL;
626
add_res_entry(&hd_scsi->res, hd_usb->res);
629
if(!hd_scsi->modalias) {
630
hd_scsi->modalias = hd_usb->modalias;
631
hd_usb->modalias = NULL;
634
if(!hd_scsi->vendor.id) hd_scsi->vendor.id = hd_usb->vendor.id;
635
if(!hd_scsi->device.id) hd_scsi->device.id = hd_usb->device.id;
637
if(!hd_scsi->serial) {
638
hd_scsi->serial = hd_usb->serial;
639
hd_usb->serial = NULL;
642
if(!hd_scsi->driver_info) {
643
hd_scsi->driver_info = hd_usb->driver_info;
644
hd_usb->driver_info = NULL;
647
new_id(hd_data, hd_scsi);
649
hd_usb->tag.remove = 1;
656
remove_tagged_hd_entries(hd_data);
661
* Improve mouse info.
663
void int_mouse(hd_data_t *hd_data)
666
bios_info_t *bt = NULL;
668
for(hd = hd_data->hd; hd; hd = hd->next) {
671
hd->detail->type == hd_detail_bios &&
672
(bt = hd->detail->bios.data) &&
679
for(hd = hd_data->hd; hd; hd = hd->next) {
681
hd->base_class.id == bc_mouse &&
682
hd->sub_class.id == sc_mou_ps2 &&
683
hd->bus.id == bt->mouse.bus &&
684
hd->vendor.id == MAKE_ID(TAG_SPECIAL, 0x0200) &&
685
hd->device.id == MAKE_ID(TAG_SPECIAL, 0x0002)
687
hd->vendor.name = free_mem(hd->vendor.name);
688
hd->device.name = free_mem(hd->device.name);
689
hd->vendor.id = hd->device.id = 0;
691
hd->vendor.id = bt->mouse.compat_vend;
692
hd->device.id = bt->mouse.compat_dev;
694
hd->vendor.name = new_str(bt->mouse.vendor);
695
hd->device.name = new_str(bt->mouse.type);
696
hd->compat_vendor.id = bt->mouse.compat_vend;
697
hd->compat_device.id = bt->mouse.compat_dev;
705
void new_id(hd_data_t *hd_data, hd_t *hd)
708
hd->unique_id = free_mem(hd->unique_id);
709
hd->unique_id1 = free_mem(hd->unique_id1);
710
hd->old_unique_id = free_mem(hd->old_unique_id);
711
hd_add_id(hd_data, hd);
717
* Assign device names to (win-)modems.
719
void int_modem(hd_data_t *hd_data)
723
hd_dev_num_t dev_num = { type: 'c', range: 1 };
726
for(hd = hd_data->hd; hd; hd = hd->next) {
728
hd->base_class.id == bc_modem
731
switch(hd->sub_class.id) {
733
s = new_str("/dev/ham");
738
s = new_str("/dev/536ep0");
743
s = new_str("/dev/ttyLT0");
749
str_printf(&s, 0, "/dev/ttySL%u", cnt4);
751
dev_num.minor = cnt4++;
756
free_mem(hd->unix_dev_name);
757
hd->unix_dev_name = s;
759
hd->unix_dev_num = dev_num;
767
* Look for WLAN cards by checking module info.
769
void int_wlan(hd_data_t *hd_data)
775
static char *wlan_mods[] = {
829
for(hd = hd_data->hd; hd; hd = hd->next) {
830
for(found = 0, di = hd->driver_info; di && !found; di = di->next) {
831
if(di->any.type == di_module) {
832
for(sl = di->module.names; sl && !found; sl = sl->next) {
833
for(u = 0; u < sizeof wlan_mods / sizeof *wlan_mods; u++) {
834
if(!strcmp(sl->str, wlan_mods[u])) {
844
hd->base_class.id = bc_network;
845
hd->sub_class.id = 0x82; /* wlan */
846
hddb_add_info(hd_data, hd);
855
void int_udev(hd_data_t *hd_data)
861
if(!hd_data->udevinfo) read_udevinfo(hd_data);
863
if(!hd_data->udevinfo) return;
865
for(hd = hd_data->hd; hd; hd = hd->next) {
866
if(!hd->unix_dev_names && hd->unix_dev_name) {
867
add_str_list(&hd->unix_dev_names, hd->unix_dev_name);
870
if(!hd->sysfs_id) continue;
872
for(ui = hd_data->udevinfo; ui; ui = ui->next) {
873
if(ui->name && !strcmp(ui->sysfs, hd->sysfs_id)) {
874
if(!search_str_list(hd->unix_dev_names, ui->name)) {
875
add_str_list(&hd->unix_dev_names, ui->name);
877
for(sl = ui->links; sl; sl = sl->next) {
878
if(!search_str_list(hd->unix_dev_names, sl->str)) {
879
add_str_list(&hd->unix_dev_names, sl->str);
883
if(!hd->unix_dev_name) {
884
sl = hd->unix_dev_names;
886
if(hd_data->flags.udev) {
887
/* use first link as canonical device name */
888
if(ui->links) sl = sl->next;
891
hd->unix_dev_name = new_str(sl->str);
899
for(hd = hd_data->hd; hd; hd = hd->next) {
900
if(!hd->unix_dev_names) continue;
902
for(ui = hd_data->udevinfo; ui; ui = ui->next) {
903
if(search_str_list(hd->unix_dev_names, ui->name)) {
904
for(sl = ui->links; sl; sl = sl->next) {
905
if(!search_str_list(hd->unix_dev_names, sl->str)) {
906
add_str_list(&hd->unix_dev_names, sl->str);
916
* If hd->unix_dev_name is not in hd->unix_dev_names, add it.
918
void int_devicenames(hd_data_t *hd_data)
922
for(hd = hd_data->hd; hd; hd = hd->next) {
925
!search_str_list(hd->unix_dev_names, hd->unix_dev_name)
927
add_str_list(&hd->unix_dev_names, hd->unix_dev_name);
933
#if defined(__i386__) || defined (__x86_64__)
935
* Tag ide soft raid disks.
937
void int_softraid(hd_data_t *hd_data)
940
str_list_t *raid, *sl, *raid_sysfs = NULL, *sl1;
944
if(hd_data->flags.fast) return;
946
for(hd = hd_data->hd; hd; hd = hd->next) {
948
hd->base_class.id == bc_storage_device &&
949
hd->status.available != status_no
953
/* no disks -> no check necessary */
956
raid = read_file("| /sbin/dmraid -rc 2>/dev/null", 0, 0);
958
for(sl = raid; sl; sl = sl->next) {
959
s = *sl->str ? strchr(sl->str + 1, '/') : NULL;
961
sl1 = add_str_list(&raid_sysfs, NULL);
962
str_printf(&sl1->str, 0, "/block%s", s);
963
len = strlen(sl1->str);
964
if(len) sl1->str[len - 1] = 0;
970
ADD2LOG("----- soft raid devices -----\n");
971
for(sl = raid_sysfs; sl; sl = sl->next) {
972
ADD2LOG(" %s\n", sl->str);
974
ADD2LOG("----- soft raid devices end -----\n");
976
for(hd = hd_data->hd; hd; hd = hd->next) {
977
if(search_str_list(raid_sysfs, hd->sysfs_id)) {
978
hd->is.softraiddisk = 1;
982
free_str_list(raid_sysfs);
990
void int_system(hd_data_t *hd_data)
996
enum { v_none = 0, v_ibm = 1, v_toshiba, v_sony } vendor;
1001
for(hd_sys = hd_data->hd; hd_sys; hd_sys = hd_sys->next) {
1003
hd_sys->base_class.id == bc_internal &&
1004
hd_sys->sub_class.id == sc_int_sys
1011
hd_sys->vendor.name &&
1012
!strncasecmp(hd_sys->vendor.name, "sony", sizeof "sony" - 1)
1018
hd_sys->device.name &&
1019
!strncmp(hd_sys->device.name, "PCG-", sizeof "PCG-" - 1)
1024
for(sm = hd_data->smbios; sm; sm = sm->next) {
1026
sm->any.type == sm_sysinfo &&
1027
sm->sysinfo.manuf &&
1028
!strcasecmp(sm->sysinfo.manuf, "ibm")
1034
sm->any.type == sm_sysinfo &&
1035
sm->sysinfo.manuf &&
1036
!strcasecmp(sm->sysinfo.manuf, "toshiba")
1038
is.vendor = v_toshiba;
1040
if(!hd_sys->device.name && !hd_sys->device.id && sm->sysinfo.product) {
1041
hd_sys->device.name = new_str(sm->sysinfo.product);
1043
if(!hd_sys->vendor.name && !hd_sys->vendor.id) {
1044
hd_sys->vendor.name = new_str("Toshiba");
1049
sm->any.type == sm_sysinfo &&
1050
sm->sysinfo.manuf &&
1051
!strncasecmp(sm->sysinfo.manuf, "sony", sizeof "sony" - 1)
1055
if(!hd_sys->device.name && !hd_sys->device.id && sm->sysinfo.product) {
1056
hd_sys->device.name = new_str(sm->sysinfo.product);
1058
(s = strchr(hd_sys->device.name, '(')) &&
1059
hd_sys->device.name[strlen(hd_sys->device.name) - 1] == ')'
1064
if(!hd_sys->vendor.name && !hd_sys->vendor.id) {
1065
hd_sys->vendor.name = new_str("Sony");
1070
sm->any.type == sm_chassis &&
1072
(sm->chassis.ch_type.id >= 8 && sm->chassis.ch_type.id <= 11) ||
1073
sm->chassis.ch_type.id == 14
1081
" system type:%s%s\n",
1082
is.vendor == v_ibm ? " ibm" :
1083
is.vendor == v_toshiba ? " toshiba" :
1084
is.vendor == v_sony ? " sony" :
1086
is.notebook ? " notebook" : ""
1089
if(is.notebook && is.vendor) {
1090
hd_sys->compat_vendor.id = MAKE_ID(TAG_SPECIAL, 0xf001);
1091
hd_sys->compat_device.id = MAKE_ID(TAG_SPECIAL, is.vendor);
1094
hd_sys->is.with_acpi = stat("/proc/acpi", &sbuf) ? 0 : 1;
1095
ADD2LOG(" acpi: %d\n", hd_sys->is.with_acpi);
1099
void int_legacy_geo(hd_data_t *hd_data)
1107
if(!hd_data->edd) return;
1109
for(hd = hd_data->hd; hd; hd = hd->next) {
1111
hd->base_class.id == bc_storage_device &&
1112
hd->sub_class.id == sc_sdev_disk &&
1115
id = strtol(hd->rom_id, &s, 0) - 0x80;
1116
if(*s || id < 0 || id >= sizeof hd_data->edd / sizeof *hd_data->edd) continue;
1118
ei = hd_data->edd + id;
1121
res = add_res_entry(&hd->res, new_mem(sizeof *res));
1122
res->disk_geo.type = res_disk_geo;
1123
res->disk_geo.cyls = ei->edd.cyls;
1124
res->disk_geo.heads = ei->edd.heads;
1125
res->disk_geo.sectors = ei->edd.sectors;
1126
res->disk_geo.size = ei->sectors;
1127
res->disk_geo.geotype = geo_bios_edd;
1130
if(ei->legacy.cyls) {
1131
res = add_res_entry(&hd->res, new_mem(sizeof *res));
1132
res->disk_geo.type = res_disk_geo;
1133
res->disk_geo.cyls = ei->legacy.cyls;
1134
res->disk_geo.heads = ei->legacy.heads;
1135
res->disk_geo.sectors = ei->legacy.sectors;
1136
res->disk_geo.geotype = geo_bios_legacy;
1145
void int_find_parent(hd_data_t *hd_data)
1149
for(hd = hd_data->hd; hd; hd = hd->next) {
1150
if(hd->attached_to || !hd->parent_udi) continue;
1152
for(hd2 = hd_data->hd; hd2; hd2 = hd2->next) {
1153
if(!hd2->udi) continue;
1154
if(!strcmp(hd->parent_udi, hd2->udi)) {
1155
hd->attached_to = hd2->idx;
1163
void int_add_driver_modules(hd_data_t *hd_data)
1169
hd_sysfs_driver_list(hd_data);
1171
for(hd = hd_data->hd; hd; hd = hd->next) {
1172
hd->driver_modules = free_str_list(hd->driver_modules);
1174
for(sl = hd->drivers; sl; sl = sl->next) {
1175
for(sf = hd_data->sysfsdrv; sf; sf = sf->next) {
1176
if(sf->module && !strcmp(sf->driver, sl->str)) {
1177
add_str_list(&hd->driver_modules, sf->module);