svn commit: r326231 - head/lib/libefivar
Warner Losh
imp at FreeBSD.org
Sun Nov 26 16:12:11 UTC 2017
Author: imp
Date: Sun Nov 26 16:12:10 2017
New Revision: 326231
URL: https://svnweb.freebsd.org/changeset/base/326231
Log:
Add efidp_format_device_path_node to format a single node in a device
path, much like efidp_format_device_path will format the entire path.
Sponsored by: Netflix
Modified:
head/lib/libefivar/efivar-dp-format.c
head/lib/libefivar/efivar-dp.h
Modified: head/lib/libefivar/efivar-dp-format.c
==============================================================================
--- head/lib/libefivar/efivar-dp-format.c Sun Nov 26 14:56:23 2017 (r326230)
+++ head/lib/libefivar/efivar-dp-format.c Sun Nov 26 16:12:10 2017 (r326231)
@@ -2272,7 +2272,6 @@ static const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePath
{0, 0, NULL}
};
-#ifndef __FreeBSD__
/**
Converts a device node to its string representation.
@@ -2288,7 +2287,7 @@ static const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePath
is NULL or there was insufficient memory.
**/
-CHAR16 *
+static char *
EFIAPI
UefiDevicePathLibConvertDeviceNodeToText (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
@@ -2299,6 +2298,7 @@ UefiDevicePathLibConvertDeviceNodeToText (
POOL_PRINT Str;
UINTN Index;
DEVICE_PATH_TO_TEXT ToText;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
if (DeviceNode == NULL) {
return NULL;
@@ -2310,6 +2310,7 @@ UefiDevicePathLibConvertDeviceNodeToText (
// Process the device path node
// If not found, use a generic function
//
+ Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DeviceNode);
ToText = DevPathToTextNodeGeneric;
for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&
@@ -2323,12 +2324,11 @@ UefiDevicePathLibConvertDeviceNodeToText (
//
// Print this node
//
- ToText (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);
+ ToText (&Str, (VOID *) Node, DisplayOnly, AllowShortcuts);
ASSERT (Str.Str != NULL);
return Str.Str;
}
-#endif
/**
Converts a device path to its text representation.
@@ -2431,8 +2431,26 @@ efidp_format_device_path(char *buf, size_t len, const_
return retval;
}
+ssize_t
+efidp_format_device_path_node(char *buf, size_t len, const_efidp dp, ssize_t max)
+{
+ char *str;
+ ssize_t retval;
+
+ str = UefiDevicePathLibConvertDeviceNodeToText (
+ __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
+ if (str == NULL)
+ return -1;
+ strlcpy(buf, str, len);
+ retval = strlen(str);
+ free(str);
+
+ return retval;
+}
+
size_t
efidp_size(const_efidp dp)
{
+
return GetDevicePathSize(__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp));
}
Modified: head/lib/libefivar/efivar-dp.h
==============================================================================
--- head/lib/libefivar/efivar-dp.h Sun Nov 26 14:56:23 2017 (r326230)
+++ head/lib/libefivar/efivar-dp.h Sun Nov 26 16:12:10 2017 (r326231)
@@ -60,6 +60,8 @@ typedef const efidp_data *const_efidp;
*/
ssize_t efidp_format_device_path(char *buf, size_t len, const_efidp dp,
ssize_t max);
+ssize_t efidp_format_device_path_node(char *buf, size_t len, const_efidp dp,
+ ssize_t max);
ssize_t efidp_parse_device_path(char *path, efidp out, size_t max);
size_t efidp_size(const_efidp);
More information about the svn-src-all
mailing list