1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Avoid selecting names under /dev/block if there is an alternative.

This commit is contained in:
Alasdair Kergon 2010-05-24 22:53:48 +00:00
parent 3014fad054
commit ed122a962d
2 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.67 - Version 2.02.67 -
=============================== ===============================
Avoid selecting names under /dev/block if there is an alternative.
Update clustered log kernel module name to log-userspace for 2.6.31 onwards. Update clustered log kernel module name to log-userspace for 2.6.31 onwards.
Activate only first head of Replicator for vgchange -ay. Activate only first head of Replicator for vgchange -ay.
Add Replicators' LVs to dtree for activation. Add Replicators' LVs to dtree for activation.

View File

@ -40,6 +40,7 @@ static struct {
struct dm_hash_table *names; struct dm_hash_table *names;
struct btree *devices; struct btree *devices;
struct dm_regex *preferred_names_matcher; struct dm_regex *preferred_names_matcher;
const char *dev_dir;
int has_scanned; int has_scanned;
struct dm_list dirs; struct dm_list dirs;
@ -155,6 +156,7 @@ static int _compare_paths(const char *path0, const char *path1)
char p0[PATH_MAX], p1[PATH_MAX]; char p0[PATH_MAX], p1[PATH_MAX];
char *s0, *s1; char *s0, *s1;
struct stat stat0, stat1; struct stat stat0, stat1;
size_t devdir_len;
/* /*
* FIXME Better to compare patterns one-at-a-time against all names. * FIXME Better to compare patterns one-at-a-time against all names.
@ -179,6 +181,19 @@ static int _compare_paths(const char *path0, const char *path1)
* Built-in rules. * Built-in rules.
*/ */
/*
* Anything beats /dev/block.
*/
devdir_len = strlen(_cache.dev_dir);
if (!strncmp(path0, _cache.dev_dir, devdir_len) &&
!strncmp(path1, _cache.dev_dir, devdir_len)) {
if (!strncmp(path0 + devdir_len, "block/", 6)) {
if (strncmp(path1 + devdir_len, "block/", 6))
return 1;
} else if (!strncmp(path1 + devdir_len, "block/", 6))
return 0;
}
/* Return the path with fewer slashes */ /* Return the path with fewer slashes */
for (p = path0; p++; p = (const char *) strchr(p, '/')) for (p = path0; p++; p = (const char *) strchr(p, '/'))
slash0++; slash0++;
@ -545,6 +560,11 @@ int dev_cache_init(struct cmd_context *cmd)
goto bad; goto bad;
} }
if (!(_cache.dev_dir = _strdup(cmd->dev_dir))) {
log_error("strdup dev_dir failed.");
goto bad;
}
dm_list_init(&_cache.dirs); dm_list_init(&_cache.dirs);
dm_list_init(&_cache.files); dm_list_init(&_cache.files);