- Thread RSS
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Favorite
- Subscribe
Motorola Android EINVAL (errno==22 ) When opening files on SDCard
- Mark as New
- Favorite
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Flag as Inappropriate
08.15.2011 01:30 PM
We've run into a problem with build 4.5.91 on the Motorola Atrix. Our product uses native code to open a file on the SD Card.
We need to open the file with the O_DIRECT flag so that the OS does not cache our reads and it writes directly through to the filesystem. The SD card that's mounted is a really smart sdcard and is able to respond back to the commands we're writing.
This has been working perfectly with older build but after upgrading to the 4.5.91 build we're getting EINVAL (errno ==22) when we atempt to open a file. I've tracked this down to the use of the O_DIRECT flag. Once the flag is removed we're able to open the file but we need the ability to write through directly and not have the data cached so our reads get fresh data from the sd card.
Example Code:
int hFile=-1;
hFile = open("/sdcard/external_sd/foo.txt", O_RDWR | O_CREAT |O_SYNC|O_NDELAY|O_DIRECT); // this returns -1 and errno is set to 22
hFile = open("/sdcard/external_sd/foo.txt", O_RDWR | O_CREAT |O_SYNC| O_NDELAY); // this returns a valid file handle
Can someone shed some light on what's happend and how we could work around this change.
Thanks
Re: Motorola Android EINVAL (errno==22 ) When opening files on SDCard
- Mark as New
- Favorite
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Flag as Inappropriate
08.16.2011 09:01 AM
Hi op84,
Thanks for your post!
Let me check into this.
thanks!
Re: Motorola Android EINVAL (errno==22 ) When opening files on SDCard
- Mark as New
- Favorite
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Flag as Inappropriate
08.17.2011 12:29 PM
Thanks
Re: Motorola Android EINVAL (errno==22 ) When opening files on SDCard
- Mark as New
- Favorite
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Flag as Inappropriate
08.18.2011 12:02 PM
Hi op84,
I was told after further investigation by our Feature leads that O_DIRECT does not work in Gingerbread.
thanks!
-
-
- of 1
-
-
