Manage: fix regression on removing detached devices.
If /dev is static, a name may remain there after the device has been detached from the system. Using 'mdadm' to remove such a device from the array should still work (even though "mdadm --remove detached" might be preferred). So when processing a device for '-r', don't insist on being able to open the device. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
c132678b18
commit
5a9de8db04
8
Manage.c
8
Manage.c
|
@ -425,6 +425,13 @@ int Manage_subdevs(char *devname, int fd,
|
|||
j = 0;
|
||||
|
||||
tfd = dev_open(dv->devname, O_RDONLY);
|
||||
if (tfd < 0 && dv->disposition == 'r' &&
|
||||
lstat(dv->devname, &stb) == 0)
|
||||
/* Be happy, the lstat worked, that is
|
||||
* enough for --remove
|
||||
*/
|
||||
;
|
||||
else {
|
||||
if (tfd < 0 || fstat(tfd, &stb) != 0) {
|
||||
fprintf(stderr, Name ": cannot find %s: %s\n",
|
||||
dv->devname, strerror(errno));
|
||||
|
@ -433,6 +440,7 @@ int Manage_subdevs(char *devname, int fd,
|
|||
return 1;
|
||||
}
|
||||
close(tfd);
|
||||
}
|
||||
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
|
||||
fprintf(stderr, Name ": %s is not a "
|
||||
"block device.\n",
|
||||
|
|
Loading…
Reference in New Issue