diff options
author | NeilBrown <neilb@suse.de> | 2012-10-11 17:15:55 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-10-11 17:15:55 +1100 |
commit | a994592d75e64b50201121f6357ea73a0b7d4e6e (patch) | |
tree | 1f3ba6bdaca9d256f1dd118d9ace264940ff4662 /util.c | |
parent | 869523878e83586f4e55b00f705378d6e7b11e68 (diff) |
Fix open_container
open_container should open a container which contains the device,
but sometimes it would open another volume which contains the
device. Be more careful in 'holder' selection.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1352,6 +1352,20 @@ int open_container(int fd) continue; if (de->d_name[0] == '.') continue; + /* Need to make sure it is a container and not a volume */ + sprintf(e, "/%s/md/metadata_version", de->d_name); + dfd = open(path, O_RDONLY); + if (dfd < 0) + continue; + n = read(dfd, buf, sizeof(buf)); + close(dfd); + if (n <= 0 || (unsigned)n >= sizeof(buf)) + continue; + buf[n] = 0; + if (strncmp(buf, "external", 8) != 0 || + n < 10 || + buf[9] == '/') + continue; sprintf(e, "/%s/dev", de->d_name); dfd = open(path, O_RDONLY); if (dfd < 0) |