diff options
author | Karel Zak | 2009-02-18 22:46:01 +0100 |
---|---|---|
committer | Karel Zak | 2009-02-18 22:46:01 +0100 |
commit | bb5f28762083a48a886a0f6ee685f5a98380a5c2 (patch) | |
tree | 4afa7cf0d0e9f7a99bc77a01d90e947240354b51 | |
parent | tests: refresh ipcs expected outputs (diff) | |
download | kernel-qcow2-util-linux-bb5f28762083a48a886a0f6ee685f5a98380a5c2.tar.gz kernel-qcow2-util-linux-bb5f28762083a48a886a0f6ee685f5a98380a5c2.tar.xz kernel-qcow2-util-linux-bb5f28762083a48a886a0f6ee685f5a98380a5c2.zip |
blkid: blkid_evaluate_spec() shouldn't ignore $BLKID_FILE
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | libs/blkid/src/blkidP.h | 1 | ||||
-rw-r--r-- | libs/blkid/src/cache.c | 34 | ||||
-rw-r--r-- | libs/blkid/src/evaluate.c | 9 |
3 files changed, 30 insertions, 14 deletions
diff --git a/libs/blkid/src/blkidP.h b/libs/blkid/src/blkidP.h index 240a983f3..128c6df22 100644 --- a/libs/blkid/src/blkidP.h +++ b/libs/blkid/src/blkidP.h @@ -293,6 +293,7 @@ extern int blkid_flush_cache(blkid_cache cache); /* cache */ extern char *blkid_safe_getenv(const char *arg); +extern char *blkid_get_cache_filename(struct blkid_config *conf); /* * Functions to create and find a specific tag type: tag.c diff --git a/libs/blkid/src/cache.c b/libs/blkid/src/cache.c index 9897729e4..964992285 100644 --- a/libs/blkid/src/cache.c +++ b/libs/blkid/src/cache.c @@ -97,6 +97,27 @@ void blkid_debug_init(int mask) } #endif +/* returns allocated path to cache */ +char *blkid_get_cache_filename(struct blkid_config *conf) +{ + char *filename; + + filename = blkid_safe_getenv("BLKID_FILE"); + if (filename) + filename = blkid_strdup(filename); + else if (conf) + filename = blkid_strdup(conf->cachefile); + else { + struct blkid_config *c = blkid_read_config(NULL); + if (!c) + return -BLKID_ERR_PARAM; + filename = c->cachefile; /* already allocated */ + c->cachefile = NULL; + blkid_free_config(c); + } + return filename; +} + int blkid_get_cache(blkid_cache *ret_cache, const char *filename) { blkid_cache cache; @@ -114,21 +135,12 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename) if (filename && !*filename) filename = NULL; - if (!filename) - filename = blkid_safe_getenv("BLKID_FILE"); if (filename) cache->bic_filename = blkid_strdup(filename); - else { - struct blkid_config *conf = blkid_read_config(NULL); - if (!conf) - return -BLKID_ERR_PARAM; - cache->bic_filename = conf->cachefile; - conf->cachefile = NULL; - blkid_free_config(conf); - } + else + cache->bic_filename = blkid_get_cache_filename(NULL); blkid_read_cache(cache); - *ret_cache = cache; return 0; } diff --git a/libs/blkid/src/evaluate.c b/libs/blkid/src/evaluate.c index e0e7f81eb..a3aaf151d 100644 --- a/libs/blkid/src/evaluate.c +++ b/libs/blkid/src/evaluate.c @@ -158,7 +158,7 @@ failed: } static char *evaluate_by_scan(const char *token, const char *value, - blkid_cache *cache, const char *cachefile) + blkid_cache *cache, struct blkid_config *conf) { blkid_cache c = cache ? *cache : NULL; char *res; @@ -166,8 +166,11 @@ static char *evaluate_by_scan(const char *token, const char *value, DBG(DEBUG_EVALUATE, printf("evaluating by blkid scan %s=%s\n", token, value)); - if (!c) + if (!c) { + char *cachefile = blkid_get_cache_filename(conf); blkid_get_cache(&c, cachefile); + free(cachefile); + } if (!c) return NULL; @@ -226,7 +229,7 @@ char *blkid_evaluate_spec(const char *token, const char *value, blkid_cache *cac if (conf->eval[i] == BLKID_EVAL_UDEV) ret = evaluate_by_udev(token, value, conf->uevent); else if (conf->eval[i] == BLKID_EVAL_SCAN) - ret = evaluate_by_scan(token, value, cache, conf->cachefile); + ret = evaluate_by_scan(token, value, cache, conf); if (ret) break; } |