LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problem with libtar api and large files (https://www.linuxquestions.org/questions/programming-9/problem-with-libtar-api-and-large-files-694715/)

SirSeoman 01-03-2009 12:37 PM

Problem with libtar api and large files
 
Hello,

I've written a sample application using the tar library. But I have difficulties with large files:

Code:

tar_append_tree("/video/testfolder", "testfolder"): Value too large for defined data type
In this case in "/video/testfolder" is a file with 4,8 GB. How can I make that method to tar large files?

Here is the code I am using (it's basically the code from libtar.c that comes as example with libtar):

Code:

int create(char *tarFile, char *rootDir, libtar_list_t *l) {
        TAR *t;

        if (tar_open(&t, tarFile, NULL, O_WRONLY | O_CREAT, 0644, 0 | 0) == -1) {
                fprintf(stderr, "tar_open(): %s\n", strerror(errno));
                return 1;
        }

        char *pathname = NULL;
        char buf[256] = { 0 };
        libtar_listptr_t lp;
        libtar_listptr_reset(&lp);

        while (libtar_list_next(l, &lp) != 0) {
                pathname = (char *) libtar_listptr_data(&lp);

                if (pathname[0] != '/' && rootDir != NULL) {
                        snprintf(buf, sizeof(buf), "%s/%s", rootDir, pathname);
                } else {
                        snprintf(buf, sizeof(buf), "%s", pathname);
                }

                if (tar_append_tree(t, buf, pathname) != 0) {
                        tar_close(t);
                        return 1;
                }
        }

        if (tar_append_eof(t) != 0) {
                tar_close(t);
                return 1;
        }

        if (tar_close(t) != 0) {
                return 1;
        }

        return 0;
}

THX

foobar 01-04-2009 07:14 AM

I suspect that the error is coming from an open call which gets called by the lib indirectly. 4.8gb is bigger than what a long (assuming long is 32 bits) can hold and may require that the library uses O_LARGEFILE
in the open call flags. So I am assuming "Value too large for defined data type" is in relation to the off_t type.

Try and supply a tartype_t which has a function pointer to open in which you can supply the flag.


All times are GMT -5. The time now is 04:18 AM.