From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 AD41A21CEB12E for ; Tue, 14 Nov 2017 02:39:29 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2017 00:42:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,393,1505804400"; d="scan'208";a="173289340" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 14 Nov 2017 00:42:45 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 00:42:44 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 00:42:43 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Tue, 14 Nov 2017 16:42:42 +0800 From: "Ni, Ruiyu" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [PATCH] ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle() Thread-Index: AQHTXR21z0zudiwVKEqVBHPzCbWATqMTjPMQ//97ToCAAIYroA== Date: Tue, 14 Nov 2017 08:42:40 +0000 Deferred-Delivery: Tue, 14 Nov 2017 08:42:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BABFB3D@SHSMSX104.ccr.corp.intel.com> References: <20171114075333.12024-1-hao.a.wu@intel.com> <734D49CCEBEEF84792F5B80ED585239D5BABFAE8@SHSMSX104.ccr.corp.intel.com> In-Reply-To: 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] ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2017 10:39:30 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni Thanks/Ray > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, November 14, 2017 4:41 PM > To: Ni, Ruiyu ; edk2-devel@lists.01.org > Cc: Carsey, Jaben > Subject: RE: [PATCH] ShellPkg/Shell: Check the OpenVolume result in > OpenRootByHandle() >=20 > > -----Original Message----- > > From: Ni, Ruiyu > > Sent: Tuesday, November 14, 2017 4:38 PM > > To: Wu, Hao A; edk2-devel@lists.01.org > > Cc: Carsey, Jaben > > Subject: RE: [PATCH] ShellPkg/Shell: Check the OpenVolume result in > > OpenRootByHandle() > > > > How about changing the function header comments from > > > + @retval EFI_MEDIA_CHANGED The device has a different medium in= it > > or the medium is no longer supported. > > > > To: > > > + @retval others Error status returned from > > EFI_SIMPLE_FILE_SYSTEM_PROTOCOL->OpenVolume(). > > > > Because MEDIA_CHANGED is not the only error that could happen. >=20 > Yes, I will update the comments when I push the patch if there's no other > comments. >=20 >=20 > Best Regards, > Hao Wu >=20 > > > > > > Thanks/Ray > > > > > -----Original Message----- > > > From: Wu, Hao A > > > Sent: Tuesday, November 14, 2017 3:54 PM > > > To: edk2-devel@lists.01.org > > > Cc: Wu, Hao A ; Carsey, Jaben > > > ; Ni, Ruiyu > > > Subject: [PATCH] ShellPkg/Shell: Check the OpenVolume result in > > > OpenRootByHandle() > > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D779 > > > > > > For the API EfiShellOpenRootByHandle(): > > > > > > The return status of the call to SimpleFileSystem->OpenVolume should > > > be checked. > > > > > > It is possible that there is a media change in the device (like CD/DV= D ROM). > > In > > > such case, the volume root opened and/or the device path opened > > > previously (also within EfiShellOpenRootByHandle) may be invalid. > > > > > > This commit adds a check for the result of OpenVolume before > > > subsequently calling functions like EfiShellGetMapFromDevicePath() & > > > ConvertEfiFileProtocolToShellHandle(). > > > > > > Cc: Jaben Carsey > > > Cc: Ruiyu Ni > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > Signed-off-by: Hao Wu > > > --- > > > ShellPkg/Application/Shell/ShellProtocol.c | 9 +++++++-- > > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > > > b/ShellPkg/Application/Shell/ShellProtocol.c > > > index 5e34b8dad1..0dee267353 100644 > > > --- a/ShellPkg/Application/Shell/ShellProtocol.c > > > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > > > @@ -827,7 +827,8 @@ EfiShellGetDeviceName( > > > @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be > > found > > > or the root directory > > > could not be opened. > > > @retval EFI_VOLUME_CORRUPTED The data structures in the volume > > were > > > corrupted. > > > - @retval EFI_DEVICE_ERROR The device had an error > > > + @retval EFI_DEVICE_ERROR The device had an error. > > > + @retval EFI_MEDIA_CHANGED The device has a different medium in= it > > or > > > the medium is no longer supported. > > > **/ > > > EFI_STATUS > > > EFIAPI > > > @@ -867,8 +868,12 @@ EfiShellOpenRootByHandle( > > > // Open the root volume now... > > > // > > > Status =3D SimpleFileSystem->OpenVolume(SimpleFileSystem, > > &RealFileHandle); > > > + if (EFI_ERROR(Status)) { > > > + return Status; > > > + } > > > + > > > *FileHandle =3D ConvertEfiFileProtocolToShellHandle(RealFileHandle= , > > > EfiShellGetMapFromDevicePath(&DevPath)); > > > - return (Status); > > > + return (EFI_SUCCESS); > > > } > > > > > > /** > > > -- > > > 2.12.0.windows.1