summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2010-04-13 14:44:24 -0400
committerDoug Ledford <dledford@redhat.com>2010-04-13 14:44:24 -0400
commitd1f7ba12a4e1ec9ed3a005a84489073d80be8cc9 (patch)
treef5b883c1ef2d9c3e810d9384b83b44b68560a732
parent506c331a6030531fe647c7a654bd87ae32373543 (diff)
downloadmdadm-d1f7ba12a4e1ec9ed3a005a84489073d80be8cc9.tar.gz
mdadm-d1f7ba12a4e1ec9ed3a005a84489073d80be8cc9.tar.xz
mdadm-d1f7ba12a4e1ec9ed3a005a84489073d80be8cc9.zip
The assumption is that if tfd >= 0, then we have a valid major/minor pair
in stb.st_rdev to use in ioctl calls. Therefore, even if we use the sysfs block/dev entry to get our major/minor pair, we should really be using tfd and not sysfd as it changes assumptions made later on. Note: I actually don't like this. I would prefer that in the case of a kernel internal name that we skipped tfd altogether and went strait to sysfs operation exclusively. But that's just my preference. I'm concerned that sometime in the future we'll make the mistake of assuming that tfd >= 0 means dv->devname is a fully qualified path name and not a kernel internal name. We don't now, but I could easily see it happening. Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--Manage.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Manage.c b/Manage.c
index 043e3f6..9e450b9 100644
--- a/Manage.c
+++ b/Manage.c
@@ -386,7 +386,7 @@ int Manage_subdevs(char *devname, int fd,
next = dv->next;
jnext = 0;
- tfd = -1;
+ tfd = sysfd = -1;
if (strcmp(dv->devname, "failed")==0 ||
strcmp(dv->devname, "faulty")==0) {
@@ -461,17 +461,16 @@ int Manage_subdevs(char *devname, int fd,
}
sprintf(dname, "dev-%s", dv->devname);
- sysfd = sysfs_open(fd2devnum(fd), dname, "block/dev");
- if (sysfd >= 0) {
+ tfd = sysfs_open(fd2devnum(fd), dname, "block/dev");
+ if (tfd >= 0) {
char dn[20];
int mj,mn;
- if (sysfs_fd_get_str(sysfd, dn, 20) > 0 &&
+ if (sysfs_fd_get_str(tfd, dn, 20) > 0 &&
sscanf(dn, "%d:%d", &mj,&mn) == 2) {
stb.st_rdev = makedev(mj,mn);
found = 1;
}
- close(sysfd);
- sysfd = -1;
+ close(tfd);
}
if (!found) {
sysfd = sysfs_open(fd2devnum(fd), dname, "state");
@@ -481,6 +480,7 @@ int Manage_subdevs(char *devname, int fd,
dv->devname, devname);
return 1;
}
+ tfd = -1;
}
} else {
j = 0;