From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.1089.1602197795790145855 for ; Thu, 08 Oct 2020 15:56:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=SgnS1Zpn; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: ZDObiGn5cndZ/Y1auARmvLp30PqdvL6qkBBJYtaf5FUqDjC9BYBgMfwL1JvhTvn24g0i0SKrXC 8CcS2TwIWzpw== X-IronPort-AV: E=McAfee;i="6000,8403,9768"; a="250110294" X-IronPort-AV: E=Sophos;i="5.77,352,1596524400"; d="scan'208";a="250110294" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2020 15:56:34 -0700 IronPort-SDR: UG7ID0gKlIDWJQf7HQjn4v/ly1qkOJmFwjXg0u3hQb1d0I3vTBJxlJro2/nbqNKCHKx5vQuGKI 4fJrWdxi78dg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,352,1596524400"; d="scan'208";a="298090448" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga007.fm.intel.com with ESMTP; 08 Oct 2020 15:56:34 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) 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; Thu, 8 Oct 2020 15:56:34 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 8 Oct 2020 15:56:34 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.172) 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; Thu, 8 Oct 2020 15:56:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hcAgfCFiGqO4PpXkqo583Y7KzDI0cyhZ/sGJrCJQEcrguBpjYKBGOrGUF0dX64v/oWiU4hmZvbj4jK2ap8LF/RgBrl1inbQ6QT4pJHzMcGjFFN+IhOm6cpRoaaFsIBTSbqhsp8G4QaIhLZnpaX9jt/ZOWWzMYQGhrUFdG83Sp3nITVUk8SLDqWwfCMimk0Vnc9DpTukf7BWo94ILLZyF3jBRF4w5eFva59He/bU5Tc9X++LQ8rXncXxHcB3L6DZDIToB+1PzpOBvHDThOx35iEgXRx3gVIboMfz2z3BY2ItO7GG47ctGL31yccoJNCbrR89PJO9P5mQfTMrJyGsobA== 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=1TqxU5IcMjnHNP4hH0KLqIPcb2S6dzA2fGxIjQgJq8U=; b=l+fvlqaABevU1/K/qQqeuMor596yOMDbk7AcL/OzTYR9Lfx6yoOv2FjLxhNOQpgE5YZzC2d2SrTRpktlOyM3FfAg+70gY8S85O5x6FFN+8vAa2WZrRxCnk9M550Sz45/jgv8PdsYjBsDf0t4m5xeweE3pFGjSSYGI2W6bIxmqQG7tj6m4LOc3ydoWKf03OcURPCF53t11gzcm7aP/E8y8lH9woxoKm1Hzrh9DIEKW3kxTl5V5oWHCheYot+zygPPBCgqXM8z7wlf00JsVzUWUWNG6fUETKY//wzYkackx55x4A5DymJiXSHptgad+W1g3hr2uvWm37R2Ii7hbY4HEg== 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=1TqxU5IcMjnHNP4hH0KLqIPcb2S6dzA2fGxIjQgJq8U=; b=SgnS1Zpne4CVLo+HioVhGwu5LEgwf2YAyG17iwhlyfio1i4eLVvybuNI5G5YNRgHchXrIu+NR4tj+FHsPjdJWi5YaJtE6s4wiTRa2K8H/aU2CSpTU1jwHZcyBIYInjQabr6zV5HISF5txJkiqMMTvo8YGUYcy95O4/l9KkNfDiA= Received: from BY5PR11MB3973.namprd11.prod.outlook.com (2603:10b6:a03:185::29) by BYAPR11MB2535.namprd11.prod.outlook.com (2603:10b6:a02:be::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 8 Oct 2020 22:56:31 +0000 Received: from BY5PR11MB3973.namprd11.prod.outlook.com ([fe80::e467:ac20:6b35:aa8c]) by BY5PR11MB3973.namprd11.prod.outlook.com ([fe80::e467:ac20:6b35:aa8c%5]) with mapi id 15.20.3455.022; Thu, 8 Oct 2020 22:56:31 +0000 From: "Ashley E Desimone" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" CC: "Pandya, Puja" , Bret Barkelew , "Agyeman, Prince" , "Bjorge, Erik C" 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: AQHWk6Rnv3HVcwKDPE2Iw7R5wngsUKmOZTlQ Date: Thu, 8 Oct 2020 22:56:31 +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-version: 11.5.1.3 dlp-reaction: no-action 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.190.176] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f080949c-00e8-4946-6c5d-08d86bdd6600 x-ms-traffictypediagnostic: BYAPR11MB2535: 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: MKfxtTTBqwF2LBX9BqbVuYijh2S+t0H4vgBTJzULfYOWPDr3IfsqtWZ48H6F4snEkPIcrXyiuEcSiV1V4Ed64P6iSPWXWzKMDAJPCQrEZX59FGxDfAftbZ634Mo+x60ra991dlHL+2qT/boXn0c5nsgTexlEkeEjvhHrjAydQNJuGEkCp6sBPG4L/wuDlZ8IhIqw7Ivk6W91vDKbJ8BsO3ZzrFLRLzcaV1Nug1Tpmmk4iTNvzEU5zHSWY3GXl6LYhSoZgO+VeJrlamzYRIhuzmCs3NFELFUcplQJ9rRkvLXFgC9jCfNbtpCb9Ixmt1rO x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR11MB3973.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(346002)(376002)(136003)(366004)(39860400002)(107886003)(55016002)(76116006)(66556008)(66476007)(66946007)(8936002)(64756008)(66446008)(53546011)(478600001)(4326008)(33656002)(6506007)(7696005)(86362001)(52536014)(9686003)(2906002)(83380400001)(5660300002)(8676002)(71200400001)(186003)(316002)(54906003)(19627235002)(110136005)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 9BFVG47ykENVzo8CkcFQB6BwMP0SwT6dSI2MRuBvysksNO1t8iTjlhXk0d2ofFhjAgZBSVHBfjaNT8ONYayVhJgbUDNvDFPcGxfJXX5YC5A141PGZCLHw9scWEBaXALynkoMEZ2obkjocrcWppS5AaYGhqtNnt7kvJm5QoancIZgD5n+0Zp8nNsIG8l8Rwshbv0vv4uCDbB+FyYkezY5f+tFXDKr1hsO7hIN705j4t1vGzsH07UsYoHQpOiXlncmJ9dx0rjVGArbzVfr1Ey3n1BEilaTsXEdUmt5BJh/dQio5GudFvPOxwfcI5SHObYaszPi7KXiIG+Gor0JnATacjwrF6fP6Jf6e5IUZzCnRVkW9F1ElUC5Q7GCaUYZc/+6etJwbtlnuSqlDuZhTqzz/LzazPxZ/IAD0MmOyaStG3RmFiRDXzWyDJEL4rzCiJ8kohXqjI7t3du48yq4eTf2YkJL3CB2mLYdqMqaxJp4COj5V19uUO4nfnK5gUWudso1Ku+uybFd19HUH8bX2fgziqjVCwlsRLVbX47jl1eoa7WktYAOxrukFuB7Qv5k6V8icBC+XxmDw14jHJQXZCzNztW1lg8FmZQvSVNTjJcJ8ZJX8AFEeCEDIMiP8n5FuIR7kzBmwucjcVTQaFGcMnrIuw== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR11MB3973.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f080949c-00e8-4946-6c5d-08d86bdd6600 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Oct 2020 22:56:31.4204 (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: anlX/wBpQ/diDEy1SSwLwjb0pRhw+0XOqNOCdbaHZLHf5N01gZ+JAxTUnG4ruf1XLY73RxFi5RTGQTKCmghoqTOV705u+Cfh6e3pvqd3yeI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2535 Return-Path: ashley.e.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ashley DeSimone -----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