file(1) / magic(5) database vs shared-mime-info database

Kip Warner kip at thevertigo.com
Sat Feb 24 07:39:06 UTC 2018


Hey list,

Unless I'm misunderstanding things, it seems to me as though typical
GNU typical distros seem to ship two different systems for determining
a file's magic. 

There is the older file(1) / libmagic / magic(5) mechanism. One can
test it via running file(1) on a particular file and it will identify
it and can also provide the MIME type.

The second way is via /usr/share/mime/packages/<mypackage>.xml
mechanism as described by the fd.o shared-mime-info-spec. Typical
desktop shells like Gnome's Nautilus, Xfce's Thunar, pcmanfm, etc.,
seem to identify files via this way.

The amount of redundant work in specifying file magic patterns for both
systems is substantial considering how many different types of files
there are out there in the wild. I am assuming, but I don't know this
for certain, but the latter's
/usr/share/mime/packages/freedesktop.org.xml might have been initially
generated from file(1)'s upstream magic source database (ships as
libmagic-mgc on my distro).

Ironically neither one of these two mechanisms seem to communicate with
each other. If the second mechanism is intended to superannuate the
first, would it not make sense to provide an fd.o replacement for
file(1) which queries the system's shared-mime-info database instead? I
would think this should be trivial to implement.

Yours truly,

-- 
Kip Warner | Senior Software Engineer
OpenPGP signed/encrypted mail preferred
https://www.cartesiantheatre.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/xdg/attachments/20180223/706e0567/attachment.sig>


More information about the xdg mailing list