wayne@csri.toronto.edu (Wayne Hayes) (07/05/90)
Well, actually, patch #1 from *me*, someone else has already posted some patches that fix all the warnings I was too lazy to fix. BTW, I think I forgot to mention that LHARC only compiles under 1.5. (Go ahead, prove me wrong. :-) I would also like to make a suggestion about using lharc, maybe even an "official" recommendation if we ever start seriously using lharc for Minix distribution. (It's only about 1/2 as fast as compress, not 1/10th as I reported...) LHARC seems to work best with intermediate sized files, say in the 5-50K range. Larger and the "parse tree" gets too rigid; smaller, you never get good ratios. This means that you get better compression ratios if you turn the regular UNIX convention inside out and make .lzh.tar files rather than .tar.lzh. That is, for the 1.3->1.5 upgrade kit, for example, take the xxx.NN files (which are tar files), untar them, LHARC each one by itself giving "xxx.lzh" files, and then tar these together. This cuts my previous claim that the upgrade kit is 1.6 Meg down to 1.4 Meg, small enough to fit on a single 1.44 Meg floppy (just barely). --- Anyway, as someone mentioned, since Minix doesn't have an ftruncate system call, you need to store the compressed version even if it's longer than the uncompressed version (which only happens with *very* small files, less than 100 bytes, or with already-lharc'd files). Unfortunately my first attempt to fix this didn't work, resulting in a file that claimed to be about 2 gigabytes long and couldn't be removed without "rm -f". Undoubtably this points to some obscure error in Minix's file system to do with seeking and telling and writing, but for now the fix is to fix LHARC. Here is the patch. --- #/bin/sh # A shar archive... # echo x - Makefile sed '/^X/s///' > Makefile << '/' X# lharc makefile for Minix 1.5 XCFLAGS=-F -T. X Xlharc: lharc.s lhio.s lhdir.s lzhuf.s X cc -T. -i -o lharc lharc.s lhio.s lhdir.s lzhuf.s X Xlharc.s : lharc.c Xlhio.s : lhio.c Xlhdir.s : lhdir.c Xlzhuf.s : lzhuf.c / echo x - lharc.c.cdif sed '/^X/s///' > lharc.c.cdif << '/' X*** /usr/posted/lharc.c Wed Jul 4 00:54:23 1990 X--- lharc.c Wed Jul 4 21:05:00 1990 X*************** X*** 1842,1860 **** X hdr->crc = lzhufEncode (fp, nafp, hdr->original_size, X &v_original_size, &v_packed_size, hdr->name); X if (v_packed_size < v_original_size) X! { X next_pos = ftell (nafp); X } X else X! { /* retry by stored method */ X fprintf(stderr, "warning: compressed size GREATER than uncompressed size; however still using\ncompressed version.\n"); X /* fseek (fp, org_pos, SEEK_SET); X fseek (nafp, data_pos, SEEK_SET); X hdr->crc = encode_stored_crc (fp, nafp, hdr->original_size, X &v_original_size, &v_packed_size); X fflush (nafp); X! next_pos = ftell (nafp); X! ftruncate (fileno (nafp), next_pos); X bcopy (LZHUFF0_METHOD, hdr->method, METHOD_TYPE_STRAGE); X */ X } X--- 1842,1861 ---- X hdr->crc = lzhufEncode (fp, nafp, hdr->original_size, X &v_original_size, &v_packed_size, hdr->name); X if (v_packed_size < v_original_size) X! { X next_pos = ftell (nafp); X } X else X! { /* DON'T retry by stored method */ X fprintf(stderr, "warning: compressed size GREATER than uncompressed size; however still using\ncompressed version.\n"); X /* fseek (fp, org_pos, SEEK_SET); X fseek (nafp, data_pos, SEEK_SET); X hdr->crc = encode_stored_crc (fp, nafp, hdr->original_size, X &v_original_size, &v_packed_size); X fflush (nafp); X! */ X! next_pos = ftell (nafp); X! /* ftruncate (fileno (nafp), next_pos); X bcopy (LZHUFF0_METHOD, hdr->method, METHOD_TYPE_STRAGE); X */ X } / echo x - lharc.c.crc sed '/^X/s///' > lharc.c.crc << '/' X29939 49654 lharc.c / echo x - lharc.crcold sed '/^X/s///' > lharc.crcold << '/' X04728 49642 /usr/posted/lharc.c X43355 1662 lharc.c.cdif /