/etc/magic lines for compress

John Campbell jdc at naucse.UUCP
Fri Nov 4 02:02:45 AEST 1988


In article <274 at gsg.UUCP>, lew at gsg (Paul Lwe) writes:
:
:In article <2643 at nuchat.UUCP>, steve at nuchat.UUCP (Steve Nuchia) writes:
:> If you have a file(1) compatible with the one in sysVr3
:> adding the following lines to /etc/magic will make it
:> recognize compressed files.  I was motivated to add this
:> when I imported a bunch of files from BSD systems and the .Zs
:> all got lopped off.
:> 
:> 0	short		40223		compressed data
:> >2	byte		<0200		- %d bits
:> >2	byte		0214		- 12 bits
:> >2	byte		0215		- 13 bits
:> >2	byte		0220		- 16 bits
:> 
:
:I found out on Pyramid the magic value should be represented as:
:
:	017635 instead of 40223
(I don't care how old an "old timer" you are--can you octal freaks really
 see this as byte swapped?  I found the 0x4093, 0x9340 representation much
 clearer. (jdc :-})
:
:apparently this is yet another byte swapping problem.  Maybe all the fields
:in /etc/magic should use byte instead of short?  Otherwise, /etc/magic is not
:portable to other machine.  Change the short to 2 bytes solve the problem:
:
:	0	byte		0037		compressed data
:	>1	byte		0235
:	>2	byte		<0200		- %d bits
:	>2	byte		0214		- 12 bits
:	>2	byte		0215		- 13 bits
:	>2	byte		0220		- 16 bits
:
:By browsing thru the /etc/magic file on the Pyramid, I found a lot of places
:where long and short were used.  If this file is used on other machine like
:Vax it probably will not work properly.  Is there a portable version of
:/etc/magic somewhere?

On my 3b1 (SysV UnixPC box) I found that file(1) itself must be different
than the file(1) on the Pyramid.  I had to use Lew's byte order (which I 
rewrote in hex form) and still the - 12 bits, etc. were not recognized.  
A little hacking and I discovered that (0220 = 0x90) 0xffffff90 would
work.  It appeared that file(1) was sign extending the quantity (byte
in this case) before making the comparison.  (The hint I got was that
everything seemed <0200.)  

So I have a working /etc/magic, but I would guess that it is decidedly
non-portable.  Anyone know more than I about this?
-- 
	John Campbell               ...!arizona!naucse!jdc

	unix?  Sure send me a dozen, all different colors.



More information about the Comp.sources.bugs mailing list