Blame tar-1.15.1-vfatTruncate.patch
|
|
6c50160 |
--- tar-1.15.1/src/system.c.vfatTruncate 2004-09-06 07:31:00.000000000 -0400
|
|
|
6c50160 |
+++ tar-1.15.1/src/system.c 2006-02-03 14:40:51.000000000 -0500
|
|
|
6c50160 |
@@ -272,8 +272,25 @@
|
|
|
6c50160 |
int
|
|
|
6c50160 |
sys_truncate (int fd)
|
|
|
6c50160 |
{
|
|
|
6c50160 |
+ struct stat st;
|
|
|
6c50160 |
off_t pos = lseek (fd, (off_t) 0, SEEK_CUR);
|
|
|
6c50160 |
- return pos < 0 ? -1 : ftruncate (fd, pos);
|
|
|
6c50160 |
+
|
|
|
6c50160 |
+ if ( pos < 0)
|
|
|
6c50160 |
+ return -1;
|
|
|
6c50160 |
+
|
|
|
6c50160 |
+ if ( ftruncate(fd, pos) && errno == EPERM ) {
|
|
|
6c50160 |
+ /* wrapper around ftruncate:
|
|
|
6c50160 |
+ * ftruncate may fail to grow the size of a file with some OS and filesystem
|
|
|
6c50160 |
+ * combinations. Linux and vfat/fat is one example. If this is the case do
|
|
|
6c50160 |
+ * a write to grow the file to the desired length.
|
|
|
6c50160 |
+ */
|
|
|
6c50160 |
+ if( (fstat( fd, &st ) == -1) ||
|
|
|
6c50160 |
+ (st.st_size >= pos) ||
|
|
|
6c50160 |
+ (lseek( fd, pos - 1, SEEK_SET) == (off_t)-1) ||
|
|
|
6c50160 |
+ (write( fd, "\0", 1) == -1) )
|
|
|
6c50160 |
+ return -1;
|
|
|
6c50160 |
+ }
|
|
|
6c50160 |
+ return 0;
|
|
|
6c50160 |
}
|
|
|
6c50160 |
|
|
|
6c50160 |
/* Return nonzero if NAME is the name of a regular file, or if the file
|