Beispiel #1
0
static ssize_t
unparse_media_path(char *buffer, size_t buffer_size, EFI_DEVICE_PATH *path)
{

	CDROM_DEVICE_PATH *cdrom = (CDROM_DEVICE_PATH *)path;
	MEDIA_PROTOCOL_DEVICE_PATH *media = (MEDIA_PROTOCOL_DEVICE_PATH *)path;
	FILE_PATH_DEVICE_PATH *file = (FILE_PATH_DEVICE_PATH *)path;
	char *text_guid;
	char file_name[80];
	memset(file_name, 0, sizeof(file_name));
	char a[16], b[16], c[16];
	int rc;

	switch (path->subtype) {
	case 1:
		return unparse_media_hard_drive_path(buffer, buffer_size, path);
	case 2:
		return snprintf(buffer, buffer_size,
				"CD-ROM(%x,%" PRIx64 ",%" PRIx64 ")",
				get(a, cdrom->boot_entry),
				get(b, cdrom->start), get(c, cdrom->size));
	case 3:
		return unparse_vendor_path(buffer, buffer_size, NULL,
				(VENDOR_DEVICE_PATH *)path);
	case 4:
		efichar_to_char(file_name, file->path_name, 80);
		return snprintf(buffer, buffer_size, "File(%s)", file_name);
	case 5:
		rc = efi_guid_to_str(&media->guid, &text_guid);
		if (rc < 0)
			return rc;
		rc = snprintf(buffer, buffer_size, "Media(%s)", text_guid);
		free(text_guid);
		return rc;
	case 6:
		rc = efi_guid_to_str(&media->guid, &text_guid);
		if (rc < 0)
			return rc;
		rc = snprintf(buffer, buffer_size, "FvFile(%s)", text_guid);
		free(text_guid);
		return rc > 0 ? rc + 1 : rc;
	case 7:
		rc = efi_guid_to_str(&media->guid, &text_guid);
		if (rc < 0)
			return rc;
		rc = snprintf(buffer, buffer_size, "FvVol(%s)", text_guid);
		free(text_guid);
		return rc > 0 ? rc + 1 : rc;
	}
	return 0;
}
Beispiel #2
0
static int
unparse_media_path(char *buffer, EFI_DEVICE_PATH *path)
{

	CDROM_DEVICE_PATH *cdrom = (CDROM_DEVICE_PATH *)path;
	MEDIA_PROTOCOL_DEVICE_PATH *media = (MEDIA_PROTOCOL_DEVICE_PATH *)path;
	FILE_PATH_DEVICE_PATH *file = (FILE_PATH_DEVICE_PATH *)path;
	char text_guid[40], *p = buffer;
	char file_name[80];
	memset(file_name, 0, sizeof(file_name));
	char a[16], b[16], c[16];

	switch (path->subtype) {
	case 1:
		return unparse_media_hard_drive_path(buffer, path);
		break;
	case 2:
		return sprintf(buffer, "CD-ROM(%x,%" PRIx64 ",%" PRIx64 ")",
			       get(a, cdrom->boot_entry), get(b, cdrom->start), get(c, cdrom->size));
		break;
	case 3:
		return unparse_vendor_path(buffer, (VENDOR_DEVICE_PATH *)path);
		break;
	case 4:
		efichar_to_char(file_name, file->path_name, 80);
		return sprintf(p, "File(%s)", file_name);
		break;
	case 5:
		efi_guid_unparse(&media->guid, text_guid);
		return sprintf(buffer, "Media(%s)", text_guid);
		break;
	default:
		break;
	}
	return 0;
}