What about this one? On Thu, 02 Feb 2006 18:31:37 EET "Sergey Poznyakoff" <[EMAIL PROTECTED]> wrote:
> Peter Vrabec <[EMAIL PROTECTED]> wrote: > > > extracting a sparse file to a filesystem like vfat that does not > > support sparse files results in an incomplete output file. > > Thanks for reporting. > > > What do you think about attached patch? > > I think that, while the issue should certainly be solved, the patch > addresses it the wrong way. It should be the responsibility of > sys_truncate to handle this case. > > Regards, > Sergey
--- tar-1.15.1/src/system.c.vfatTruncate 2004-09-06 07:31:00.000000000 -0400 +++ tar-1.15.1/src/system.c 2006-02-03 14:40:51.000000000 -0500 @@ -272,8 +272,25 @@ int sys_truncate (int fd) { + struct stat st; off_t pos = lseek (fd, (off_t) 0, SEEK_CUR); - return pos < 0 ? -1 : ftruncate (fd, pos); + + if ( pos < 0) + return -1; + + if ( ftruncate (fd, pos) != 0 ) { + /* wrapper around ftruncate: + * ftruncate may fail to grow the size of a file with some OS and filesystem + * combinations. Linux and vfat/fat is one example. If this is the case do + * a write to grow the file to the desired length. + */ + if( (fstat( fd, &st ) == -1) || + (st.st_size >= pos) || + (lseek( fd, pos - 1, SEEK_SET) == (off_t)-1) || + (write( fd, "\0", 1) == -1) ) + return -1; + } + return 0; } /* Return nonzero if NAME is the name of a regular file, or if the file
_______________________________________________ Bug-tar mailing list Bug-tar@gnu.org http://lists.gnu.org/mailman/listinfo/bug-tar