wok rev 10936

fusecloop: fix index convertion
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 27 17:16:27 2011 +0200 (2011-08-27)
parents 65b7fa14f14f
children f462b780444d
files fusecloop/stuff/fusecloop.u
line diff
     1.1 --- a/fusecloop/stuff/fusecloop.u	Sat Aug 27 13:32:15 2011 +0200
     1.2 +++ b/fusecloop/stuff/fusecloop.u	Sat Aug 27 17:16:27 2011 +0200
     1.3 @@ -150,7 +150,7 @@
     1.4   		exit(1);
     1.5   	}
     1.6   
     1.7 -@@ -24,44 +27,77 @@
     1.8 +@@ -24,44 +27,76 @@
     1.9   		exit(1);
    1.10   	}
    1.11   
    1.12 @@ -197,18 +197,17 @@
    1.13  +	fprintf(stderr, "Index %s.\n", build_index(offsets, num_blocks));
    1.14  +	
    1.15  +	if (argc > 2) {
    1.16 -+		loff_t offset;
    1.17 -+		int delta = ((num_blocks + 1) * sizeof(offset)) +
    1.18 -+			sizeof(head) - offsets[0].offset;
    1.19 ++		loff_t data, offset = ((num_blocks + 1) * sizeof(offset)) + sizeof(head);
    1.20  +		
    1.21  +		strcpy(head.preamble, CLOOP_PREAMBLE);
    1.22  +		write(STDOUT_FILENO, &head, sizeof(head));
    1.23  +		for (i = 0; i < num_blocks; i++) {
    1.24 -+			offset = __be64_to_cpu(delta + offsets[i].offset); 
    1.25 -+			write(STDOUT_FILENO, &offset, sizeof(offset));
    1.26 ++			data = __be64_to_cpu(offset);
    1.27 ++			write(STDOUT_FILENO, &data, sizeof(data));
    1.28 ++			offset += offsets[i].size;
    1.29  +		}
    1.30 -+		offset = __be64_to_cpu(delta + offsets[num_blocks-1].offset + offsets[num_blocks-1].size); 
    1.31 -+		write(STDOUT_FILENO, &offset, sizeof(offset));
    1.32 ++		data = __be64_to_cpu(offset);
    1.33 ++		write(STDOUT_FILENO, &data, sizeof(data));
    1.34  +		for (i = 0; i < num_blocks && lseek(handle, offsets[i].offset, SEEK_SET) >= 0; i++) {
    1.35  +			read(handle, buffer, offsets[i].size);
    1.36  +			write(STDOUT_FILENO, buffer, offsets[i].size);
    1.37 @@ -255,7 +254,7 @@
    1.38   		if (i == 3) {
    1.39   			fprintf(stderr,
    1.40   				"Block head:%02X%02X%02X%02X%02X%02X%02X%02X\n",
    1.41 -@@ -105,12 +141,12 @@
    1.42 +@@ -105,12 +140,12 @@
    1.43   			fprintf(stderr, "Uncomp: unknown error %u\n", i);
    1.44   			exit(1);
    1.45   		}