Re: [edk2] EFI_FILE_PROTOCOL.Delete() failing with EFI_WARN_DELETE_FAILURE

Subject: Re: [edk2] EFI_FILE_PROTOCOL.Delete() failing with EFI_WARN_DELETE_FAILURE

From: duck wilson <duck.54321@gmail.com>

To: edk2-devel@lists.sourceforge.net

Date: 2012-10-26 15:13:20

Opening the file in create mode is the problem. Change this:

status = root->Open (
root,
file,
L"\\EFI\\BOOT\\FILE.TXT",
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
0
);

to this:

status = root->Open (
root,
file,
L"\\EFI\\BOOT\\FILE.TXT",
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
0
);



On Wed, Oct 24, 2012 at 10:59 AM, Kashif Memon <kashif@nvelo.com> wrote:
Hello,

I am trying to delete a file on the system partition from anUEFI appusing the Delete function withinEFI_FILE_PROTOCOL, but it is returning with aEFI_WARN_DELETE_FAILURE.

I can read the file without any problem, but delete doesn't seem to work.

Any ideas?

Here is the code:
// get the handle for EFI Simple File System protocol
status = gBS->LocateDevicePath (
&gEfiSimpleFileSystemProtocolGuid,
&ourDevicePath,
&handle
);
if (status != EFI_SUCCESS) {
return (status);
}

// get the pointer for the volume
status = gBS->HandleProtocol (
handle,
&gEfiSimpleFileSystemProtocolGuid,
&volume
);
if (status != EFI_SUCCESS) {
return (status);
}

// Open the root directory of the volume
root = NULL;
status = volume->OpenVolume (
volume,
&root
);
if ((status != EFI_SUCCESS) || (root == NULL)) {
return (status);
}

// Open file.txt file
status = root->Open (
root,
file,
L"\\EFI\\BOOT\\FILE.TXT",
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
0
);
if (status != EFI_SUCCESS) {
return (status);
}

// Delete the file
status = (*file)->Delete (*file);
if (status != EFI_SUCCESS) {
Print (L"Deletion failed, status = %d.\n",
status);
return (status);
}

Thanks.
Kashif...

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel