diff options
author | Michael Tokarev <mjt@tls.msk.ru> | 2014-09-20 08:50:44 +0400 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2014-09-20 08:50:44 +0400 |
commit | 20d0ba040d767361c1d0c8a825b2a5e8bfdb39a6 (patch) | |
tree | 687a5eda9314ea76da64e234ba269d84345f7efe /policy.c | |
parent | fef4f4267e21104887eba03b8ddec5e6a3fc9747 (diff) | |
parent | fed12d436b9803ad97d1f11cc8f312ab08c3a659 (diff) |
Merge tag 'mdadm-3.3.2' into debian
Release mdadm-3.3.2
Minor bugfix/stability release.
Diffstat (limited to 'policy.c')
-rw-r--r-- | policy.c | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -200,26 +200,25 @@ static char *disk_path(struct mdinfo *disk) int rv; by_path = opendir(symlink); - if (!by_path) - return NULL; - prefix_len = strlen(symlink); - - while ((ent = readdir(by_path)) != NULL) { - if (ent->d_type != DT_LNK) - continue; - strncpy(symlink + prefix_len, - ent->d_name, - sizeof(symlink) - prefix_len); - if (stat(symlink, &stb) < 0) - continue; - if ((stb.st_mode & S_IFMT) != S_IFBLK) - continue; - if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor)) - continue; + if (by_path) { + prefix_len = strlen(symlink); + while ((ent = readdir(by_path)) != NULL) { + if (ent->d_type != DT_LNK) + continue; + strncpy(symlink + prefix_len, + ent->d_name, + sizeof(symlink) - prefix_len); + if (stat(symlink, &stb) < 0) + continue; + if ((stb.st_mode & S_IFMT) != S_IFBLK) + continue; + if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor)) + continue; + closedir(by_path); + return xstrdup(ent->d_name); + } closedir(by_path); - return xstrdup(ent->d_name); } - closedir(by_path); /* A NULL path isn't really acceptable - use the devname.. */ sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor); rv = readlink(symlink, nm, sizeof(nm)-1); @@ -800,12 +799,12 @@ char *find_rule(struct rule *rule, char *rule_type) #define UDEV_RULE_FORMAT \ "ACTION==\"add\", SUBSYSTEM==\"block\", " \ "ENV{DEVTYPE}==\"%s\", ENV{ID_PATH}==\"%s\", " \ -"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\"\n" +"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n" #define UDEV_RULE_FORMAT_NOTYPE \ "ACTION==\"add\", SUBSYSTEM==\"block\", " \ "ENV{ID_PATH}==\"%s\", " \ -"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\"\n" +"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n" /* Write rule in the rule file. Use format from UDEV_RULE_FORMAT */ int write_rule(struct rule *rule, int fd, int force_part) |