if (blkid_get_cache(&cache, NULL) >= 0)
dev = blkid_find_dev_with_tag(cache, label, (const char*)uuid_str);
+ else
+ rc = -EINVAL;
if (dev) {
temp_partition_ptr = blkid_dev_devname(dev);
strncpy(partition, temp_partition_ptr, PATH_MAX);
rc = get_block_device_base(partition, basename,
sizeof(basename));
- if (rc >= 0)
+ if (rc >= 0) {
strncpy(device, basename, sizeof(basename));
- else
- return -ENODEV;
-
- return 0;
+ rc = 0;
+ } else {
+ rc = -ENODEV;
+ }
+ } else {
+ rc = -EINVAL;
}
- return -EINVAL;
+ /* From what I can tell, blkid_put_cache cleans up dev, which
+ * appears to be a pointer into cache, as well */
+ if (cache)
+ blkid_put_cache(cache);
+ return rc;
}
#elif defined(__APPLE__)
#include <sys/disk.h>