4 ms·
The magic file (man magic / man file) is a neat one to read. On my Mac, this is located in /usr/share/file/magic/ while I recall on a unix distribution I worke
by shagie 2y ago
The magic file (man magic / man file) is a neat one to read. On my Mac, this is located in /usr/share/file/magic/ while I recall on a unix distribution I worked on it was /etc/magic
The file itself has a format that can test a file and identify it (and possibly more useful information) that is read by the file command.
# Various dictionary images used by OpenFirware FORTH environment
0 lelong 0xe1a00000
>8 lelong 0xe1a00000
# skip raspberry pi kernel image kernel7.img by checking for positive text length
>>24 lelong >0 ARM OpenFirmware FORTH Dictionary,
>>>24 lelong x Text length: %d bytes,
>>>28 lelong x Data length: %d bytes,
>>>32 lelong x Text Relocation Table length: %d bytes,
>>>36 lelong x Data Relocation Table length: %d bytes,
>>>40 lelong x Entry Point: %#08X,
>>>44 lelong x BSS length: %d bytes
- chrismorgan 2y agoOn Arch, per `file`: /usr/share/file/misc/magic.mgc: magic binary file for file(1) cmd (version 20) (little endian) Per magic(5), it could also be “a directory of source text magic pattern fragment files in /usr/share/file/misc/magic”. The original sources are mirrored in <https://github.com/file/file/tree/master/magic/Magdir https://github.com/file/file/tree/master/magic/Magdir>. The identification of the magic.mgc file itself comes from <https://github.com/file/file/blob/0fa0ffd15ff17d798e2f985447af47ab8c3440fb/magic/Magdir/magic#L84-L91 https://github.com/file/file/blob/0fa0ffd15ff17d798e2f985447...>.