wok rev 10937
fusecloop: large file support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Aug 28 10:58:22 2011 +0200 (2011-08-28) |
parents | e5f7f1b3d407 |
children | 1e7452b326f8 |
files | fusecloop/stuff/fusecloop.u |
line diff
1.1 --- a/fusecloop/stuff/fusecloop.u Sat Aug 27 17:16:27 2011 +0200 1.2 +++ b/fusecloop/stuff/fusecloop.u Sun Aug 28 10:58:22 2011 +0200 1.3 @@ -129,8 +129,9 @@ 1.4 1.5 --- extract_compressed_fs.c 1.6 +++ extract_compressed_fs.c 1.7 -@@ -1,15 +1,18 @@ 1.8 +@@ -1,15 +1,19 @@ 1.9 /* Extracts a filesystem back from a compressed fs file */ 1.10 ++#define _LARGEFILE64_SOURCE 1.11 #include "common_header.h" 1.12 +#define CLOOP_PREAMBLE "#!/bin/sh\n" "#V2.0 Format\n" "insmod cloop.o file=$0 && mount -r -t iso9660 /dev/cloop $1\n" "exit $?\n" 1.13 1.14 @@ -150,7 +151,7 @@ 1.15 exit(1); 1.16 } 1.17 1.18 -@@ -24,44 +27,76 @@ 1.19 +@@ -24,44 +28,77 @@ 1.20 exit(1); 1.21 } 1.22 1.23 @@ -175,11 +176,12 @@ 1.24 + 1.25 + if (num_blocks == -1) { 1.26 + struct cloop_tail tail; 1.27 -+ if (lseek(handle, - sizeof(tail), SEEK_END) < 0 || 1.28 ++ loff_t end = lseek64(handle, 0, SEEK_END); 1.29 ++ if (lseek64(handle, end - sizeof(tail), SEEK_SET) < 0 || 1.30 + read(handle, &tail, sizeof(tail)) != sizeof(tail) || 1.31 -+ lseek(handle, - sizeof(tail) - 1.32 ++ lseek64(handle, end - sizeof(tail) - 1.33 + (ntohl(tail.num_blocks) * ntohl(tail.index_size)), 1.34 -+ SEEK_END) < 0) { 1.35 ++ SEEK_SET) < 0) { 1.36 + perror("Reading tail\n"); 1.37 + exit(1); 1.38 + } 1.39 @@ -208,7 +210,7 @@ 1.40 + } 1.41 + data = __be64_to_cpu(offset); 1.42 + write(STDOUT_FILENO, &data, sizeof(data)); 1.43 -+ for (i = 0; i < num_blocks && lseek(handle, offsets[i].offset, SEEK_SET) >= 0; i++) { 1.44 ++ for (i = 0; i < num_blocks && lseek64(handle, offsets[i].offset, SEEK_SET) >= 0; i++) { 1.45 + read(handle, buffer, offsets[i].size); 1.46 + write(STDOUT_FILENO, buffer, offsets[i].size); 1.47 + } 1.48 @@ -224,7 +226,7 @@ 1.49 - 1.50 - currpos = lseek(handle, 0, SEEK_CUR); 1.51 - if (lseek(handle, __be64_to_cpu(offset[0]), SEEK_SET) < 0) { 1.52 -+ if (lseek(handle, offsets[i].offset, SEEK_SET) < 0) { 1.53 ++ if (lseek64(handle, offsets[i].offset, SEEK_SET) < 0) { 1.54 fprintf(stderr, "lseek to %Lu: %s\n", 1.55 - __be64_to_cpu(offset[0]), strerror(errno)); 1.56 + offsets[i].offset, strerror(errno)); 1.57 @@ -254,6 +256,23 @@ 1.58 if (i == 3) { 1.59 fprintf(stderr, 1.60 "Block head:%02X%02X%02X%02X%02X%02X%02X%02X\n", 1.61 +@@ -105,12 +142,12 @@ 1.62 + fprintf(stderr, "Uncomp: unknown error %u\n", i); 1.63 + exit(1); 1.64 + } 1.65 +- if (destlen != ntohl(head.block_size)) { 1.66 +- fprintf(stderr, "Uncomp: bad len %u (%lu not %u)\n", i, 1.67 +- destlen, ntohl(head.block_size)); 1.68 ++ if (destlen != block_size) { 1.69 ++ fprintf(stderr, "Uncomp: bad len %u (%lu not %lu)\n", i, 1.70 ++ destlen, block_size); 1.71 + exit(1); 1.72 + } 1.73 +- write(STDOUT_FILENO, clear_buffer, ntohl(head.block_size)); 1.74 ++ write(STDOUT_FILENO, clear_buffer, block_size); 1.75 + } 1.76 + return 0; 1.77 + } 1.78 @@ -105,12 +140,12 @@ 1.79 fprintf(stderr, "Uncomp: unknown error %u\n", i); 1.80 exit(1);