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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to