wok-next rev 10932

fusecloop: add old version support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Aug 26 17:50:10 2011 +0200 (2011-08-26)
parents 149e9a44c474
children 9de4fcf2f70c
files fusecloop/receipt fusecloop/stuff/fusecloop.u
line diff
     1.1 --- a/fusecloop/receipt	Fri Aug 26 13:57:39 2011 +0200
     1.2 +++ b/fusecloop/receipt	Fri Aug 26 17:50:10 2011 +0200
     1.3 @@ -1,11 +1,11 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="fusecloop"
     1.7 -VERSION="0.20.0"
     1.8 +VERSION="0.20.1"
     1.9  CATEGORY="system-tools"
    1.10  SHORT_DESC="Mount cloop image in user space with fuse."
    1.11  MAINTAINER="pascal.bellard@slitaz.org"
    1.12 -TARBALL="$PACKAGE-$VERSION.tar.bz2"
    1.13 +TARBALL="$PACKAGE-$VERSION.tar.gz"
    1.14  WEB_SITE="http://$PACKAGE.sourceforge.net/"
    1.15  WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"
    1.16  DEPENDS="fuse zlib"
    1.17 @@ -17,6 +17,7 @@
    1.18  {
    1.19  	cd $src
    1.20  	sed -i 's/dprintf/d_printf/g' *.h *.c
    1.21 +	patch -p0 < ../stuff/fusecloop.u
    1.22  	./configure --prefix=/usr --infodir=/usr/share/info \
    1.23  	--mandir=/usr/share/man $CONFIGURE_ARGS &&
    1.24  	make
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/fusecloop/stuff/fusecloop.u	Fri Aug 26 17:50:10 2011 +0200
     2.3 @@ -0,0 +1,160 @@
     2.4 +--- compressed_loop.h
     2.5 ++++ compressed_loop.h
     2.6 +@@ -41,6 +41,55 @@
     2.7 + /* data_index (num_blocks 64bit pointers, network order)...      */
     2.8 + /* compressed data (gzip block compressed format)...             */
     2.9 + 
    2.10 ++struct block_info
    2.11 ++{
    2.12 ++	loff_t offset;		/* 64-bit offsets of compressed block */
    2.13 ++	u_int32_t size;		/* 32-bit compressed block size */
    2.14 ++	u_int32_t optidx;	/* 32-bit index number */
    2.15 ++};
    2.16 ++
    2.17 ++static inline char *build_index(struct block_info *offsets, unsigned long n)
    2.18 ++{
    2.19 ++	u_int32_t *ofs32 = (u_int32_t *) offsets;
    2.20 ++	loff_t    *ofs64 = (loff_t *) offsets;
    2.21 ++	if (ofs32[0] == 0) {
    2.22 ++		if (ofs32[2]) { /* ACCELERATED KNOPPIX V1.0 */
    2.23 ++			do { 
    2.24 ++				offsets[n].offset = __be64_to_cpu(offsets[n].offset);
    2.25 ++				offsets[n].size = ntohl(offsets[n].size);
    2.26 ++			} while (n--);
    2.27 ++			return "128BE accelerated knoppix 1.0";
    2.28 ++		}
    2.29 ++		else { /* V2.0 */
    2.30 ++			loff_t last = __be64_to_cpu(ofs64[n+1]);
    2.31 ++			do { 
    2.32 ++				offsets[n].size = last - 
    2.33 ++					(offsets[n].offset = __be64_to_cpu(ofs64[n])); 
    2.34 ++				last = offsets[n].offset;
    2.35 ++			} while (n--);
    2.36 ++			return "64BE v2.0";
    2.37 ++		}
    2.38 ++	}
    2.39 ++	else if (ofs32[1] == 0) { /* V1.0 */
    2.40 ++		loff_t last = __be64_to_cpu(ofs64[n+1]);
    2.41 ++		do { 
    2.42 ++			offsets[n].size = last - 
    2.43 ++				(offsets[n].offset = __le64_to_cpu(ofs64[n])); 
    2.44 ++			last = offsets[n].offset;
    2.45 ++		} while (n--);
    2.46 ++		return "64LE v1.0";
    2.47 ++	}
    2.48 ++	else { /* V0.68 */
    2.49 ++		loff_t last = ntohl(ofs32[n+1]);
    2.50 ++		do { 
    2.51 ++			offsets[n].size = last - 
    2.52 ++				(offsets[n].offset = ntohl(ofs32[n])); 
    2.53 ++			last = offsets[n].offset;
    2.54 ++		} while (n--);
    2.55 ++		return "32BE v0.68";
    2.56 ++	}
    2.57 ++}
    2.58 ++
    2.59 + /* Cloop suspend IOCTL */
    2.60 + #define CLOOP_SUSPEND 0x4C07
    2.61 + 
    2.62 +
    2.63 +--- cloopreader.h
    2.64 ++++ cloopreader.h
    2.65 +@@ -33,7 +33,7 @@
    2.66 +     int numblocks;
    2.67 +     ulong blocksize;
    2.68 + 
    2.69 +-    loff_t* toc; /* Data index */
    2.70 ++    struct block_info *toc; /* Data index */
    2.71 +     size_t tocsize;
    2.72 + 
    2.73 +     unsigned char* cblock;  /* Compressed block */
    2.74 +
    2.75 +--- cloopreader.c
    2.76 ++++ cloopreader.c
    2.77 +@@ -59,10 +59,11 @@
    2.78 + 
    2.79 +     ALLOC(c->pblock,c->blocksize);
    2.80 + 
    2.81 +-    c->tocsize=sizeof *c->toc * (c->numblocks+1); /* One extra address is position of EOF */
    2.82 ++    c->tocsize=sizeof(*c->toc) * c->numblocks;
    2.83 +     ALLOC(c->toc,c->tocsize);
    2.84 + 
    2.85 +     OP(read_all(c->fh,c->toc,c->tocsize));  /* read Data Index */
    2.86 ++    build_index(c->toc, c->numblocks);
    2.87 +     c->cblocksizecur=0;
    2.88 +     c->curblock=-1;
    2.89 +     return 0;
    2.90 +@@ -79,10 +80,10 @@
    2.91 +     if(page>=c->numblocks){errno=EFAULT;return -1;}
    2.92 +     c->curblock=page;
    2.93 + 
    2.94 +-    bprintf("Seeking to 0x%Lx\n",btc(c->toc[page]));
    2.95 +-    OP(lseek(c->fh,btc(c->toc[page]), SEEK_SET)); 
    2.96 ++    bprintf("Seeking to 0x%Lx\n",c->toc[page].offset);
    2.97 ++    OP(lseek(c->fh,c->toc[page].offset, SEEK_SET)); 
    2.98 + 
    2.99 +-    c->cblocksize=btc(c->toc[page+1]) - btc(c->toc[page]);
   2.100 ++    c->cblocksize=c->toc[page].size;
   2.101 +     bprintf("Compressed size=%lu\n",c->cblocksize);
   2.102 +     if(c->cblocksize > c->cblocksizecur){
   2.103 + 	if(c->cblocksizecur)free(c->cblock);
   2.104 +--- extract_compressed_fs.c
   2.105 ++++ extract_compressed_fs.c
   2.106 +@@ -7,6 +7,7 @@
   2.107 + 	struct cloop_head head;
   2.108 + 	unsigned int i;
   2.109 + 	unsigned char *buffer, *clear_buffer;
   2.110 ++	struct block_info *offsets;
   2.111 + 
   2.112 + 	if (argc != 2) {
   2.113 + 		fprintf(stderr, "Need filename\n");
   2.114 +@@ -30,35 +31,34 @@
   2.115 + 	fprintf(stderr, "%u blocks of size %u. Preamble:\n%s\n", 
   2.116 + 		ntohl(head.num_blocks), ntohl(head.block_size), head.preamble);
   2.117 + 
   2.118 ++	i = ntohl(head.num_blocks) * sizeof(*offsets);
   2.119 ++	offsets = malloc(i);
   2.120 ++	if (!offsets || read(handle, offsets, i) != i) {
   2.121 ++		perror("Reading index\n");
   2.122 ++		exit(1);
   2.123 ++	}
   2.124 ++	
   2.125 ++	fprintf(stderr, "Index %s.\n", 
   2.126 ++		build_index(offsets, ntohl(head.num_blocks)));
   2.127 ++	
   2.128 + 	for (i = 0; i < ntohl(head.num_blocks); i++) {
   2.129 +-		int currpos;
   2.130 + 		unsigned long destlen = ntohl(head.block_size);
   2.131 +-		loff_t offset[2];
   2.132 +-		unsigned int size;
   2.133 ++		unsigned int size = offsets[i].size;
   2.134 + 
   2.135 +-		read(handle, &offset, 2*sizeof(loff_t));
   2.136 +-                lseek(handle, -sizeof(loff_t), SEEK_CUR);
   2.137 +-                
   2.138 +-		currpos = lseek(handle, 0, SEEK_CUR);
   2.139 +-		if (lseek(handle, __be64_to_cpu(offset[0]), SEEK_SET) < 0) {
   2.140 ++		if (lseek(handle, offsets[i].offset, SEEK_SET) < 0) {
   2.141 + 			fprintf(stderr, "lseek to %Lu: %s\n",
   2.142 +-				__be64_to_cpu(offset[0]), strerror(errno));
   2.143 ++				offsets[i].offset, strerror(errno));
   2.144 + 			exit(1);
   2.145 + 		}
   2.146 +                 
   2.147 +-                size=__be64_to_cpu(offset[1])-__be64_to_cpu(offset[0]);
   2.148 + 		if (size > ntohl(head.block_size) + ntohl(head.block_size)/1000
   2.149 + 		    + 12 + 4) {
   2.150 + 			fprintf(stderr, 
   2.151 + 				"Size %u for block %u (offset %Lu) too big\n",
   2.152 +-				size, i, __be64_to_cpu(offset[0]));
   2.153 ++				size, i, offsets[i].offset);
   2.154 + 			exit(1);
   2.155 + 		}
   2.156 + 		read(handle, buffer, size);
   2.157 +-		if (lseek(handle, currpos, SEEK_SET) < 0) {
   2.158 +-			perror("seeking");
   2.159 +-			exit(1);
   2.160 +-		}
   2.161 + 
   2.162 + 		fprintf(stderr, "Block %u length %u => %lu\n",
   2.163 + 			i, size, destlen);