Re: [edk2] File operation help

Subject: Re: [edk2] File operation help

From: "Carsey, Jaben" <jaben.carsey@intel.com>

To: "edk2-devel@lists.sourceforge.net" <edk2-devel@lists.sourceforge.net>, Daryl McDaniel <darylm503@gmail.com>

Date: 2011-09-29 16:19:34

First, SHELL_FILE_HANDLE and EFI_FILE_HANDLE are different types.  They are not always interchangeable.  That is the difference between FileHandleWrite and ShellWriteFile.  They are for different data types.

Second, I would change your filename to have the '\' after the ':' like this: "fs0:\test.txt"

-Jaben


-----Original Message-----
From: Raghuramchary Jallipalli [mailto:Raghuramchary.Jallipalli@lntinfotech.com] 
Sent: Thursday, September 29, 2011 12:54 AM
To: Daryl McDaniel; edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] File operation help

Thanks Daryl for the response.
The other thing I tried is as below:
-------------
int main(int Argc, char** Argv) {
CHAR16 FileName[] = L"fs0:test.txt";
         EFI_FILE_HANDLE  FileHandle;
         EFI_STATUS   Status;
         UINTN value = 9,rd =9;
         char *buff = "Hello";
         char *rbuff = NULL;

Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ |EFI_FILE_MODE_WRITE, 0);

     if(Status == EFI_SUCCESS)
            Print(L"File Opened \n");
         else
                Print(L"Cannot open [%r]!\n",Status);

        Status = FileHandleWrite(FileHandle, &value, buff);
        if(Status == EFI_SUCCESS)
            Print(L"File Written \n");
         else
                Print(L"Cannot write [%r]!\n",Status);
        rbuff = malloc(10);
        Status = FileHandleRead(FileHandle, &rd, rbuff);
        if(Status == EFI_SUCCESS)
            Print(L"File Read \n");
         else
                Print(L"Cannot read [%r]!\n",Status);
        Print(L"%s\n",rbuff);
return 0;
}
-----------------------

Here the Status is EFI_SUCCESS for open,Write and Read but when I try to print the read buffer I get the File name "test.txt" as output but not the written value "Hello". Also, what is the difference between ShellWriteFile() and FileHandleWrite()? Any idea in what cases we need to go for ShellWriteFile() and FileHandleWrite() ??
I'm testing the .efi application by copying it into usb , plugging it into the board and run the app in the efi shell.

Thanks,
Raghu


-----Original Message-----
From: Daryl McDaniel [mailto:darylm503@gmail.com]
Sent: Thursday, September 29, 2011 2:18 AM
To: Raghuramchary Jallipalli
Subject: Re: [edk2] File operation help

Raghu,

There are a number of things you may try.

First, your code looks OK except for one small issue:

    1) Zero, 0, is a valid value for open() to return.  Normally, this
is STDIN, but if stdin is closed open could return 0.

I did notice that you must be using an obsolete version of the
Standard C Library.  The current version uses the following prototype
for main:
    int main(int Argc, char** Argv)

The command line is now converted to narrow characters before it is
tokenized and passed to main().

Please update your code to the latest version from www.tianocore.org,
make the above changes to your main() prototype, and try again.

Please note that there are two packages required: StdLib and
StdLibPrivateInternalFiles.  A third package, AppPkg, contains demo
applications that use the Standard C Library and other standard
libraries contained within StdLib.

Best of luck,
Daryl McDaniel

______________________________________________________________________

The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s). Unintended recipients are prohibited from taking action on the basis of information in this e-mail and  using or disseminating the information,  and must notify the sender and delete it from their system. L&T Infotech will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in this e-mail"

______________________________________________________________________

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel