summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2010-07-20 12:17:20 -0400
committerDoug Ledford <dledford@redhat.com>2010-07-22 10:16:31 -0400
commitcfad27a93765529d72c49b9a39f736b194d31866 (patch)
tree8130cbb5e7799456ecc2106acdd8273a87fe1a3f
parent753cf9051223992dc8f18b46d26650fe52e6f2f8 (diff)
downloadmdadm-cfad27a93765529d72c49b9a39f736b194d31866.tar.gz
mdadm-cfad27a93765529d72c49b9a39f736b194d31866.tar.xz
mdadm-cfad27a93765529d72c49b9a39f736b194d31866.zip
Two Minor bug fixes to incremental support
One: a single character typo (of instead of or in an error printout) Two: Audited usage of tfd file descriptor. Make sure that the tfd file is always closed after usage, and that the tfd variable is reset to -1 if we are going to continue in our loop (not necessary if we know we will return from our function without going through the dv loop again). Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--Manage.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Manage.c b/Manage.c
index 3680d68..f88d95e 100644
--- a/Manage.c
+++ b/Manage.c
@@ -349,7 +349,7 @@ int Manage_subdevs(char *devname, int fd,
mddev_dev_t dv, next = NULL;
struct stat stb;
int j, jnext = 0;
- int tfd;
+ int tfd = -1;
struct supertype *st, *tst;
int duuid[4];
int ouuid[4];
@@ -486,7 +486,7 @@ int Manage_subdevs(char *devname, int fd,
char dname[55];
if (dv->disposition != 'r' && dv->disposition != 'f') {
fprintf(stderr, Name ": %s only meaningful "
- "with -r of -f, not -%c\n",
+ "with -r or -f, not -%c\n",
dv->devname, dv->disposition);
return 1;
}
@@ -532,6 +532,7 @@ int Manage_subdevs(char *devname, int fd,
return 1;
}
close(tfd);
+ tfd = -1;
}
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
fprintf(stderr, Name ": %s is not a "
@@ -575,6 +576,7 @@ int Manage_subdevs(char *devname, int fd,
}
} else if (!get_dev_size(tfd, NULL, &ldsize)) {
close(tfd);
+ tfd = -1;
continue;
}
@@ -582,6 +584,7 @@ int Manage_subdevs(char *devname, int fd,
array.major_version == 0 &&
md_get_version(fd)%100 < 2) {
close(tfd);
+ tfd = -1;
if (ioctl(fd, HOT_ADD_DISK,
(unsigned long)stb.st_rdev)==0) {
if (verbose >= 0)
@@ -639,6 +642,7 @@ int Manage_subdevs(char *devname, int fd,
if (tst->ss->avail_size(tst, ldsize/512) <
array_size) {
close(tfd);
+ tfd = -1;
if (add_dev != dv->devname)
continue;
fprintf(stderr, Name ": %s not large enough to join array\n",
@@ -689,7 +693,6 @@ int Manage_subdevs(char *devname, int fd,
continue;
}
if (errno == ENOMEM || errno == EROFS) {
- close(tfd);
fprintf(stderr, Name ": add new device failed for %s: %s\n",
add_dev, strerror(errno));
if (add_dev != dv->devname)
@@ -704,8 +707,10 @@ int Manage_subdevs(char *devname, int fd,
fprintf(stderr, Name
": --re-add for %s to %s is not possible\n",
add_dev, devname);
- if (tfd >= 0)
+ if (tfd >= 0) {
close(tfd);
+ tfd = -1;
+ }
continue;
}
if (dv->re_add) {
@@ -723,6 +728,8 @@ int Manage_subdevs(char *devname, int fd,
if (ldsize/512 < array_size) {
fprintf(stderr, Name ": %s not large enough to join array\n",
dv->devname);
+ if (tfd >= 0)
+ close(tfd);
return 1;
}
}
@@ -730,6 +737,7 @@ int Manage_subdevs(char *devname, int fd,
if (tfd >= 0) {
remove_partitions(tfd);
close(tfd);
+ tfd = -1;
}
/* in 2.6.17 and earlier, version-1 superblocks won't
* use the number we write, but will choose a free number.