From owner-svn-src-head@freebsd.org Thu May 26 22:13:41 2016 Return-Path: Delivered-To: svn-src-head@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 B4879B4CD36; Thu, 26 May 2016 22:13:41 +0000 (UTC) (envelope-from jhb@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 6BFD4122A; Thu, 26 May 2016 22:13:41 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4QMDe9t047111; Thu, 26 May 2016 22:13:40 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QMDec0047110; Thu, 26 May 2016 22:13:40 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201605262213.u4QMDec0047110@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 26 May 2016 22:13:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300785 - head/sys/boot/efi/libefi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 22:13:41 -0000 Author: jhb Date: Thu May 26 22:13:40 2016 New Revision: 300785 URL: https://svnweb.freebsd.org/changeset/base/300785 Log: Use routines from the recently added devpath.c. These efipart layer did several devpath related operations inline. This just switches it over to using shared code for working with device paths. Sponsored by: Cisco Systems Modified: head/sys/boot/efi/libefi/efipart.c Modified: head/sys/boot/efi/libefi/efipart.c ============================================================================== --- head/sys/boot/efi/libefi/efipart.c Thu May 26 22:07:09 2016 (r300784) +++ head/sys/boot/efi/libefi/efipart.c Thu May 26 22:13:40 2016 (r300785) @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL; -static EFI_GUID devpath_guid = DEVICE_PATH_PROTOCOL; static int efipart_init(void); static int efipart_strategy(void *, int, daddr_t, size_t, size_t, char *, @@ -85,7 +84,6 @@ efipart_init(void) UINTN sz; u_int n, nin, nout; int err; - size_t devpathlen; sz = 0; hin = NULL; @@ -112,20 +110,11 @@ efipart_init(void) return (ENOMEM); for (n = 0; n < nin; n++) { - status = BS->HandleProtocol(hin[n], &devpath_guid, - (void **)&devpath); - if (EFI_ERROR(status)) { + devpath = efi_lookup_devpath(hin[n]); + if (devpath == NULL) { continue; } - node = devpath; - devpathlen = DevicePathNodeLength(node); - while (!IsDevicePathEnd(NextDevicePathNode(node))) { - node = NextDevicePathNode(node); - devpathlen += DevicePathNodeLength(node); - } - devpathlen += DevicePathNodeLength(NextDevicePathNode(node)); - status = BS->HandleProtocol(hin[n], &blkio_guid, (void**)&blkio); if (EFI_ERROR(status)) @@ -140,14 +129,10 @@ efipart_init(void) * we try to find the parent device and add that instead as * that will be the CD filesystem. */ + node = efi_devpath_last_node(devpath); if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_CDROM_DP) { - devpathcpy = malloc(devpathlen); - memcpy(devpathcpy, devpath, devpathlen); - node = devpathcpy; - while (!IsDevicePathEnd(NextDevicePathNode(node))) - node = NextDevicePathNode(node); - SetDevicePathEndNode(node); + devpathcpy = efi_devpath_trim(devpath); tmpdevpath = devpathcpy; status = BS->LocateDevicePath(&blkio_guid, &tmpdevpath, &handle);