pwrite failed on emulator and HTC G1, errno is -EFBIG

by ZhangJieJing » Wed, 05 Aug 2009 18:07:35 GMT


Sponsored Links
 Hi, all:

Does anyone have pwirte failed on android?
I've write a small test program, to test pwrite behavior on android emulator
and HTC G1,

but it's cann't call twice correctly.  the return errno is EFBIG, but i only
write 1024 B to a file.

I cann't figure out why  this happens, please help me. thank you...

this is my test program:


#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>

static void
usage(const char *s)
{
    fprintf(stderr, "USAGE: %s SECONDS\n", s);
    exit(-1);
}

int main(int argc, char *argv[])
{

        int fd;
        char buf[8777];
        ssize_t  total_in = 0;
        ssize_t  max_write = 0x2 << 20; /* 2 * * M */

        if (argc > 2)
                usage("test_p filepath");

        fd = open(argv[1], O_RDWR | O_CREAT, 0666);
        if (fd < 0) {
                perror(" open error");
                exit(-1);
        }
        ssize_t ret = 0;

        do {
                ret = pwrite(fd, (void*)buf, 1024, total_in);
                printf("Pwirte: ret: %d errnos:%d \n", ret, errno);
                if (ret > 0) total_in += ret;
        } while ((ret >0 && total_in < max_write) || errno == EINTR);

        close(fd);
        printf(" finish: total_write : %d K", total_in >> 10);

        return 0;
}



On the emulator and HTC G1 both have same out come:
I've test it at every file system on the emulator and G1.

the Log :

# ./test_p /sqlite_stmt_journals/aaa
Pwirte: ret: 1024 errnos:0
Pwirte: ret: -1 errnos:27
 finish: total_write : 1 K#
#

# ./test_p /cache/sss
Pwirte: ret: -1 errnos:27
 finish: total_write : 0 K#


The df command :
# df
/dev: 49484K total, 0K used, 49484K available (block size 4096)
/sqlite_stmt_journals: 4096K total, 12K used, 4084K available (block size
4096)
/system: 69120K total, 68436K used, 684K available (block size 4096)
/data: 76544K total, 39424K used, 37120K available (block size 4096)
/cache: 69120K total, 20884K used, 48236K available (block size 4096)
/sdcard: 991488K total, 918256K used, 73232K available (block size 16384)


---
Best regards,
Zhang Jiejing

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Query

How to get the port number for the device to run more than one
emulator?

--~--~---------~--~----~------------~-------~--~----~

2. Writing Exif Data

Does Android have any facilities for writing custom exif data?  In
particular, I have some data that will only be available as early as
the jpeg PictureCallback.  How can I insert this data into the exif
header of the jpeg file?  I tried using a copy of the ExifInterface
class I found online, but it fails on the call to
"System.loadLibrary("exif")".  Any help with this would be greatly
appreciated.

Cheers,
Rob

--~--~---------~--~----~------------~-------~--~----~

3. Hello world help

4. Shortcomings with Native Gmail App

5. Can I set Exchange to automatically use the other APN (intranet)?

6. Using Open source libraries for ADC2

7. Getting rid of HTC Smart Dialer?