Is /etc/magic machine independent?

Guy Harris guy at auspex.auspex.com
Thu Apr 11 04:18:46 AEST 1991


>Is file's magic number database (/etc/magic) machine independant
>or must you have a different version for big and little endian
>machines?

"string" entries are machine-independent.  "short" and "long" entries
are machine-dependent.  It would be nice if 1) there were "cstring"
entries, which would look like "string" entries except that they could
include C-style escapes, e.g.

	0	cstring		\037\036	packed data
	0	cstring		\377\037	compacted data
	0	cstring		\037\235	compressed data,
	>2	byte&0x80	>0		block compressed,
	>2	byte&0x1f	x		%d bits
	0	cstring		\032\001	Compiled Terminfo Entry

(the "byte&0x80" and "byte&0x1f" are Sun enhancements; "file" should be
taught to support them as well - Sun's "file" supports C-style strings
with "string", which wasn't really the right thing to do, as it means
any string containing backslashes has to escape the backslases, e.g.

	0	string		\\begindata	Andrew Toolkit document

) and 2) there were "beshort", "belong", "leshort", and "lelong"
entries, which would be for "short" and "long" quantities to be
interpreted as big-endian and little-endian values, rather than being
interpreted in the native byte order.



More information about the Comp.unix.questions mailing list