diff --git a/src/lib/files.c b/src/lib/files.c index 18cdf6b..ea57d3c 100644 --- a/src/lib/files.c +++ b/src/lib/files.c @@ -79,60 +79,6 @@ bool cbm_files_match(const char *p1, const char *p2) return false; } -char *get_part_uuid(const char *path) -{ - struct stat st = { 0 }; - autofree(char) *node = NULL; - blkid_probe probe = NULL; - const char *value = NULL; - char *ret = NULL; - - if (stat(path, &st) != 0) { - LOG_ERROR("Path does not exist: %s", path); - return NULL; - } - - if (major(st.st_dev) == 0) { - LOG_ERROR("Invalid block device: %s", path); - return NULL; - } - - if (asprintf(&node, "/dev/block/%u:%u", major(st.st_dev), minor(st.st_dev)) < 0) { - DECLARE_OOM(); - return NULL; - } - - probe = blkid_new_probe_from_filename(node); - if (!probe) { - LOG_ERROR("Unable to probe %u:%u", major(st.st_dev), minor(st.st_dev)); - return NULL; - } - - blkid_probe_enable_superblocks(probe, 1); - blkid_probe_set_superblocks_flags(probe, BLKID_SUBLKS_TYPE); - blkid_probe_enable_partitions(probe, 1); - blkid_probe_set_partitions_flags(probe, BLKID_PARTS_ENTRY_DETAILS); - - if (blkid_do_safeprobe(probe) != 0) { - LOG_ERROR("Error probing filesystem: %s", strerror(errno)); - goto clean; - } - - if (blkid_probe_lookup_value(probe, "PART_ENTRY_UUID", &value, NULL) != 0) { - LOG_ERROR("Unable to find UUID for %s: %s", node, strerror(errno)); - value = NULL; - goto clean; - } - - LOG_DEBUG("UUID for %s is %s", node, value); - - ret = strdup(value); -clean: - blkid_free_probe(probe); - errno = 0; - return ret; -} - char *get_boot_device() { glob_t glo = { 0 }; diff --git a/src/lib/files.h b/src/lib/files.h index 50c9bab..5066bfa 100644 --- a/src/lib/files.h +++ b/src/lib/files.h @@ -38,14 +38,6 @@ typedef struct CbmMappedFile { size_t length; /**< Length of the mmap()'d file (see fstat) */ } CbmMappedFile; -/** - * Get the PartUUID for a given path - * - * @param path Path to get the PartUUID for - * @return a newly allocated string, or NULL on error - */ -char *get_part_uuid(const char *path); - /** * Return the UEFI device that is used for booting (/boot) * diff --git a/tests/check-files.c b/tests/check-files.c index 62cf567..a06639f 100644 --- a/tests/check-files.c +++ b/tests/check-files.c @@ -56,22 +56,6 @@ START_TEST(bootman_match_test) } END_TEST -START_TEST(bootman_uuid_test) -{ - if (geteuid() != 0) { - LOG_INFO("Skipping UUID test as root privileges are required"); - return; - } - const char *path = TOP_DIR "/tests/data/hashfile"; - autofree(char) *puuid = NULL; - - puuid = get_part_uuid(path); - fail_if(!puuid, "Failed to get filesystem UUID"); - - LOG_INFO("PUUID: %s", puuid); -} -END_TEST - START_TEST(bootman_find_boot) { if (!nc_file_exists("/sys/firmware/efi")) { @@ -105,7 +89,6 @@ static Suite *core_suite(void) s = suite_create("bootman_files"); tc = tcase_create("bootman_files"); tcase_add_test(tc, bootman_match_test); - tcase_add_test(tc, bootman_uuid_test); tcase_add_test(tc, bootman_mount_test); tcase_add_test(tc, bootman_find_boot); suite_add_tcase(s, tc);