Here are the information.

The (meaningful) code:
--
   char currentdir[1024];
   if(getcwd(currentdir, sizeof(currentdir))!= NULL){
      printf("Working dir: '%s'\n", currentdir);
   }
   if(fopen("test.txt", "rb") == NULL)
   {
      printf("fopen failed. errno = %d\n", errno);
      perror("Couldn't open 'test.txt' file: ");
   }
   if(fopen("fs0:\\test.txt", "rb") == NULL)
   {
      printf("fopen failed. errno = %d\n", errno);
      perror("Couldn't open 'fs0:\\test.txt' file: ");
   }
--

I've never used errno with EDK2 and I don't know if perror() should work,
but it just don't print anything.

The output is:
--
fopen failed. errno = 2
fopen failed. errno = 2
--

Checking what 2 means in sys/errno.h:

--
  __ENOENT,                         /*  2   No such file or directory */
--

If I delete the file the behavior is exactly the same.

Once again, thank for your help,

Mauro


On Wed, Jul 24, 2013 at 3:04 PM, Mauro Faccenda <facce...@gmail.com> wrote:

> Hi Daryl,
>
> Thank you for your quick answer.
>
> that command shows the file content as expected.
>
> I'll try to check the information you suggested and post the results here.
>
> Mauro
>
>
>
>
>
> On Wed, Jul 24, 2013 at 2:52 PM, Mcdaniel, Daryl <daryl.mcdan...@intel.com
> > wrote:
>
>>  Mauro,****
>>
>> ** **
>>
>> After a quick scan of your email, I can’t see anything wrong.****
>>
>> I’ll try to reproduce it this afternoon and get back to you with my
>> results.****
>>
>> ** **
>>
>> Sorry, but I have to ask the following stupid questions.****
>>
>> **1)      **What happens if you enter “type fs0:\file.txt” at a (U)Efi
>> Shell prompt?****
>>
>> **2)      **Have you tried checking errno or EfiErrno for additional
>> information after the fopen() failed?****
>>
>> ** **
>>
>> Daryl McDaniel****
>>
>> ** **
>>
>> *From:* Mauro Faccenda [mailto:facce...@gmail.com]
>> *Sent:* Wednesday, July 24, 2013 10:39 AM
>> *To:* edk2-devel@lists.sourceforge.net
>> *Subject:* [edk2] simple file operations using stdio.h****
>>
>> ** **
>>
>> Hi all,****
>>
>> ** **
>>
>> I am sorry to ask such a simple question and I swear before asking to
>> this list I've searched for some solutions and couldn't fine one that
>> worked for me.****
>>
>> ** **
>>
>> I need to make some basic file operations using the fopen and fclose. So,
>> my code is this simple:****
>>
>> ** **
>>
>> --****
>>
>> #include <stdio.h>****
>>
>> #include <unistd.h>****
>>
>> ** **
>>
>> int main(int argc, char *argv[])****
>>
>> {****
>>
>>    char currentdir[1024];****
>>
>> ** **
>>
>>    if(getcwd(currentdir, sizeof(currentdir)) != NULL) printf("Working
>> dir: '%s'\n");****
>>
>>    if(fopen("file.txt", "rb") == NULL) printf("Couldn't open 'file.txt'
>> file\n");****
>>
>>    if(fopen("fs0:\\file.txt", "rb") == NULL) printf("Couldn't open
>> 'fs0:\\file.txt' file\n");****
>>
>> ** **
>>
>>    return(0);****
>>
>> }****
>>
>> --****
>>
>> ** **
>>
>> And the .inf:****
>>
>> --****
>>
>> [Defines]****
>>
>>   INF_VERSION                    = 0x00010006****
>>
>>   BASE_NAME                      = Test****
>>
>>   FILE_GUID                         = 08f6ab0d-57ca-4759-b217-47ca02a368c5
>> ****
>>
>>   MODULE_TYPE                    = UEFI_APPLICATION****
>>
>>   VERSION_STRING                 = 0.1****
>>
>>   ENTRY_POINT                    = ShellCEntryLib****
>>
>> ** **
>>
>> [Sources]****
>>
>>   Test.c****
>>
>> ** **
>>
>> [Packages]****
>>
>>   StdLib/StdLib.dec****
>>
>>   MdePkg/MdePkg.dec  ****
>>
>> ** **
>>
>> [LibraryClasses]****
>>
>>   DevShell****
>>
>>   LibC****
>>
>>   ShellCEntryLib****
>>
>> --****
>>
>> ** **
>>
>> And I run it after typing 'fs0:' to have a working dir.****
>>
>> ** **
>>
>> The program output is:****
>>
>> ** **
>>
>> --****
>>
>> Working dir: 'fs0:\'****
>>
>> Couldn't open 'file.txt' file****
>>
>> Couldn't open 'fs0:\file.txt' file****
>>
>> --****
>>
>> ** **
>>
>> Is it supposed to work? If so, how can I find out why it isn't?****
>>
>> ** **
>>
>> Thanks in advance,****
>>
>> ** **
>>
>> Mauro****
>>
>> ** **
>>
>> ** **
>>
>
>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to