From: Neil Brown Date: Mon, 11 Apr 2005 00:20:03 +0000 (+0000) Subject: Fix embarassing bug in 1.10.0 which broke --add X-Git-Tag: mdadm-1.11.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fbf459d0d3c8cb0b050468c27f8e6bcc0db5d7d;p=thirdparty%2Fmdadm.git Fix embarassing bug in 1.10.0 which broke --add Use a different variable to old result of open Signed-off-by: Neil Brown --- diff --git a/ChangeLog b/ChangeLog index 33e729be..1c8a10d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Changes Prior to this release + - Fix embarassing bug which causes --add to always fail. + Changes Prior to 1.10.0 release - Fix bug with --config=partitions - Open sub-devices with O_EXCL to detect if already in use diff --git a/Manage.c b/Manage.c index b323fd3c..c1debfa9 100644 --- a/Manage.c +++ b/Manage.c @@ -168,6 +168,7 @@ int Manage_subdevs(char *devname, int fd, mddev_dev_t dv; struct stat stb; int j; + int tfd; int save_errno; static char buf[4096]; @@ -195,13 +196,13 @@ int Manage_subdevs(char *devname, int fd, case 'a': /* add the device - hot or cold */ /* Make sure it isn' in use (in 2.6 or later) */ - fd = open(dv->devname, O_RDONLY|O_EXCL); - if (fd < 0) { + tfd = open(dv->devname, O_RDONLY|O_EXCL); + if (tfd < 0) { fprintf(stderr, Name ": Cannot open %s: %s\n", dv->devname, strerror(errno)); return 1; } - close(fd); + close(tfd); if (ioctl(fd, HOT_ADD_DISK, (unsigned long)stb.st_rdev)==0) { fprintf(stderr, Name ": hot added %s\n", dv->devname);