Ticket #1390: resolve_device_symlinks.patch

File resolve_device_symlinks.patch, 1.0 KB (added by rogach, 3 months ago)
  • smartd.cpp

     
    53765376
    53775377    dev_config cfg = conf_entries[i];
    53785378
     5379    // resolve symbolic links
     5380    struct stat buf;
     5381    if (lstat(cfg.dev_name.c_str(), &buf) != 0) {
     5382      perror(NULL);
     5383      PrintOut(LOG_WARNING, "Device: %s, stat call failed on path %s\n", cfg.name.c_str(), cfg.dev_name.c_str());
     5384    } else {
     5385      if (S_ISLNK(buf.st_mode)) {
     5386        char link_target[PATH_MAX];
     5387        if (realpath(cfg.dev_name.c_str(), link_target) == NULL) {
     5388          perror(NULL);
     5389          PrintOut(LOG_WARNING, "Device: %s, realpath call failed on path %s\n", cfg.name.c_str(), cfg.dev_name.c_str());
     5390        } else {
     5391          PrintOut(LOG_INFO, "Device: %s, link resolved to %s\n", cfg.name.c_str(), link_target);
     5392          cfg.dev_name = link_target;
     5393        }
     5394      }
     5395    }
     5396
    53795397    if (cfg.ignore) {
    53805398      // Store for is_duplicate_device() check and ignore
    53815399      PrintOut(LOG_INFO, "Device: %s%s%s%s, ignored\n", cfg.name.c_str(),