Codebase list hwinfo / 26749a9
New upstream version 21.58 Tomasz Buchert 5 years ago
1 changed file(s) with 28 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
56395639 str_list_t *sl, *udevinfo;
56405640 hd_udevinfo_t **uip, *ui;
56415641 char *s = NULL, buf[256];
5642 struct stat sbuf;
56425643
56435644 udevinfo = read_file("| " PROG_UDEVADM " info -e 2>/dev/null", 0, 0);
56445645 if(!udevinfo) udevinfo = read_file("| " PROG_UDEVINFO " -e 2>/dev/null", 0, 0);
56795680 }
56805681
56815682 s = free_mem(s);
5683
5684 /*
5685 * It sometimes happens that udev generates the same link for different
5686 * kernel devices. To catch this we check here that udev device symlinks
5687 * actually point to the kernel device name.
5688 *
5689 * If it does not match the link is replaced by the kernel device name.
5690 */
5691 for(ui = hd_data->udevinfo; ui; ui = ui->next) {
5692 if(!ui->name || stat(ui->name, &sbuf)) continue;
5693
5694 for(sl = ui->links; sl; sl = sl->next) {
5695 char *real_path = realpath(sl->str, NULL);
5696
5697 if(real_path) {
5698 if(strcmp(real_path, ui->name)) {
5699 ADD2LOG(
5700 "udev link %s points to %s (expected %s) - removed\n",
5701 sl->str, real_path, ui->name
5702 );
5703 str_printf(&sl->str, 0, "%s", ui->name);
5704 }
5705
5706 free(real_path);
5707 }
5708 }
5709 }
56825710
56835711 for(ui = hd_data->udevinfo; ui; ui = ui->next) {
56845712 ADD2LOG("%s\n", ui->sysfs);