From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4A3772117FD4C for ; Tue, 30 Oct 2018 00:33:25 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 00:33:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,443,1534834800"; d="scan'208";a="103864527" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 30 Oct 2018 00:33:25 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 30 Oct 2018 00:33:24 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by shsmsx102.ccr.corp.intel.com ([169.254.2.84]) with mapi id 14.03.0415.000; Tue, 30 Oct 2018 15:33:21 +0800 From: "Ni, Ruiyu" To: "Jim.Dailey@dell.com" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [PATCH v2 1/2] ShellPkg-UefiShellLib: Add a function to fully-qualify paths Thread-Index: AdRvyvFMWA6pVzosSjCUose/JKCJhgAV+iZA Date: Tue, 30 Oct 2018 07:33:21 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BEE552B@SHSMSX104.ccr.corp.intel.com> References: <517a9546603441cc868554cb350e8afe@ausx13mps335.AMER.DELL.COM> In-Reply-To: <517a9546603441cc868554cb350e8afe@ausx13mps335.AMER.DELL.COM> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 1/2] ShellPkg-UefiShellLib: Add a function to fully-qualify paths X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Oct 2018 07:33:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Jim.Dailey@dell.com > Sent: Tuesday, October 30, 2018 5:15 AM > To: edk2-devel@lists.01.org > Cc: Carsey, Jaben ; Ni, Ruiyu > Subject: [PATCH v2 1/2] ShellPkg-UefiShellLib: Add a function to fully-qu= alify > paths >=20 > +CHAR16* > +EFIAPI > +FullyQualifyPath( > + IN CONST CHAR16 *Path > + ) > +{ > + CONST CHAR16 *WorkingPath; > + CONST CHAR16 *InputPath; > + CHAR16 *InputFileSystem; > + UINTN FileSystemCharCount; > + CHAR16 *FullyQualifiedPath; > + UINTN Size; > + > + FullyQualifiedPath =3D NULL; > + > + ASSERT(Path !=3D NULL); > + // > + // Handle erroneous input when asserts are disabled. > + // > + if (Path =3D=3D NULL) { > + return NULL; > + } > + // > + // In paths that contain ":", like fs0:dir/file.ext and fs2:\fqpath\fi= le.ext, > + // we have to consider the file system part separately from the "path= " > part. > + // If there is a file system in the path, we have to get the current w= orking > + // directory for that file system. Then we need to use the part of the= path > + // following the ":". If a path does not contain ":", we use it as gi= ven. > + // > + InputPath =3D StrStr(Path, L":"); > + if (InputPath !=3D NULL) { > + InputPath++; > + FileSystemCharCount =3D ((UINTN)InputPath - (UINTN)Path + > sizeof(CHAR16)) / sizeof(CHAR16); > + InputFileSystem =3D AllocateCopyPool(FileSystemCharCount * > sizeof(CHAR16), Path); > + if (InputFileSystem !=3D NULL) { > + InputFileSystem[FileSystemCharCount - 1] =3D CHAR_NULL; > + } > + WorkingPath =3D ShellGetCurrentDir(InputFileSystem); > + SHELL_FREE_NON_NULL(InputFileSystem); > + // > + // Handle the degenerate case where Path was only a file system > reference. > + // In that case we return the current working directory of the file = system. > + // > + if (InputPath =3D=3D NULL) { The "InputPath" should not be NULL.