2008-10-06 08:41:43     fopen dosn't work

Document created by Aaronwu Employee on Aug 7, 2013
Version 1Show Document
  • View in full screen mode

2008-10-06 08:41:43     fopen dosn't work

Stephen Sheldon (GERMANY)

Message: 63160   

 

Hi,

 

I have a problem with file operations. I can't open a simple binary file.

 

Nothing happens when I call FILE *file = fopen("Filename", "rb"). The application never comes back from this function. When I debug it with gdb nothing happens, and I have to restart the application.

 

 

 

I use the BF561 Eval Board with uClinux-dist-2008R1-RC8. Default config. Just the watchdog ist disabled.

 

 

 

Best regards

 

Stephen

TranslateQuoteReplyEditDelete

 

 

2008-10-06 09:17:14     Re: fopen dosn't work

Robin Getz (UNITED STATES)

Message: 63161   

 

Stephen:

 

Need more info.

 

Are you trying to open a file that exists? doesn't exist? special file (/dev/*, /sys/*, /proc/* ), normal file? backed on what type of file system?

 

-robin

QuoteReplyEditDelete

 

 

2008-10-06 12:21:36     Re: fopen dosn't work

Stephen Sheldon (GERMANY)

Message: 63164   

 

I am trying to open an existing *.bmp file. But I also need to open a non existing file later on. The file is in the same directory as the binary of the application. I have created the file on my Suse Desktop PC.

TranslateQuoteReplyEditDelete

 

 

2008-10-06 14:05:26     Re: fopen dosn't work

Robin Getz (UNITED STATES)

Message: 63166   

 

Stephen:

 

Then something is likely wrong with your code. - have a look in lib/libjpeg/example.c

 

 

  if ((infile = fopen(filename, "rb")) == NULL) {

    fprintf(stderr, "can't open %s\n", filename);

    return 0;

  }

 

-Robin

QuoteReplyEditDelete

 

 

2008-10-06 14:15:15     Re: fopen dosn't work

Mike Frysinger (UNITED STATES)

Message: 63167   

 

try running it through strace as well

QuoteReplyEditDelete

 

 

2008-10-07 04:25:35     Re: fopen dosn't work

Stephen Sheldon (GERMANY)

Message: 63212   

 

the code can't be wrong. I used several libraries for *.bmp loading such as http://easybmp.sourceforge.net/ or http://www.kalytta.com/bitmap.h.

 

I have compilied the bmp libs as static libs. I use them in a shared lib.

 

When I use ifstream with the funtions ::open ::read ::write ... it works. But not every lib, which I want to use, uses this method to read/write from/to files. So this is no solution for me.

TranslateQuoteReplyEditDelete

 

 

2008-10-07 06:45:16     Re: fopen dosn't work

Stephen Sheldon (GERMANY)

Message: 63213   

 

When I just execute a little "Hello World" program with some file operations (open, read, write, close) the file operations work fine. I have no idea why nothing happens when I call open in our software.

TranslateQuoteReplyEditDelete

 

 

2008-10-07 07:42:05     Re: fopen dosn't work

Robin Getz (UNITED STATES)

Message: 63214   

 

Stephen:

 

Is the failing application a standard library - where I can get the source to replicate things? or is it your own custom source that you can share?

 

-Robin

QuoteReplyEditDelete

 

 

2008-10-07 09:09:49     Re: fopen dosn't work

Stephen Sheldon (GERMANY)

Message: 63220   

 

Robin:

 

I think that I know why it dosn't work. We use in our Software an Operation System Abstract Layer (OSAL). This layer supports also some file operations. With those operation file access works. Perhaps the OSAL influences the file operations from stdio.

 

Unfortunately I am not allowed to share the OSAL or any other part of our Software. :-(

 

 

 

Best regards

 

Steph

TranslateQuoteReplyEditDelete

 

 

2008-10-07 12:11:21     Re: fopen dosn't work

Mike Frysinger (UNITED STATES)

Message: 63225   

 

if your OSAL is overriding standard C functions, then there isnt much we can do ...

 

you use readelf to see what symbols OSAL is exporting ...

Attachments

    Outcomes