LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-03-2009, 01:37 PM   #1
LQ Newbie
Registered: Oct 2003
Posts: 2

Rep: Reputation: 0
Problem with libtar api and large files


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

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):

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;

	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) {
			return 1;

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

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

	return 0;
Old 01-04-2009, 08:14 AM   #2
LQ Newbie
Registered: Jan 2009
Posts: 4

Rep: Reputation: 0
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.

Last edited by foobar; 01-04-2009 at 08:51 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ext3 performance -- very large number of files, large filesystems, etc. td3201 Linux - Server 5 11-25-2008 10:28 AM
Problem copying large amount of files from IDE external case in Fedora C4 TruthSeeker Linux - Newbie 8 10-26-2005 03:04 AM
Samba Problem: Fedora crashes when transferring large files TheLizard Linux - Networking 6 05-08-2005 05:19 AM
USB External Hard Disk problem with large files nick1.41 Linux - Hardware 0 05-26-2004 08:33 PM
My Biggest Problem Yet. (troubles xfering large files) bkeating Linux - General 18 01-14-2003 04:10 PM

All times are GMT -5. The time now is 07:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration