Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b89ccf0 authored by faqiang.zhu's avatar faqiang.zhu
Browse files

fix copy large file issue over MTP on 32bit device



change offset variable type from off_t to loff_t, then it won't overflow
when the offset value is larger than 2GB.

change the pwrite and pread function to be pwrite64 and pread64 so the
offset parameter won't overflow.

Change-Id: I45947479a59a4240fd708787384bcadee09d8947
Signed-off-by: default avatarfaqiang.zhu <faqiang.zhu@nxp.com>
parent 28d257e4
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -47,10 +47,10 @@ void work_func(void *) {
        CHECK(aiocbp->queued);
        int ret;
        if (aiocbp->read) {
            ret = TEMP_FAILURE_RETRY(pread(aiocbp->aio_fildes,
            ret = TEMP_FAILURE_RETRY(pread64(aiocbp->aio_fildes,
                    aiocbp->aio_buf, aiocbp->aio_nbytes, aiocbp->aio_offset));
        } else {
            ret = TEMP_FAILURE_RETRY(pwrite(aiocbp->aio_fildes,
            ret = TEMP_FAILURE_RETRY(pwrite64(aiocbp->aio_fildes,
               aiocbp->aio_buf, aiocbp->aio_nbytes, aiocbp->aio_offset));
        }
        {
@@ -139,7 +139,7 @@ int aio_suspend(struct aiocb *aiocbp[], int n,
    return 0;
}

void aio_prepare(struct aiocb *aiocbp, void* buf, size_t count, off_t offset) {
void aio_prepare(struct aiocb *aiocbp, void* buf, size_t count, off64_t offset) {
    aiocbp->aio_buf = buf;
    aiocbp->aio_offset = offset;
    aiocbp->aio_nbytes = count;
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ struct aiocb {
    int aio_fildes;
    void *aio_buf;

    off_t aio_offset;
    off64_t aio_offset;
    size_t aio_nbytes;

    // Used internally
@@ -61,7 +61,7 @@ int aio_error(const struct aiocb *);
ssize_t aio_return(struct aiocb *);

// Helper method for setting aiocb members
void aio_prepare(struct aiocb *, void*, size_t, off_t);
void aio_prepare(struct aiocb *, void*, size_t, off64_t);

#endif // POSIXASYNCIO_H