From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web12.5680.1601327793029351823 for ; Mon, 28 Sep 2020 14:16:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=engcetdT; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: erik.c.bjorge@intel.com) IronPort-SDR: yIHr6WMUlQCCfs9YF6wPXKldyIgBetD+P3xZ771vtJjpAKmLkNAdRrqHufv4dVcEtOVbjyk+C8 0dVU8O95rntA== X-IronPort-AV: E=McAfee;i="6000,8403,9758"; a="180221089" X-IronPort-AV: E=Sophos;i="5.77,315,1596524400"; d="scan'208";a="180221089" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 14:16:32 -0700 IronPort-SDR: U1doTYhiynXqQYGPRdgChTmQF+j6z/ERvErKHMPKHbeKwTQA0wWiyJzK7qzmoQXWr4XFJoK3v7 6iORK/5W6/ow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,315,1596524400"; d="scan'208";a="338336733" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by fmsmga004.fm.intel.com with ESMTP; 28 Sep 2020 14:16:32 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 28 Sep 2020 14:16:31 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 28 Sep 2020 14:16:31 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 28 Sep 2020 14:16:31 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.177) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 28 Sep 2020 14:16:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VoMNFka0e/TFMfoLHrwwxiK0vljjkaQJdLeyqHLX00JC60yH8zxylilrIorxHxxDCokfWzSZtLwmERz3CMj7VP3JxECDAcVPuUQvQifAgPdkx0eTQHQfwKBFxwCLaHpJeFNwV5I8/NSDmZv3QBQ91312OulX85aQ4B2vPOXAxGsCC43BanFmNi5fb6ZF9cbTZ6sNsn8yh7XtF6DZshGRue66xoYiUOx+0YW+bFLTd4wtrtFBQDbWtHeJaIAAlnyLQGpd7KSVN6MsQaqN0Q0daThp8/9KE11DouGr3q4H0ti6PDbG6jOF5ZTTzg6qwSMwNhnfdWtlGE1HMimkrKEdLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2qjubjaBXjN9AK/vVdJoZ92TW5/b1siDoDXXMlkHHHQ=; b=gUE+TU4eMQHYF9GtDIqgdWxa4N47gZi7vlZZUvWfkyJiMoWFXAVJWon27oyzuXEUgv3+Mku+3fBMsh5G8WwjIeIz7gyhQgDdvECeZ7x+sBh1GhFLvZOCnGMxYv8XBuVQ5JQejRlmoKADyhe/4eskMHO0bAVcsAykcUpEIcEv6nwACzB0cf7umqJLtW+zsMLcakduOXGvWSFTCYiyh/R6qbwYJpuygfUfVJHS8UC0lL2HQcE3i9y5Y87g/6yihfBTPh4ZaxIP5km31qb3TQyA4dix8SJtj5EGjtPLI6lRQB21cKmEOZw+ouLz+o00vbb6gyoA3dXVftjrtvbgfpjH5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2qjubjaBXjN9AK/vVdJoZ92TW5/b1siDoDXXMlkHHHQ=; b=engcetdT+aisDOB4shdEfa0cmAFLDKvj9xrT/eDY8itPv5hn02GYeLKCbw6NDFsW1OZpPrdBL0fFMx4fwfsRSLoYUu6EwnuGbbrz/uWbYLQ3LBud9up7oVLbWfcN+qRSf6abjcV065KtADNa/7m3YD7mD2PDfRnKm8or6WiJbE4= Received: from MW3PR11MB4554.namprd11.prod.outlook.com (2603:10b6:303:5d::7) by MWHPR11MB1951.namprd11.prod.outlook.com (2603:10b6:300:10c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Mon, 28 Sep 2020 21:16:28 +0000 Received: from MW3PR11MB4554.namprd11.prod.outlook.com ([fe80::7194:aad7:7eae:83df]) by MW3PR11MB4554.namprd11.prod.outlook.com ([fe80::7194:aad7:7eae:83df%8]) with mapi id 15.20.3412.029; Mon, 28 Sep 2020 21:16:28 +0000 From: "Bjorge, Erik C" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" CC: "Desimone, Ashley E" , "Pandya, Puja" , Bret Barkelew , "Agyeman, Prince" Subject: Re: [edk2-staging/EdkRepo] [PATCH V3 1/2] EdkRepo: Add function to enumerate subst drives Thread-Topic: [edk2-staging/EdkRepo] [PATCH V3 1/2] EdkRepo: Add function to enumerate subst drives Thread-Index: AQHWk6RnbN2NHkMLskCTB42NgtVCvKl+kenA Date: Mon, 28 Sep 2020 21:16:28 +0000 Message-ID: References: <20200926012826.4976-1-nathaniel.l.desimone@intel.com> <20200926012826.4976-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20200926012826.4976-2-nathaniel.l.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [50.53.38.57] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6c457d9a-835b-40d5-40b4-08d863f3c3e1 x-ms-traffictypediagnostic: MWHPR11MB1951: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3826; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: D4j5r4uPH6cRYTgMNY4egnEywuQZ9vYIaWVJ/nSZ1cTY4VKvA1hqieyTVVwBlWKI3ZyoJDJhXTsLjkG1kMLPwMGOSGO6RWfpHf/fgTcOKTQc5f/46qsdhRmbm/xDx6sAlDq+rTgVsJo3GXYtJ2NUZNoHIw+wQthGXtdiUFVOHEnqmG8NZMlNxOvgPakVrkkHIJna/QMj8jA0STZJ4qR083f+TBBDN8NMgm/cxfMaOjFM/3Zgodo4EPFIh+TsUPZOdo/giDKQf4ZoJmZB8CJpaKxwE+xVUb8dZiOOCKa6zO7sVJlnoNloPvoMiGZm8vBGuTdnY5T3Nh49IKRtiSPz+Psf4AmoMVeYrza2jsP2YZnxbxzIfVGzuo8zq7imGkDX x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4554.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(346002)(366004)(39860400002)(396003)(136003)(7696005)(186003)(54906003)(110136005)(52536014)(86362001)(71200400001)(8676002)(2906002)(316002)(4326008)(5660300002)(64756008)(26005)(8936002)(33656002)(478600001)(66446008)(55016002)(66946007)(6506007)(76116006)(19627235002)(9686003)(66556008)(53546011)(83380400001)(107886003)(66476007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: FYJe4n/MejOKZ+nJ90gjHFiaIVd4Alc2gsB9IqNDedbVblNtwqEsWjYCOqgrjyVI0NwezxHp/HT3k8LA2AYAj1wWq2p5RAcBRrv3kvtEe5u3ymo1lSOWQmIPGNUNituBWAbjcQ1O+J3JMZl0sNg30Phv4Eb+A+lFFZPCWut+5gCIUg4PqIRKd+GUROQVkMXv/Tni78Wa/whZXVqvac/E5am5cysv4IwIw0u5xsd6xRFwtYOOOXat7wZ3iMvpTbwN7dhvKxp06/UcsLMoGR78tcwGvogdDuaweJS1mCo66gR7glk0gAxK2d31SHwDLxLPbXQvMbAIDOICxIRY9rtE5PItYw5pppOuKDdMZ8fxw658riBXuFU3CnY7F4kp1Zjdwp8sS/1Y+1hlO5aoV9URlQOg1WTTvEIYp6mR2xIXTAFBr4OaCcYBTA7O8KvUj6S1TSFnwHmnbFuaXiiLe077xB39cLi6kGvrcaBh2CWCsVL3/Pk1Yjm6u+rCTso4ZK9RVrOSCtQ5AKLDstGskqXiwtDVTLq82baIMrSgYN1ZRTcdy7wYijFYNlfebWrz3+1CY7En6JSgKyTRtx4AzbLDY0M5bWdHseAJKNmCjHKVU4GCaHwYYp0F1VIm80MW3TSo5eQixaLslMw/EoBF11wIzw== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4554.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c457d9a-835b-40d5-40b4-08d863f3c3e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Sep 2020 21:16:28.4987 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3X+ggU9bx3ks/X8mh5jhwALEpKcmAwgzEkwgyQHGGvv++tKFsRuZDIGZwUSyKjBxZNUtTyeNxzTew9m/IovIjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1951 Return-Path: erik.c.bjorge@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Erik Bjorge -----Original Message----- From: Nate DeSimone =20 Sent: Friday, September 25, 2020 6:28 PM To: devel@edk2.groups.io Cc: Desimone, Ashley E ; Pandya, Puja ; Bret Barkelew ; Agyeman, Prin= ce ; Bjorge, Erik C Subject: [edk2-staging/EdkRepo] [PATCH V3 1/2] EdkRepo: Add function to enu= merate subst drives Cc: Ashley E Desimone Cc: Puja Pandya Cc: Bret Barkelew Cc: Prince Agyeman Cc: Erik Bjorge Signed-off-by: Nate DeSimone --- edkrepo/common/pathfix.py | 50 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/edkrepo/common/pathfix.py b/edkrepo/common/pathfix.py index 1a= 9c20f..2775442 100644 --- a/edkrepo/common/pathfix.py +++ b/edkrepo/common/pathfix.py @@ -3,7 +3,7 @@ ## @file # checkout_command.py # -# Copyright (c) 2018- 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2018 - 2020, Intel Corporation. All rights=20 +reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # import os @@ -11,6 +11,= 7 @@ import sys if sys.platform =3D=3D "win32": from ctypes import windll, POINTER, byref, GetLastError, Structure, Wi= nError from ctypes import c_void_p, c_ushort, c_int, c_ulong, c_wchar, c_wch= ar_p + from ctypes import create_unicode_buffer =20 def _is_wow64_process(): kernel32 =3D windll.kernel32 @@ -211,3 +212,50 @@ def expanduser(path): userhome =3D os.path.join(os.path.dirname(userhome), path[1:i]) =20 return userhome + path[i:] + +def get_subst_drive_dict(): + if sys.platform !=3D "win32": + return {} + def _query_subst_drive(drive_letter): + kernel32 =3D windll.kernel32 + QueryDosDevice =3D kernel32.QueryDosDeviceW + QueryDosDevice.argtypes =3D [c_wchar_p, c_wchar_p, c_ulong] + QueryDosDevice.restype =3D c_ulong + MAX_PATH =3D 260 + + if len(drive_letter) > 1 or len(drive_letter) =3D=3D 0: + raise ValueError("Bad drive letter") + drive =3D '{}:'.format(drive_letter.upper()) + drive_buffer =3D create_unicode_buffer(drive) + target_path_buffer_size =3D c_ulong(MAX_PATH) + target_path_buffer =3D create_unicode_buffer(target_path_buffer_si= ze.value) + while True: + count =3D QueryDosDevice(drive_buffer, target_path_buffer, tar= get_path_buffer_size) + if count =3D=3D 0: + last_error =3D GetLastError() + if last_error =3D=3D 122: #ERROR_INSUFFICIENT_BUFFER + #Increase the buffer size and try again + target_path_buffer_size =3D c_ulong((target_path_buffe= r_size.value * 161) / 100) + target_path_buffer =3D create_unicode_buffer(target_pa= th_buffer_size.value) + elif last_error =3D=3D 2: #ERROR_FILE_NOT_FOUND + #This is an invalid drive, return an empty string + return '' + else: + raise WinError(last_error) + else: + break + target_path =3D target_path_buffer.value + if len(target_path) > 4 and target_path[0:4] =3D=3D '\\??\\': + if (ord(target_path[4]) >=3D ord('A') and ord(target_path[4]) = <=3D ord('Z')) or \ + (ord(target_path[4]) >=3D ord('a') and ord(target_path[4])= <=3D ord('z')): + #This is a SUBST'd drive, return the path + return target_path[4:].strip() + #This is a non-SUBST'd (aka real) drive, return an empty string + return '' + subst_dict =3D {} + for index in range(26): + drive_letter =3D chr(ord('A') + index) + target_path =3D _query_subst_drive(drive_letter) + if target_path !=3D '': + subst_dict[drive_letter] =3D target_path + return subst_dict -- 2.27.0.windows.1