New upstream version 21.58
Tomasz Buchert
5 years ago
5639 | 5639 | str_list_t *sl, *udevinfo; |
5640 | 5640 | hd_udevinfo_t **uip, *ui; |
5641 | 5641 | char *s = NULL, buf[256]; |
5642 | struct stat sbuf; | |
5642 | 5643 | |
5643 | 5644 | udevinfo = read_file("| " PROG_UDEVADM " info -e 2>/dev/null", 0, 0); |
5644 | 5645 | if(!udevinfo) udevinfo = read_file("| " PROG_UDEVINFO " -e 2>/dev/null", 0, 0); |
5679 | 5680 | } |
5680 | 5681 | |
5681 | 5682 | 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 | } | |
5682 | 5710 | |
5683 | 5711 | for(ui = hd_data->udevinfo; ui; ui = ui->next) { |
5684 | 5712 | ADD2LOG("%s\n", ui->sysfs); |