The blkid_get_cache() parses /etc/blkid.tab, it's better do it only when we really need to resolve a spec (label or uuid). Signed-off-by: Karel Zak <kzak@xxxxxxxxxx> --- mount/fsprobe_blkid.c | 38 ++++++++++++++++++++++++++++++-------- 1 files changed, 30 insertions(+), 8 deletions(-) diff --git a/mount/fsprobe_blkid.c b/mount/fsprobe_blkid.c index 2dc734e..16a093a 100644 --- a/mount/fsprobe_blkid.c +++ b/mount/fsprobe_blkid.c @@ -5,32 +5,50 @@ static blkid_cache blkid; void -fsprobe_init(void) { - blkid_get_cache(&blkid, NULL); +fsprobe_init(void) +{ + blkid = NULL; } void -fsprobe_exit(void) { +fsprobe_exit(void) +{ blkid_put_cache(blkid); } const char * -fsprobe_get_label_by_devname(const char *devname) { +fsprobe_get_label_by_devname(const char *devname) +{ + if (!blkid) + blkid_get_cache(&blkid, NULL); + return blkid_get_tag_value(blkid, "LABEL", devname); } const char * -fsprobe_get_uuid_by_devname(const char *devname) { +fsprobe_get_uuid_by_devname(const char *devname) +{ + if (!blkid) + blkid_get_cache(&blkid, NULL); + return blkid_get_tag_value(blkid, "UUID", devname); } const char * -fsprobe_get_devname_by_uuid(const char *uuid) { +fsprobe_get_devname_by_uuid(const char *uuid) +{ + if (!blkid) + blkid_get_cache(&blkid, NULL); + return blkid_get_devname(blkid, "UUID", uuid); } const char * -fsprobe_get_devname_by_label(const char *label) { +fsprobe_get_devname_by_label(const char *label) +{ + if (!blkid) + blkid_get_cache(&blkid, NULL); + return blkid_get_devname(blkid, "LABEL", label); } @@ -41,7 +59,11 @@ fsprobe_known_fstype(const char *fstype) } const char * -fsprobe_get_fstype_by_devname(const char *devname) { +fsprobe_get_fstype_by_devname(const char *devname) +{ + if (!blkid) + blkid_get_cache(&blkid, NULL); + return blkid_get_tag_value(blkid, "TYPE", devname); } -- 1.5.0.6 - To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html