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

Bastien Nocera <[email protected]>
Newsgroups gmane.linux.xdg.devel
Message-ID <[email protected]>
On Fri, 2018-02-23 at 23:39 -0800, Kip Warner wrote:
> 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.

No, it wouldn't make sense. They have very different use cases and
restrictions. In shared-mime-info:
- mime-types don't have to have a magic associated
- and mime-types have globs associated
- the magic length is limited to avoid seeking through huge files
- descriptions are translated, acronyms can be split-off and expanded
- mime-types have inheritance

There's probably others, but that's already a good chunk of the
problems we'd encounter if we used file's database.
_______________________________________________
xdg mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/xdg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.