wok-current rev 23762
fusecloop, linux-cloop, qemu: multicompressor support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue May 05 11:06:44 2020 +0000 (2020-05-05) |
parents | 36e9a3dcd5de |
children | 299e2fd264d8 |
files | fusecloop/stuff/fusecloop.u linux-cloop/stuff/cloop.u linux64-cloop/stuff/cloop.u ocsinventory-server/receipt ocsinventory/receipt ocsreports/receipt qemu/stuff/cloop.u |
line diff
1.1 --- a/fusecloop/stuff/fusecloop.u Mon May 04 09:05:12 2020 +0000 1.2 +++ b/fusecloop/stuff/fusecloop.u Tue May 05 11:06:44 2020 +0000 1.3 @@ -1809,3 +1809,299 @@ 1.4 } 1.5 flush_index(0); 1.6 return 0; 1.7 +--- compressed_loop.h 1.8 ++++ compressed_loop.h 1.9 +@@ -92,9 +92,8 @@ 1.10 + struct cloop_tail 1.11 + { 1.12 + u_int32_t table_size; 1.13 +- u_int32_t index_size; /* size:4 comp:3 ctrl-c:1 lastlen:24 */ 1.14 ++ u_int32_t index_size; /* size:4 unused:3 ctrl-c:1 lastlen:24 */ 1.15 + #define CLOOP3_INDEX_SIZE(x) ((unsigned int)((x) & 0xF)) 1.16 +-#define CLOOP3_BLOCKS_FLAGS(x) ((unsigned int)((x) & 0x70) >> 4) 1.17 + #define CLOOP3_TRUNCATED(x) ((unsigned int)((x) & 0x80) >> 7) 1.18 + #define CLOOP3_LASTLEN(x) (unsigned int)((x) >> 8) 1.19 + u_int32_t num_blocks; 1.20 +@@ -107,12 +106,12 @@ 1.21 + loff_t offset; /* 64-bit offsets of compressed block */ 1.22 + u_int32_t size; /* 32-bit compressed block size */ 1.23 + u_int32_t flags; /* 32-bit compression flags */ 1.24 +- 1.25 + }; 1.26 + 1.27 +-static inline char *build_index(struct block_info *offsets, unsigned long n, 1.28 +- unsigned long block_size, unsigned global_flags) 1.29 ++static inline char *build_index(struct block_info *offsets, unsigned long n, unsigned long block_size) 1.30 + { 1.31 ++ static char v[sizeof("64BE v4.0a")]; 1.32 ++ u_int32_t flags; 1.33 + u_int32_t *ofs32 = (u_int32_t *) offsets; 1.34 + loff_t *ofs64 = (loff_t *) offsets; 1.35 + 1.36 +@@ -137,8 +136,6 @@ 1.37 + } 1.38 + else { /* V2.0/V4.0 */ 1.39 + loff_t last = CLOOP_BLOCK_OFFSET(__be64_to_cpu(ofs64[n])); 1.40 +- u_int32_t flags; 1.41 +- static char v4[11]; 1.42 + unsigned long i = n; 1.43 + 1.44 + for (flags = 0; n-- ;) { 1.45 +@@ -156,12 +153,7 @@ 1.46 + offsets[i] = offsets[offsets[i].offset]; 1.47 + } 1.48 + } 1.49 +- strcpy(v4, (char *) "64BE v4.0a"); 1.50 +- v4[10] = 'a' + ((flags-1) & 0xF); // compressors used 1.51 +- if (flags > 0x10) { // with links ? 1.52 +- v4[10] += 'A' - 'a'; 1.53 +- } 1.54 +- return v4; 1.55 ++ strcpy(v, (char *) "64BE v4.0a"); 1.56 + } 1.57 + } 1.58 + else if (ofs32[1] == 0 && v3_64 == 0) { /* V1.0 */ 1.59 +@@ -174,44 +166,50 @@ 1.60 + } 1.61 + return (char *) "64LE v1.0"; 1.62 + } 1.63 +- else if (ntohl(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ 1.64 +- loff_t last = ntohl(ofs32[n]); 1.65 +- while (n--) { 1.66 +- offsets[n].size = last - 1.67 +- (offsets[n].offset = ntohl(ofs32[n])); 1.68 +- last = offsets[n].offset; 1.69 +- offsets[n].flags = 0; 1.70 +- } 1.71 +- return (char *) "32BE v0.68"; 1.72 +- } 1.73 +- else { /* V3.0 */ 1.74 ++ else { /* V3.0 or V0.68 */ 1.75 + unsigned long i; 1.76 + loff_t j; 1.77 +- static char v3[11]; 1.78 + 1.79 +- v3_64 = (ofs32[1] == 0) ? 2 : 1; 1.80 +- for (i = n; i-- != 0; ) 1.81 +- offsets[i].size = ntohl(ofs32[i*v3_64]); 1.82 ++ for (i = 0; i < n && ntohl(ofs32[i]) < ntohl(ofs32[i+1]); i++); 1.83 ++ if (i == n && ntohl(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ 1.84 ++ loff_t last = ntohl(ofs32[n]); 1.85 ++ while (n--) { 1.86 ++ offsets[n].size = last - 1.87 ++ (offsets[n].offset = ntohl(ofs32[n])); 1.88 ++ last = offsets[n].offset; 1.89 ++ offsets[n].flags = 0; 1.90 ++ } 1.91 ++ return (char *) "32BE v0.68"; 1.92 ++ } 1.93 ++ 1.94 ++ v3_64 = (ofs32[1] == 0); 1.95 ++ for (i = n; i-- != 0; ) { 1.96 ++ offsets[i].size = ntohl(ofs32[i << v3_64]); 1.97 ++ if (offsets[i].size == 0xFFFFFFFF) { 1.98 ++ offsets[i].size = 0x10000000 | block_size; 1.99 ++ } 1.100 ++ offsets[i].flags = (offsets[i].size >> 28); 1.101 ++ offsets[i].size &= 0x0FFFFFFF; 1.102 ++ } 1.103 + for (i = 0, j = sizeof(struct cloop_head); i < n; i++) { 1.104 + offsets[i].offset = j; 1.105 +- offsets[i].flags = global_flags; 1.106 +- if ((offsets[i].size & 0x80000000) == 0) { 1.107 ++ if (offsets[i].flags < 8) { 1.108 + j += offsets[i].size; 1.109 + } 1.110 +- else if (offsets[i].size == 0xFFFFFFFF) { 1.111 +- offsets[i].flags = CLOOP_COMPRESSOR_NONE; 1.112 +- j += offsets[i].size = block_size; 1.113 +- } 1.114 + } 1.115 + for (i = 0; i < n; i++) { 1.116 +- if (offsets[i].size & 0x80000000) { 1.117 +- offsets[i] = offsets[offsets[i].size & 0x7FFFFFFF]; 1.118 ++ flags |= 1 << offsets[i].flags; 1.119 ++ if (offsets[i].flags >= 8) { 1.120 ++ offsets[i] = offsets[offsets[i].size]; 1.121 + } 1.122 + } 1.123 +- strcpy(v3, (char *) (--v3_64) ? "64BE v3.0a" : "32BE v3.0a"); 1.124 +- v3[10] += global_flags; 1.125 +- return v3; 1.126 ++ strcpy(v, (char *) (v3_64) ? "64BE v3.0a" : "32BE v3.0a"); 1.127 ++ } 1.128 ++ v[10] = 'a' + ((flags-1) & 0xF); // compressors used 1.129 ++ if (flags > 0x10) { // with links ? 1.130 ++ v[10] += 'A' - 'a'; 1.131 + } 1.132 ++ return v; 1.133 + } 1.134 + 1.135 + /* Cloop suspend IOCTL */ 1.136 +--- cloopreader.c 1.137 ++++ cloopreader.c 1.138 +@@ -52,7 +52,7 @@ 1.139 + bfuncinfo("fh=%d",fh); 1.140 + c->fh=fh; 1.141 + struct cloop_head head; 1.142 +- int v4_header_last, flags; 1.143 ++ int v4_header_last; 1.144 + loff_t end; 1.145 + 1.146 + for (v4_header_last=0;;v4_header_last++) { 1.147 +@@ -83,23 +83,21 @@ 1.148 + c->numblocks = ntohl(tail.num_blocks); 1.149 + c->tocsize = sizeof(*c->toc) * c->numblocks; 1.150 + len = ntohl(tail.table_size); 1.151 +- flags = CLOOP3_BLOCKS_FLAGS(ntohl(tail.index_size)); 1.152 + toclen = CLOOP3_INDEX_SIZE(ntohl(tail.index_size)) * c->numblocks; 1.153 + OP(lseek(c->fh, end - sizeof(tail) - len, SEEK_SET)); 1.154 + ALLOC(c->toc, sizeof(*c->toc) * c->numblocks); 1.155 + ALLOC(p,len); 1.156 + OP(read_all(c->fh,p,len)); /* read Data Index */ 1.157 +- if (unpack[flags]((void *)c->toc,&toclen,p,len) != Z_OK) 1.158 ++ if (unpack[CLOOP_COMPRESSOR_ZLIB]((void *)c->toc,&toclen,p,len) != Z_OK) 1.159 + exit(1); 1.160 + free(p); 1.161 + } 1.162 + else { 1.163 +- flags = 0; 1.164 + c->tocsize = sizeof(*c->toc) * c->numblocks; 1.165 + ALLOC(c->toc,c->tocsize); 1.166 + OP(read_all(c->fh,c->toc,c->tocsize)); /* read Data Index */ 1.167 + } 1.168 +- build_index(c->toc, c->numblocks, c->blocksize, flags); 1.169 ++ build_index(c->toc, c->numblocks, c->blocksize); 1.170 + c->cblocksizecur=0; 1.171 + c->curblock=-1; 1.172 + return 0; 1.173 +--- create_compressed_fs.c 1.174 ++++ create_compressed_fs.c 1.175 +@@ -179,7 +179,6 @@ 1.176 + static unsigned long block_size = 0; 1.177 + static void flush_index(int sig) 1.178 + { 1.179 +- static char padding[512]; 1.180 + struct cloop_tail tail; 1.181 + unsigned long len; 1.182 + int flags = 0; 1.183 +@@ -187,24 +186,21 @@ 1.184 + fprintf(stderr, "Write index for %u blocks\n", n); 1.185 + if (block_size >= 0x1000000) lastlen = 0; 1.186 + if (sig) flags = 0x80; 1.187 +- if (compress3 == xz_compress) { 1.188 +- flags |= (CLOOP_COMPRESSOR_XZ << 4); 1.189 +- } 1.190 +- if (compress3 == lz4_compress) { 1.191 +- flags |= (CLOOP_COMPRESSOR_LZ4 << 4); 1.192 +- } 1.193 + tail.index_size = ntohl(sizeof(*block_index) + flags + 256*(lastlen % 0xFFffFF)); 1.194 + tail.num_blocks = ntohl(n); 1.195 + n *= sizeof(*block_index); 1.196 + len = GZIP_MAX_BUFFER(n); 1.197 + compressed = (unsigned char *) realloc(compressed, len); 1.198 +- if (!compressed || compress3(compressed, &len, (unsigned char *) block_index, 1.199 ++#ifdef FIND_BEST_COMPRESSION 1.200 ++ if (!compressed || best_compress(compressed, &len, (unsigned char *) block_index, 1.201 ++#else 1.202 ++ if (!compressed || compress2(compressed, &len, (unsigned char *) block_index, 1.203 ++#endif 1.204 + n, Z_BEST_SPEED) != Z_OK) 1.205 + quit("Index compression failed"); 1.206 + tail.table_size = ntohl(len); 1.207 + pos += len + sizeof(tail); 1.208 + n = pos & 511; 1.209 +- // if (n) write(STDOUT_FILENO, padding, 512 - n); 1.210 + write(STDOUT_FILENO, compressed, len); 1.211 + write(STDOUT_FILENO, &tail, sizeof(tail)); 1.212 + exit(sig != 0); 1.213 +@@ -242,7 +238,7 @@ 1.214 + #endif 1.215 + block_size = atoi(argv[1]); 1.216 + } 1.217 +- if (block_size < 4096) 1.218 ++ if (block_size < 4096 || block_size > 0x0FFFFFFF) 1.219 + block_size = DEFAULT_BLOCKSIZE; 1.220 + fprintf(stderr, "Block size is %lu\n", block_size); 1.221 + zlenmax = block_size + block_size/1000 + 12; 1.222 +@@ -280,7 +276,7 @@ 1.223 + quit("Realloc hash"); 1.224 + } 1.225 + hash[n] = md5sum(uncompressed, len); 1.226 +- j = 0x7FFFFFFF; 1.227 ++ j = 0x0FFFFFFF; 1.228 + if (n < j) 1.229 + j = n; 1.230 + for (i = 0; i < j; i++) { 1.231 +@@ -289,7 +285,7 @@ 1.232 + break; 1.233 + } 1.234 + if (i != j) { 1.235 +- block_index[n] = ntohl(0x80000000 | i); 1.236 ++ block_index[n] = ntohl((CLOOP_COMPRESSOR_LINK >> 28) | i); 1.237 + fprintf(stderr, "Block %u length %lu => duplicate %u\n", 1.238 + n, block_size, i); 1.239 + continue; 1.240 +@@ -299,7 +295,7 @@ 1.241 + if (compress3(compressed, &len, uncompressed, lastlen, 1.242 + Z_BEST_SPEED) != Z_OK || len >= lastlen) { 1.243 + len = lastlen; 1.244 +- block_index[n] = ntohl(0xFFFFFFFF); 1.245 ++ block_index[n] = ntohl((CLOOP_COMPRESSOR_NONE >> 28) | lastlen); 1.246 + write(STDOUT_FILENO, uncompressed, len); 1.247 + } 1.248 + else { 1.249 +--- extract_compressed_fs.c 1.250 ++++ extract_compressed_fs.c 1.251 +@@ -69,9 +69,8 @@ 1.252 + 1.253 + int main(int argc, char *argv[]) 1.254 + { 1.255 +- int flags; 1.256 + struct cloop_head head; 1.257 +- unsigned int i, v4_header_last, global_flags; 1.258 ++ unsigned int i, v4_header_last; 1.259 + unsigned long n, len; 1.260 + uLongf ulen; 1.261 + loff_t end; 1.262 +@@ -128,12 +127,6 @@ 1.263 + table_size = ntohl(tail.table_size); 1.264 + table = malloc(table_size); 1.265 + len = num_blocks * CLOOP3_INDEX_SIZE(ntohl(tail.index_size)); 1.266 +- global_flags = CLOOP3_BLOCKS_FLAGS(ntohl(tail.index_size)); 1.267 +- if (global_flags > CLOOP_COMPRESSOR_MAX) { 1.268 +- fprintf(stderr, "Unsupported compression %d\n", 1.269 +- global_flags); 1.270 +- exit(1); 1.271 +- } 1.272 + ulen = num_blocks * sizeof(*offsets); 1.273 + offsets = malloc(ulen); 1.274 + if (!table || !offsets || !buffer || !clear_buffer) { 1.275 +@@ -144,16 +137,15 @@ 1.276 + perror("Reading index\n"); 1.277 + exit(1); 1.278 + } 1.279 +- err = unpack[global_flags]((void *) offsets, &ulen, table, table_size); 1.280 ++ err = unpack[CLOOP_COMPRESSOR_ZLIB]((void *) offsets, &ulen, table, table_size); 1.281 + if (err != Z_OK) { 1.282 + fprintf(stderr, "Unpack %s index error %d\n", 1.283 +- packnames[global_flags],err); 1.284 ++ packnames[CLOOP_COMPRESSOR_ZLIB],err); 1.285 + exit(1); 1.286 + } 1.287 + free(table); 1.288 + } 1.289 + else { 1.290 +- global_flags = 0; 1.291 + len = num_blocks * sizeof(*offsets); 1.292 + offsets = malloc(len); 1.293 + if (v4_header_last) { 1.294 +@@ -182,7 +174,7 @@ 1.295 + exit(0); 1.296 + } 1.297 + #endif 1.298 +- fprintf(stderr, "Index %s.\n", build_index(offsets, num_blocks, block_size, global_flags)); 1.299 ++ fprintf(stderr, "Index %s.\n", build_index(offsets, num_blocks, block_size)); 1.300 + 1.301 + #if 1 1.302 + if (getenv("CLOOP_TABLE") != NULL) {
2.1 --- a/linux-cloop/stuff/cloop.u Mon May 04 09:05:12 2020 +0000 2.2 +++ b/linux-cloop/stuff/cloop.u Tue May 05 11:06:44 2020 +0000 2.3 @@ -1373,3 +1373,178 @@ 2.4 } 2.5 return 0; 2.6 init_out_dealloc: 2.7 +--- cloop.h 2.8 ++++ cloop.h 2.9 +@@ -86,11 +86,8 @@ 2.10 + struct cloop_tail 2.11 + { 2.12 + u_int32_t table_size; 2.13 +- u_int32_t index_size; /* size:4 comp:3 ctrl-c:1 lastlen:24 */ 2.14 ++ u_int32_t index_size; /* size:4 unused:3 ctrl-c:1 lastlen:24 */ 2.15 + #define CLOOP3_INDEX_SIZE(x) ((unsigned int)((x) & 0xF)) 2.16 +-#define CLOOP3_BLOCKS_FLAGS(x) ((unsigned int)((x) & 0x70) >> 4) 2.17 +-#define CLOOP3_TRUNCATED(x) ((unsigned int)((x) & 0x80) >> 7) 2.18 +-#define CLOOP3_LASTLEN(x) (unsigned int)((x) >> 8) 2.19 + u_int32_t num_blocks; 2.20 + }; 2.21 + 2.22 +@@ -104,8 +101,10 @@ 2.23 + }; 2.24 + 2.25 + static inline char *build_index(struct block_info *offsets, unsigned long n, 2.26 +- unsigned long block_size, unsigned global_flags) 2.27 ++ unsigned long block_size) 2.28 + { 2.29 ++ static char v[11]; 2.30 ++ u_int32_t flags = 0; 2.31 + u_int32_t *ofs32 = (u_int32_t *) offsets; 2.32 + loff_t *ofs64 = (loff_t *) offsets; 2.33 + 2.34 +@@ -130,8 +129,6 @@ 2.35 + } 2.36 + else { /* V2.0/V4.0 */ 2.37 + loff_t last = CLOOP_BLOCK_OFFSET(__be64_to_cpu(ofs64[n])); 2.38 +- u_int32_t flags; 2.39 +- static char v4[11]; 2.40 + unsigned long i = n; 2.41 + 2.42 + for (flags = 0; n-- ;) { 2.43 +@@ -149,12 +146,7 @@ 2.44 + offsets[i] = offsets[offsets[i].offset]; 2.45 + } 2.46 + } 2.47 +- strcpy(v4, (char *) "64BE v4.0a"); 2.48 +- v4[10] = 'a' + ((flags-1) & 0xF); // compressors used 2.49 +- if (flags > 0x10) { // with links ? 2.50 +- v4[10] += 'A' - 'a'; 2.51 +- } 2.52 +- return v4; 2.53 ++ strcpy(v, (char *) "64BE v4.0a"); 2.54 + } 2.55 + } 2.56 + else if (ofs32[1] == 0 && v3_64 == 0) { /* V1.0 */ 2.57 +@@ -170,7 +162,6 @@ 2.58 + else { /* V3.0 or V0.68 */ 2.59 + unsigned long i; 2.60 + loff_t j; 2.61 +- static char v3[11]; 2.62 + 2.63 + for (i = 0; i < n && ntohl(ofs32[i]) < ntohl(ofs32[i+1]); i++); 2.64 + if (i == n && ntohl(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ 2.65 +@@ -185,28 +176,33 @@ 2.66 + } 2.67 + 2.68 + v3_64 = (ofs32[1] == 0); 2.69 +- for (i = n; i-- != 0; ) 2.70 ++ for (i = n; i-- != 0; ) { 2.71 + offsets[i].size = ntohl(ofs32[i << v3_64]); 2.72 +- for (i = 0, j = sizeof(struct cloop_head); i < n; i++) { 2.73 +- offsets[i].offset = j; 2.74 +- offsets[i].flags = global_flags; 2.75 + if (offsets[i].size == 0xFFFFFFFF) { 2.76 +- offsets[i].flags = CLOOP_COMPRESSOR_NONE; 2.77 +- offsets[i].size = block_size; 2.78 ++ offsets[i].size = 0x10000000 | block_size; 2.79 + } 2.80 +- if ((offsets[i].size & 0x80000000) == 0) { 2.81 ++ offsets[i].flags = (offsets[i].size >> 28); 2.82 ++ offsets[i].size &= 0x0FFFFFFF; 2.83 ++ } 2.84 ++ for (i = 0, j = sizeof(struct cloop_head); i < n; i++) { 2.85 ++ offsets[i].offset = j; 2.86 ++ if (offsets[i].flags < 8) { 2.87 + j += offsets[i].size; 2.88 + } 2.89 + } 2.90 + for (i = 0; i < n; i++) { 2.91 +- if (offsets[i].size & 0x80000000) { 2.92 +- offsets[i] = offsets[offsets[i].size & 0x7FFFFFFF]; 2.93 ++ flags |= 1 << offsets[i].flags; 2.94 ++ if (offsets[i].flags >= 8) { 2.95 ++ offsets[i] = offsets[offsets[i].size]; 2.96 + } 2.97 + } 2.98 +- strcpy(v3, (char *) (v3_64) ? "64BE v3.0a" : "32BE v3.0a"); 2.99 +- v3[10] += global_flags; 2.100 +- return v3; 2.101 ++ strcpy(v, (char *) (v3_64) ? "64BE v3.0a" : "32BE v3.0a"); 2.102 ++ } 2.103 ++ v[10] = 'a' + ((flags-1) & 0xF); // compressors used 2.104 ++ if (flags > 0x10) { // with links ? 2.105 ++ v[10] += 'A' - 'a'; 2.106 + } 2.107 ++ return v; 2.108 + } 2.109 + 2.110 + /* Cloop suspend IOCTL */ 2.111 +--- cloop.c 2.112 ++++ cloop.c 2.113 +@@ -542,7 +542,7 @@ 2.114 + const unsigned int header_size = sizeof(struct cloop_head); 2.115 + unsigned int i, total_offsets=0; 2.116 + loff_t fs_read_position = 0, header_pos[2]; 2.117 +- int flags, isblkdev, bytes_read, error = 0; 2.118 ++ int isblkdev, bytes_read, error = 0; 2.119 + if (clo->suspended) return error; 2.120 + #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) 2.121 + inode = file->f_dentry->d_inode; 2.122 +@@ -698,18 +698,12 @@ 2.123 + error=-EBADF; goto error_release; 2.124 + } 2.125 + len = CLOOP3_INDEX_SIZE(ntohl(tail.index_size)) * total_offsets; 2.126 +- flags = CLOOP3_BLOCKS_FLAGS(ntohl(tail.index_size)); 2.127 +-// May 3 19:45:20 (none) user.info kernel: cloop: uncompress(clo=e0a78000, block_ptrs=e0c9c000, &len(1440)=ddc05e6c, zbuf=e0c9f000, zlen=43, flag=0) 2.128 +-printk(KERN_INFO "%s: uncompress(clo=%p, block_ptrs=%p, &len(%ld)=%p, zbuf=%p, zlen=%ld, flag=%d)\n", cloop_name, 2.129 +- clo, clo->block_ptrs, len, &len, zbuf, zlen, flags); 2.130 +- ret = uncompress(clo, (void *) clo->block_ptrs, &len, zbuf, zlen, flags); 2.131 +-// May 3 19:45:20 (none) user.alert kernel: BUG: unable to handle kernel NULL pointer dereference at (null) 2.132 +-printk(KERN_INFO "%s: uncompressed !\n", cloop_name); 2.133 ++ ret = uncompress(clo, (void *) clo->block_ptrs, &len, zbuf, zlen, CLOOP_COMPRESSOR_ZLIB); 2.134 + cloop_free(zbuf, zlen); 2.135 + if (ret != 0) 2.136 + { 2.137 +- printk(KERN_ERR "%s: decompression error %i uncompressing index, flags %u\n", 2.138 +- cloop_name, ret, flags); 2.139 ++ printk(KERN_ERR "%s: decompression error %i uncompressing index\n", 2.140 ++ cloop_name, ret); 2.141 + error=-EBADF; goto error_release; 2.142 + } 2.143 + } 2.144 +@@ -722,7 +716,6 @@ 2.145 + else 2.146 + { 2.147 + unsigned int n, total_bytes; 2.148 +- flags = 0; 2.149 + clo->block_ptrs = cloop_malloc(sizeof(struct block_info) * total_offsets); 2.150 + if (!clo->block_ptrs) 2.151 + { 2.152 +@@ -761,7 +754,7 @@ 2.153 + } 2.154 + { 2.155 + int i; 2.156 +- char *version = build_index(clo->block_ptrs, clo->head.num_blocks, clo->head.block_size, flags); 2.157 ++ char *version = build_index(clo->block_ptrs, clo->head.num_blocks, clo->head.block_size); 2.158 + clo->largest_block = 0; 2.159 + for (i = 0; i < clo->head.num_blocks; i++) 2.160 + if (clo->block_ptrs[i].size > clo->largest_block) 2.161 +@@ -769,9 +762,6 @@ 2.162 + printk(KERN_INFO "%s: %s: %s: %u blocks, %u bytes/block, largest block is %lu bytes.\n", 2.163 + cloop_name, clo->underlying_filename, version, clo->head.num_blocks, 2.164 + clo->head.block_size, clo->largest_block); 2.165 +- } 2.166 +- { 2.167 +- int i; 2.168 + clo->num_buffered_blocks = (buffers > 0 && clo->head.block_size >= 512) ? 2.169 + (buffers / clo->head.block_size) : 1; 2.170 + clo->buffered_blocknum = cloop_malloc(clo->num_buffered_blocks * sizeof (u_int32_t)); 2.171 +@@ -874,6 +864,10 @@ 2.172 + cloop_free(clo->block_ptrs, sizeof(struct block_info) * total_offsets); 2.173 + clo->block_ptrs=NULL; 2.174 + error_release: 2.175 ++#if (defined(CONFIG_ZLIB_INFLATE) || defined(CONFIG_ZLIB_INFLATE_MODULE)) 2.176 ++ zlib_inflateEnd(&clo->zstream); 2.177 ++ if(clo->zstream.workspace) { cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); clo->zstream.workspace = NULL; } 2.178 ++#endif 2.179 + if(bbuf) cloop_free(bbuf, clo->underlying_blksize); 2.180 + if(clo->underlying_filename) { kfree(clo->underlying_filename); clo->underlying_filename=NULL; } 2.181 + clo->backing_file=NULL;
3.1 --- a/linux64-cloop/stuff/cloop.u Mon May 04 09:05:12 2020 +0000 3.2 +++ b/linux64-cloop/stuff/cloop.u Tue May 05 11:06:44 2020 +0000 3.3 @@ -1373,3 +1373,178 @@ 3.4 } 3.5 return 0; 3.6 init_out_dealloc: 3.7 +--- cloop.h 3.8 ++++ cloop.h 3.9 +@@ -86,11 +86,8 @@ 3.10 + struct cloop_tail 3.11 + { 3.12 + u_int32_t table_size; 3.13 +- u_int32_t index_size; /* size:4 comp:3 ctrl-c:1 lastlen:24 */ 3.14 ++ u_int32_t index_size; /* size:4 unused:3 ctrl-c:1 lastlen:24 */ 3.15 + #define CLOOP3_INDEX_SIZE(x) ((unsigned int)((x) & 0xF)) 3.16 +-#define CLOOP3_BLOCKS_FLAGS(x) ((unsigned int)((x) & 0x70) >> 4) 3.17 +-#define CLOOP3_TRUNCATED(x) ((unsigned int)((x) & 0x80) >> 7) 3.18 +-#define CLOOP3_LASTLEN(x) (unsigned int)((x) >> 8) 3.19 + u_int32_t num_blocks; 3.20 + }; 3.21 + 3.22 +@@ -104,8 +101,10 @@ 3.23 + }; 3.24 + 3.25 + static inline char *build_index(struct block_info *offsets, unsigned long n, 3.26 +- unsigned long block_size, unsigned global_flags) 3.27 ++ unsigned long block_size) 3.28 + { 3.29 ++ static char v[11]; 3.30 ++ u_int32_t flags = 0; 3.31 + u_int32_t *ofs32 = (u_int32_t *) offsets; 3.32 + loff_t *ofs64 = (loff_t *) offsets; 3.33 + 3.34 +@@ -130,8 +129,6 @@ 3.35 + } 3.36 + else { /* V2.0/V4.0 */ 3.37 + loff_t last = CLOOP_BLOCK_OFFSET(__be64_to_cpu(ofs64[n])); 3.38 +- u_int32_t flags; 3.39 +- static char v4[11]; 3.40 + unsigned long i = n; 3.41 + 3.42 + for (flags = 0; n-- ;) { 3.43 +@@ -149,12 +146,7 @@ 3.44 + offsets[i] = offsets[offsets[i].offset]; 3.45 + } 3.46 + } 3.47 +- strcpy(v4, (char *) "64BE v4.0a"); 3.48 +- v4[10] = 'a' + ((flags-1) & 0xF); // compressors used 3.49 +- if (flags > 0x10) { // with links ? 3.50 +- v4[10] += 'A' - 'a'; 3.51 +- } 3.52 +- return v4; 3.53 ++ strcpy(v, (char *) "64BE v4.0a"); 3.54 + } 3.55 + } 3.56 + else if (ofs32[1] == 0 && v3_64 == 0) { /* V1.0 */ 3.57 +@@ -170,7 +162,6 @@ 3.58 + else { /* V3.0 or V0.68 */ 3.59 + unsigned long i; 3.60 + loff_t j; 3.61 +- static char v3[11]; 3.62 + 3.63 + for (i = 0; i < n && ntohl(ofs32[i]) < ntohl(ofs32[i+1]); i++); 3.64 + if (i == n && ntohl(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ 3.65 +@@ -185,28 +176,33 @@ 3.66 + } 3.67 + 3.68 + v3_64 = (ofs32[1] == 0); 3.69 +- for (i = n; i-- != 0; ) 3.70 ++ for (i = n; i-- != 0; ) { 3.71 + offsets[i].size = ntohl(ofs32[i << v3_64]); 3.72 +- for (i = 0, j = sizeof(struct cloop_head); i < n; i++) { 3.73 +- offsets[i].offset = j; 3.74 +- offsets[i].flags = global_flags; 3.75 + if (offsets[i].size == 0xFFFFFFFF) { 3.76 +- offsets[i].flags = CLOOP_COMPRESSOR_NONE; 3.77 +- offsets[i].size = block_size; 3.78 ++ offsets[i].size = 0x10000000 | block_size; 3.79 + } 3.80 +- if ((offsets[i].size & 0x80000000) == 0) { 3.81 ++ offsets[i].flags = (offsets[i].size >> 28); 3.82 ++ offsets[i].size &= 0x0FFFFFFF; 3.83 ++ } 3.84 ++ for (i = 0, j = sizeof(struct cloop_head); i < n; i++) { 3.85 ++ offsets[i].offset = j; 3.86 ++ if (offsets[i].flags < 8) { 3.87 + j += offsets[i].size; 3.88 + } 3.89 + } 3.90 + for (i = 0; i < n; i++) { 3.91 +- if (offsets[i].size & 0x80000000) { 3.92 +- offsets[i] = offsets[offsets[i].size & 0x7FFFFFFF]; 3.93 ++ flags |= 1 << offsets[i].flags; 3.94 ++ if (offsets[i].flags >= 8) { 3.95 ++ offsets[i] = offsets[offsets[i].size]; 3.96 + } 3.97 + } 3.98 +- strcpy(v3, (char *) (v3_64) ? "64BE v3.0a" : "32BE v3.0a"); 3.99 +- v3[10] += global_flags; 3.100 +- return v3; 3.101 ++ strcpy(v, (char *) (v3_64) ? "64BE v3.0a" : "32BE v3.0a"); 3.102 ++ } 3.103 ++ v[10] = 'a' + ((flags-1) & 0xF); // compressors used 3.104 ++ if (flags > 0x10) { // with links ? 3.105 ++ v[10] += 'A' - 'a'; 3.106 + } 3.107 ++ return v; 3.108 + } 3.109 + 3.110 + /* Cloop suspend IOCTL */ 3.111 +--- cloop.c 3.112 ++++ cloop.c 3.113 +@@ -542,7 +542,7 @@ 3.114 + const unsigned int header_size = sizeof(struct cloop_head); 3.115 + unsigned int i, total_offsets=0; 3.116 + loff_t fs_read_position = 0, header_pos[2]; 3.117 +- int flags, isblkdev, bytes_read, error = 0; 3.118 ++ int isblkdev, bytes_read, error = 0; 3.119 + if (clo->suspended) return error; 3.120 + #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) 3.121 + inode = file->f_dentry->d_inode; 3.122 +@@ -698,18 +698,12 @@ 3.123 + error=-EBADF; goto error_release; 3.124 + } 3.125 + len = CLOOP3_INDEX_SIZE(ntohl(tail.index_size)) * total_offsets; 3.126 +- flags = CLOOP3_BLOCKS_FLAGS(ntohl(tail.index_size)); 3.127 +-// May 3 19:45:20 (none) user.info kernel: cloop: uncompress(clo=e0a78000, block_ptrs=e0c9c000, &len(1440)=ddc05e6c, zbuf=e0c9f000, zlen=43, flag=0) 3.128 +-printk(KERN_INFO "%s: uncompress(clo=%p, block_ptrs=%p, &len(%ld)=%p, zbuf=%p, zlen=%ld, flag=%d)\n", cloop_name, 3.129 +- clo, clo->block_ptrs, len, &len, zbuf, zlen, flags); 3.130 +- ret = uncompress(clo, (void *) clo->block_ptrs, &len, zbuf, zlen, flags); 3.131 +-// May 3 19:45:20 (none) user.alert kernel: BUG: unable to handle kernel NULL pointer dereference at (null) 3.132 +-printk(KERN_INFO "%s: uncompressed !\n", cloop_name); 3.133 ++ ret = uncompress(clo, (void *) clo->block_ptrs, &len, zbuf, zlen, CLOOP_COMPRESSOR_ZLIB); 3.134 + cloop_free(zbuf, zlen); 3.135 + if (ret != 0) 3.136 + { 3.137 +- printk(KERN_ERR "%s: decompression error %i uncompressing index, flags %u\n", 3.138 +- cloop_name, ret, flags); 3.139 ++ printk(KERN_ERR "%s: decompression error %i uncompressing index\n", 3.140 ++ cloop_name, ret); 3.141 + error=-EBADF; goto error_release; 3.142 + } 3.143 + } 3.144 +@@ -722,7 +716,6 @@ 3.145 + else 3.146 + { 3.147 + unsigned int n, total_bytes; 3.148 +- flags = 0; 3.149 + clo->block_ptrs = cloop_malloc(sizeof(struct block_info) * total_offsets); 3.150 + if (!clo->block_ptrs) 3.151 + { 3.152 +@@ -761,7 +754,7 @@ 3.153 + } 3.154 + { 3.155 + int i; 3.156 +- char *version = build_index(clo->block_ptrs, clo->head.num_blocks, clo->head.block_size, flags); 3.157 ++ char *version = build_index(clo->block_ptrs, clo->head.num_blocks, clo->head.block_size); 3.158 + clo->largest_block = 0; 3.159 + for (i = 0; i < clo->head.num_blocks; i++) 3.160 + if (clo->block_ptrs[i].size > clo->largest_block) 3.161 +@@ -769,9 +762,6 @@ 3.162 + printk(KERN_INFO "%s: %s: %s: %u blocks, %u bytes/block, largest block is %lu bytes.\n", 3.163 + cloop_name, clo->underlying_filename, version, clo->head.num_blocks, 3.164 + clo->head.block_size, clo->largest_block); 3.165 +- } 3.166 +- { 3.167 +- int i; 3.168 + clo->num_buffered_blocks = (buffers > 0 && clo->head.block_size >= 512) ? 3.169 + (buffers / clo->head.block_size) : 1; 3.170 + clo->buffered_blocknum = cloop_malloc(clo->num_buffered_blocks * sizeof (u_int32_t)); 3.171 +@@ -874,6 +864,10 @@ 3.172 + cloop_free(clo->block_ptrs, sizeof(struct block_info) * total_offsets); 3.173 + clo->block_ptrs=NULL; 3.174 + error_release: 3.175 ++#if (defined(CONFIG_ZLIB_INFLATE) || defined(CONFIG_ZLIB_INFLATE_MODULE)) 3.176 ++ zlib_inflateEnd(&clo->zstream); 3.177 ++ if(clo->zstream.workspace) { cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); clo->zstream.workspace = NULL; } 3.178 ++#endif 3.179 + if(bbuf) cloop_free(bbuf, clo->underlying_blksize); 3.180 + if(clo->underlying_filename) { kfree(clo->underlying_filename); clo->underlying_filename=NULL; } 3.181 + clo->backing_file=NULL;
4.1 --- a/ocsinventory-server/receipt Mon May 04 09:05:12 2020 +0000 4.2 +++ b/ocsinventory-server/receipt Tue May 05 11:06:44 2020 +0000 4.3 @@ -7,7 +7,7 @@ 4.4 MAINTAINER="pascal.bellard@slitaz.org" 4.5 LICENSE="GPL2" 4.6 SOURCE="OCSNG_UNIX_SERVER" 4.7 -WEB_SITE="http://www.ocsinventory-ng.org/index.php?page=English" 4.8 +WEB_SITE="https://www.ocsinventory-ng.org/index.php?page=English" 4.9 WANTED="ocsinventory" 4.10 4.11 DEPENDS="apache php-apache mysql perl perl-xml-simple perl-compress-raw-zlib
5.1 --- a/ocsinventory/receipt Mon May 04 09:05:12 2020 +0000 5.2 +++ b/ocsinventory/receipt Tue May 05 11:06:44 2020 +0000 5.3 @@ -8,7 +8,7 @@ 5.4 LICENSE="GPL2" 5.5 SOURCE="OCSNG_UNIX_SERVER" 5.6 TARBALL="$SOURCE-$VERSION.tar.gz" 5.7 -WEB_SITE="http://www.ocsinventory-ng.org/" 5.8 +WEB_SITE="https://www.ocsinventory-ng.org/" 5.9 WGET_URL="https://launchpad.net/ocsinventory-server/stable-${VERSION%.*}/$VERSION/+download/$TARBALL" 5.10 TAGS="system administration" 5.11
6.1 --- a/ocsreports/receipt Mon May 04 09:05:12 2020 +0000 6.2 +++ b/ocsreports/receipt Tue May 05 11:06:44 2020 +0000 6.3 @@ -8,7 +8,7 @@ 6.4 LICENSE="GPL2" 6.5 WANTED="ocsinventory" 6.6 SOURCE="OCSNG_UNIX_SERVER" 6.7 -WEB_SITE="http://www.ocsinventory-ng.org/" 6.8 +WEB_SITE="https://www.ocsinventory-ng.org/" 6.9 TAGS="system administration" 6.10 6.11 DEPENDS="php-apache php-mysql mysql"
7.1 --- a/qemu/stuff/cloop.u Mon May 04 09:05:12 2020 +0000 7.2 +++ b/qemu/stuff/cloop.u Tue May 05 11:06:44 2020 +0000 7.3 @@ -402,3 +402,128 @@ 7.4 -qcow.o-libs := -lz 7.5 +qcow.o-libs := -lz -llzma 7.6 linux-aio.o-libs := -laio 7.7 +--- block/cloop.c 7.8 ++++ block/cloop.c 7.9 +@@ -48,7 +48,6 @@ 7.10 + } cloop_tail; 7.11 + 7.12 + #define CLOOP3_INDEX_SIZE(x) ((unsigned int)((x) & 0xF)) 7.13 +-#define CLOOP3_BLOCKS_FLAGS(x) ((unsigned int)((x) & 0x70) >> 4) 7.14 + 7.15 + typedef struct block_info { 7.16 + uint64_t offset; /* 64-bit offsets of compressed block */ 7.17 +@@ -57,7 +56,7 @@ 7.18 + } block_info; 7.19 + 7.20 + static inline int build_index(struct block_info *offsets, unsigned long n, 7.21 +- unsigned long block_size, unsigned global_flags) 7.22 ++ unsigned long block_size) 7.23 + { 7.24 + uint32_t *ofs32 = (uint32_t *) offsets; 7.25 + loff_t *ofs64 = (loff_t *) offsets; 7.26 +@@ -118,42 +117,44 @@ 7.27 + offsets[n].flags = 0; 7.28 + } 7.29 + } 7.30 +- else if (be32_to_cpu(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ 7.31 +- loff_t last = be32_to_cpu(ofs32[n]); 7.32 +- while (n--) { 7.33 +- offsets[n].size = last - 7.34 +- (offsets[n].offset = be32_to_cpu(ofs32[n])); 7.35 +- if (offsets[n].size > 2 * MAX_BLOCK_SIZE) 7.36 +- return n+1; 7.37 +- last = offsets[n].offset; 7.38 +- offsets[n].flags = 0; 7.39 +- } 7.40 +- } 7.41 +- else { /* V3.0 */ 7.42 ++ else { /* V3.0 or V0.68 */ 7.43 + unsigned long i; 7.44 + loff_t j; 7.45 + 7.46 +- v3_64 = (ofs32[1] == 0) ? 2 : 1; 7.47 ++ for (i = 0; i < n && be32_to_cpu(ofs32[i]) < be32_to_cpu(ofs32[i+1]); i++); 7.48 ++ if (i == n && be32_to_cpu(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ 7.49 ++ loff_t last = be32_to_cpu(ofs32[n]); 7.50 ++ while (n--) { 7.51 ++ offsets[n].size = last - 7.52 ++ (offsets[n].offset = be32_to_cpu(ofs32[n])); 7.53 ++ if (offsets[n].size > 2 * MAX_BLOCK_SIZE) 7.54 ++ return n+1; 7.55 ++ last = offsets[n].offset; 7.56 ++ offsets[n].flags = 0; 7.57 ++ } 7.58 ++ return 0; 7.59 ++ } 7.60 ++ 7.61 ++ v3_64 = (ofs32[1] == 0); 7.62 + for (i = n; i-- > 0; ) { 7.63 +- offsets[i].size = be32_to_cpu(ofs32[i*v3_64]); 7.64 +- if ((offsets[i].size & 0x80000000) == 0 && 7.65 +- offsets[i].size > 2 * MAX_BLOCK_SIZE) 7.66 ++ offsets[i].size = be32_to_cpu(ofs32[i << v3_64]); 7.67 ++ if (offsets[i].size == 0xFFFFFFFF) { 7.68 ++ offsets[i].size = 0x10000000 | block_size; 7.69 ++ } 7.70 ++ offsets[i].flags = (offsets[i].size >> 28); 7.71 ++ offsets[i].size &= 0x0FFFFFFF; 7.72 ++ if (offsets[i].size > 2 * MAX_BLOCK_SIZE) 7.73 + return i+1; 7.74 + } 7.75 + for (i = 0, j = 128 + 4 + 4; i < n; i++) { 7.76 + offsets[i].offset = j; 7.77 +- offsets[i].flags = global_flags; 7.78 +- if (offsets[i].size == 0xFFFFFFFF) { 7.79 +- offsets[i].flags = CLOOP_COMPRESSOR_NONE; 7.80 +- offsets[i].size = block_size; 7.81 +- } 7.82 +- if ((offsets[i].size & 0x80000000) == 0) { 7.83 ++ if (offsets[i].flags < 8) { 7.84 + j += offsets[i].size; 7.85 + } 7.86 + } 7.87 + for (i = 0; i < n; i++) { 7.88 +- if (offsets[i].size & 0x80000000) { 7.89 +- offsets[i] = offsets[offsets[i].size & 0x7FFFFFFF]; 7.90 ++ if (offsets[i].flags >= 8) { 7.91 ++ offsets[i] = offsets[offsets[i].size]; 7.92 + } 7.93 + } 7.94 + } 7.95 +@@ -170,7 +171,6 @@ 7.96 + uint8_t *compressed_block; 7.97 + uint8_t *uncompressed_block; 7.98 + z_stream zstream; 7.99 +- int global_flags; 7.100 + } BDRVCloopState; 7.101 + 7.102 + static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename) 7.103 +@@ -305,7 +305,6 @@ 7.104 + } 7.105 + len = be32_to_cpu(tail.table_size); 7.106 + toclen = CLOOP3_INDEX_SIZE(be32_to_cpu(tail.index_size)) * s->n_blocks; 7.107 +- s->global_flags = CLOOP3_BLOCKS_FLAGS(be32_to_cpu(tail.index_size)); 7.108 + 7.109 + s->offsets = g_malloc(offsets_size); 7.110 + p = g_malloc(len); 7.111 +@@ -316,9 +315,9 @@ 7.112 + } 7.113 + s->zstream.next_in = p; 7.114 + s->zstream.avail_in = len; 7.115 +- s->zstream.next_out = s->offsets; 7.116 ++ s->zstream.next_out = (void *) s->offsets; 7.117 + s->zstream.avail_out = toclen; 7.118 +- if (cloop_unpack(s, s->global_flags) == 0) { 7.119 ++ if (cloop_unpack(s, CLOOP_COMPRESSOR_ZLIB) == 0) { 7.120 + ret = -EINVAL; 7.121 + goto fail; 7.122 + } 7.123 +@@ -342,7 +341,7 @@ 7.124 + goto fail; 7.125 + } 7.126 + } 7.127 +- ret = build_index(s->offsets, s->n_blocks, s->block_size, s->global_flags); 7.128 ++ ret = build_index(s->offsets, s->n_blocks, s->block_size); 7.129 + if (ret) { 7.130 + error_setg(errp, "invalid compressed block size at index %u, " 7.131 + "image file is corrupt", ret-1);