| diff -ur cdrtools-1.10/mkisofs/mkisofs.c cdrtools-1.10-zisofs/mkisofs/mkisofs.c |
| --- cdrtools-1.10/mkisofs/mkisofs.c Fri Apr 20 08:45:50 2001 |
| +++ cdrtools-1.10-zisofs/mkisofs/mkisofs.c Thu May 3 21:59:56 2001 |
| @@ -565,10 +565,8 @@ |
| '\0', "#", "Set numbers of load sectors", ONE_DASH}, |
| {{"boot-info-table", no_argument, NULL, OPTION_BOOT_INFO_TABLE}, |
| '\0', NULL, "Patch boot image with info table", ONE_DASH}, |
| -#ifdef ERIC_neverdef |
| {{"transparent-compression", no_argument, NULL, 'z'}, |
| 'z', NULL, "Enable transparent compression of files", ONE_DASH}, |
| -#endif |
| #ifdef APPLE_HYB |
| {{"hfs-type", required_argument, NULL, OPTION_HFS_TYPE}, |
| '\0', "TYPE", "Set HFS default TYPE", ONE_DASH}, |
| diff -ur cdrtools-1.10/mkisofs/rock.c cdrtools-1.10-zisofs/mkisofs/rock.c |
| --- cdrtools-1.10/mkisofs/rock.c Tue Jan 23 04:28:34 2001 |
| +++ cdrtools-1.10-zisofs/mkisofs/rock.c Fri May 4 02:34:25 2001 |
| @@ -45,7 +45,7 @@ |
| #define PX_SIZE 36 |
| #define RE_SIZE 4 |
| #define SL_SIZE 20 |
| -#define ZZ_SIZE 15 |
| +#define ZF_SIZE 16 |
| #ifdef APPLE_HYB |
| #define AA_SIZE 14 /* size of Apple extension */ |
| #endif /* APPLE_HYB */ |
| @@ -577,17 +577,24 @@ |
| #ifndef VMS |
| /* |
| * If transparent compression was requested, fill in the correct field |
| - * for this file |
| + * for this file, if (and only if) it is actually a compressed file! |
| + * This relies only on magic number, but it should in general not |
| + * be an issue since if you're using -z odds are most of your |
| + * files are already compressed. |
| + * |
| + * In the future it would be nice if mkisofs actually did the |
| + * compression. |
| */ |
| - if (transparent_compression && |
| - S_ISREG(lstatbuf->st_mode) && |
| - strlen(name) > 3 && |
| - strcmp(name + strlen(name) - 3, ".gZ") == 0) { |
| - FILE *zipfile; |
| + if (transparent_compression && S_ISREG(lstatbuf->st_mode)) { |
| + static const unsigned char zisofs_magic[8] = |
| + { 0x37, 0xE4, 0x53, 0x96, 0xC9, 0xDB, 0xD6, 0x07 }; |
| + FILE *zffile; |
| char *checkname; |
| unsigned int file_size; |
| - unsigned char header[8]; |
| + unsigned char header[16]; |
| int OK_flag; |
| + int blocksize; |
| + int headersize; |
| |
| /* |
| * First open file and verify that the correct algorithm was |
| @@ -596,73 +603,43 @@ |
| file_size = 0; |
| OK_flag = 1; |
| |
| - zipfile = fopen(whole_name, "rb"); |
| - fread(header, 1, sizeof(header), zipfile); |
| + memset(header, 0, sizeof(header)); |
| |
| - /* Check some magic numbers from gzip. */ |
| - if (header[0] != 0x1f || header[1] != 0x8b || header[2] != 8) |
| - OK_flag = 0; |
| - /* Make sure file was blocksized. */ |
| - if (((header[3] & 0x40) == 0)) |
| - OK_flag = 0; |
| - /* OK, now go to the end of the file and get some more info */ |
| - if (OK_flag) { |
| - int status; |
| - |
| - status = (long) lseek(fileno(zipfile), (off_t)(-8), |
| - SEEK_END); |
| - if (status == -1) |
| + zffile = fopen(whole_name, "rb"); |
| + if ( zffile ) { |
| + if ( fread(header, 1, sizeof(header), zffile) != sizeof(header) ) |
| OK_flag = 0; |
| - } |
| - if (OK_flag) { |
| - if (read(fileno(zipfile), (char *) header, |
| - sizeof(header)) != sizeof(header)) { |
| + |
| + /* Check magic number */ |
| + if ( memcmp(header, zisofs_magic, sizeof zisofs_magic) ) |
| OK_flag = 0; |
| - } else { |
| - int blocksize; |
| |
| - blocksize = (header[3] << 8) | header[2]; |
| - file_size = ((unsigned int) header[7] << 24) | |
| - ((unsigned int) header[6] << 16) | |
| - ((unsigned int) header[5] << 8) | |
| - header[4]; |
| -#if 0 |
| - fprintf(stderr, "Blocksize = %d %d\n", |
| - blocksize, file_size); |
| -#endif |
| - if (blocksize != SECTOR_SIZE) |
| - OK_flag = 0; |
| - } |
| - } |
| - fclose(zipfile); |
| - |
| - checkname = strdup(whole_name); |
| - checkname[strlen(whole_name) - 3] = 0; |
| - zipfile = fopen(checkname, "rb"); |
| - if (zipfile) { |
| + /* Get the real size of the file */ |
| + file_size = get_731(header+8); |
| + |
| + /* Get the header size (>> 2) */ |
| + headersize = header[12]; |
| + |
| + /* Get the block size (log2) */ |
| + blocksize = header[13]; |
| + |
| + fclose(zffile); |
| + } else { |
| OK_flag = 0; |
| -#ifdef USE_LIBSCHILY |
| - errmsg( |
| - "Unable to insert transparent compressed file - name conflict\n"); |
| -#else |
| - fprintf(stderr, |
| - "Unable to insert transparent compressed file - name conflict\n"); |
| -#endif |
| - fclose(zipfile); |
| } |
| - free(checkname); |
| - |
| + |
| if (OK_flag) { |
| - if (MAYBE_ADD_CE_ENTRY(ZZ_SIZE)) |
| + if (MAYBE_ADD_CE_ENTRY(ZF_SIZE)) |
| add_CE_entry(); |
| Rock[ipnt++] = 'Z'; |
| - Rock[ipnt++] = 'Z'; |
| - Rock[ipnt++] = ZZ_SIZE; |
| + Rock[ipnt++] = 'F'; |
| + Rock[ipnt++] = ZF_SIZE; |
| Rock[ipnt++] = SU_VERSION; |
| - Rock[ipnt++] = 'g'; /* Identify compression |
| - technique used */ |
| + Rock[ipnt++] = 'p'; /* Algorithm: "paged zlib" */ |
| Rock[ipnt++] = 'z'; |
| - Rock[ipnt++] = 3; |
| + /* 2 bytes for algorithm-specific information */ |
| + Rock[ipnt++] = headersize; |
| + Rock[ipnt++] = blocksize; |
| set_733((char *) Rock + ipnt, file_size); /* Real file size */ |
| ipnt += 8; |
| }; |