efi_generate_file_device_path(uint8_t *buf, ssize_t size, const char const *filepath, uint32_t options, ...) { int rc; ssize_t ret = -1; char *devpath = NULL; char *relpath = NULL; va_list ap; int saved_errno; rc = find_file(filepath, &devpath, &relpath); if (rc < 0) return -1; rc = get_partition_number(devpath); if (rc < 0) goto err; va_start(ap, options); ret = efi_va_generate_file_device_path_from_esp(buf, size, devpath, 0, relpath, options, ap); saved_errno = errno; va_end(ap); errno = saved_errno; err: saved_errno = errno; if (devpath) free(devpath); if (relpath) free(relpath); errno = saved_errno; return ret; }
efi_generate_file_device_path(uint8_t *buf, ssize_t size, const char * const filepath, uint32_t options, ...) { int rc; ssize_t ret = -1; char *child_devpath = NULL; char *parent_devpath = NULL; char *relpath = NULL; va_list ap; int saved_errno; rc = find_file(filepath, &child_devpath, &relpath); if (rc < 0) { efi_error("could not canonicalize fs path"); return -1; } rc = find_parent_devpath(child_devpath, &parent_devpath); if (rc < 0) { efi_error("could not find parent device for file"); return -1; } rc = get_partition_number(child_devpath); if (rc < 0) { efi_error("could not get partition number for device"); goto err; } va_start(ap, options); ret = efi_va_generate_file_device_path_from_esp(buf, size, parent_devpath, rc, relpath, options, ap); saved_errno = errno; va_end(ap); errno = saved_errno; if (ret < 0) efi_error("could not generate File DP from ESP"); err: saved_errno = errno; if (child_devpath) free(child_devpath); if (parent_devpath) free(parent_devpath); if (relpath) free(relpath); errno = saved_errno; return ret; }