Fix embarassing bug in 1.10.0 which broke --add
Use a different variable to old result of open Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
This commit is contained in:
parent
75aa592c2b
commit
0fbf459d0d
|
@ -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
|
Changes Prior to 1.10.0 release
|
||||||
- Fix bug with --config=partitions
|
- Fix bug with --config=partitions
|
||||||
- Open sub-devices with O_EXCL to detect if already in use
|
- Open sub-devices with O_EXCL to detect if already in use
|
||||||
|
|
7
Manage.c
7
Manage.c
|
@ -168,6 +168,7 @@ int Manage_subdevs(char *devname, int fd,
|
||||||
mddev_dev_t dv;
|
mddev_dev_t dv;
|
||||||
struct stat stb;
|
struct stat stb;
|
||||||
int j;
|
int j;
|
||||||
|
int tfd;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
static char buf[4096];
|
static char buf[4096];
|
||||||
|
|
||||||
|
@ -195,13 +196,13 @@ int Manage_subdevs(char *devname, int fd,
|
||||||
case 'a':
|
case 'a':
|
||||||
/* add the device - hot or cold */
|
/* add the device - hot or cold */
|
||||||
/* Make sure it isn' in use (in 2.6 or later) */
|
/* Make sure it isn' in use (in 2.6 or later) */
|
||||||
fd = open(dv->devname, O_RDONLY|O_EXCL);
|
tfd = open(dv->devname, O_RDONLY|O_EXCL);
|
||||||
if (fd < 0) {
|
if (tfd < 0) {
|
||||||
fprintf(stderr, Name ": Cannot open %s: %s\n",
|
fprintf(stderr, Name ": Cannot open %s: %s\n",
|
||||||
dv->devname, strerror(errno));
|
dv->devname, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(tfd);
|
||||||
if (ioctl(fd, HOT_ADD_DISK, (unsigned long)stb.st_rdev)==0) {
|
if (ioctl(fd, HOT_ADD_DISK, (unsigned long)stb.st_rdev)==0) {
|
||||||
fprintf(stderr, Name ": hot added %s\n",
|
fprintf(stderr, Name ": hot added %s\n",
|
||||||
dv->devname);
|
dv->devname);
|
||||||
|
|
Loading…
Reference in New Issue