From owner-svn-src-all@freebsd.org Sun Nov 26 16:12:11 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98E61DEA914; Sun, 26 Nov 2017 16:12:11 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 733716EE4F; Sun, 26 Nov 2017 16:12:11 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAQGCAbU018514; Sun, 26 Nov 2017 16:12:10 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAQGCASx018512; Sun, 26 Nov 2017 16:12:10 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201711261612.vAQGCASx018512@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sun, 26 Nov 2017 16:12:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326231 - head/lib/libefivar X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/lib/libefivar X-SVN-Commit-Revision: 326231 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Nov 2017 16:12:11 -0000 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);