Specific mime-type for root files
Explain what you would like to see improved
The current mime-type of root files is rather generic
file --mime-type histogram.root
histogram.root: application/octet-stream
respectively can be identified heuristically by it's extension .root via
application/x-root
This obviously leads to false-positives if one wants to associate root files uniquely with
- a) a specific app to open
- b) an icon
Also by judging their role in the scientific data analysis field I believe that they definitely deserve their own mime-type.
Optional: share how it could be improved
A year ago I had already opened a MR at freedesktop.org to officially register a root mime-type.
However, it's not merged yet, because we need your help to create and implement a unique mime-type for future root files first.
Additional
Once root files have their unique mime-type, they could look like this in the file explorers :)

Hi @alexde-dev , first of all thank you for taking the initiative on this.
What does "create and implement a unique mime-type" entail, concretely?
Hi @alexde-dev and @eguiraud,
I guess that, besides the registration of the MIME type, it basically requires an adding an entry to the MIME magic file (typically on /usr/share/mime/magic). Not sure about who manages the distribution of this file, though.
@jalopezg-uc3m that would be freedesktop.org, see the linked MR
I had already started this half a year ago or so; it's just not high priority.
Great to see that there's interest from your side side, even it's not high priority.
Do you know if the first 12 bytes in the .root files could be used as a magic for matching? The root files I reviewed started with only either one of these two chunks:
r o o t
72 6F 6F 74 00 00 ED E7 00 00 00 64
72 6F 6F 74 00 00 F1 68 00 00 00 64
Check file myfile.root ;-) ROOT files are already registered with the file utility (you can check its source), but that is not immediately related to MIME types. Anyway - I'll take care of it!
@alexde-dev see the second table at https://root.cern/doc/master/classTFile.html for what the bytes represent.
Freedesktop.org shared-mime-info is not a mime type registry, IANA is. Preferably, a media-type is registered with IANA first. Someone from ROOT/Cern should register e.g. application/x+cern-root with IANA.
Desktop environments don´t use the file utility, but FDOs smi DB. If one wants root files to be detected properly, a useful match has to be registered with FDO. files match DB and FDOs DB are two completely separate entities.
The match as submitted to FDO orignally is not very useful, as it is too generic:
- The "root" signature must be a offset 0, not in the range 0:64. This would match too many plain ASCII files.
- The binary nature of the
fVersionandfBeginfields can be used to distinguish ROOT files from ASCII files:
fVersionis<major>*10000 + <minor>*100 + <micro> + <large_file:1e6>, thus something very likely < 2 million, and definitely < 16.7 million (2^24). The MSB of fVersion can be assumed to be 0x00 always.fBEGINis also very likely a very small value, in the examples above 0x64, i.e. we have another 2-3 zero bytes. If the first record is guaranteed to be aligned to at least 4 bytes, we can also match withfBEGIN | 0x3 == 0.
Unfortunately, nothing has happened here during the last 2 years. Has anyone from CERN or the ROOT project registered a mime type with IANA?
BTW, the magic match of file is quite sloppy:
$> echo -e 'root\x00' > root.txt ; file root.txt
root.txt: ROOT file
$> file --mime-type ./root.txt
./root.txt: application/octet-stream
It does not even require a non-zero version field, or the existance of the fBEGIN field.
Thanks for the ping, @StefanBruens . We are now preparing the IANA form content, I expect to get the process started next week. Apologies for keeping this open and unaddressed for so long! I will update this issue once we have a decision from IANA, which will include the file magic.