NeilBrown: Manage: fix regression on removing detached devices.
Martin F. Krafft
madduck at alioth.debian.org
Mon May 24 09:21:11 UTC 2010
Module: mdadm
Branch: upstream
Commit: 5a9de8db047646e1e59d90afc478d1820736324d
URL: http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=5a9de8db047646e1e59d90afc478d1820736324d
Author: NeilBrown <neilb at suse.de>
Date: Wed Mar 3 13:16:24 2010 +1100
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 at suse.de>
---
Manage.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/Manage.c b/Manage.c
index 749fa7c..6d94836 100644
--- a/Manage.c
+++ b/Manage.c
@@ -425,14 +425,22 @@ int Manage_subdevs(char *devname, int fd,
j = 0;
tfd = dev_open(dv->devname, O_RDONLY);
- if (tfd < 0 || fstat(tfd, &stb) != 0) {
- fprintf(stderr, Name ": cannot find %s: %s\n",
- dv->devname, strerror(errno));
- if (tfd >= 0)
- close(tfd);
- return 1;
+ 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));
+ if (tfd >= 0)
+ close(tfd);
+ return 1;
+ }
+ close(tfd);
}
- close(tfd);
if ((stb.st_mode & S_IFMT) != S_IFBLK) {
fprintf(stderr, Name ": %s is not a "
"block device.\n",
More information about the pkg-mdadm-commits
mailing list