root icon indicating copy to clipboard operation
root copied to clipboard

Specific mime-type for root files

Open alexde-dev opened this issue 5 years ago • 8 comments

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 :)

Screenshot_20201107_120427 Screenshot_20201107_115034

alexde-dev avatar Nov 07 '20 11:11 alexde-dev

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?

eguiraud avatar Nov 09 '20 10:11 eguiraud

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-git avatar Nov 09 '20 10:11 jalopezg-git

@jalopezg-uc3m that would be freedesktop.org, see the linked MR

eguiraud avatar Nov 09 '20 10:11 eguiraud

I had already started this half a year ago or so; it's just not high priority.

Axel-Naumann avatar Nov 10 '20 07:11 Axel-Naumann

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

alexde-dev avatar Nov 10 '20 10:11 alexde-dev

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!

Axel-Naumann avatar Nov 10 '20 10:11 Axel-Naumann

@alexde-dev see the second table at https://root.cern/doc/master/classTFile.html for what the bytes represent.

eguiraud avatar Nov 10 '20 11:11 eguiraud

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:

  1. The "root" signature must be a offset 0, not in the range 0:64. This would match too many plain ASCII files.
  2. The binary nature of the fVersion and fBegin fields can be used to distinguish ROOT files from ASCII files:
  • fVersion is <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.
  • fBEGIN is 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 with fBEGIN | 0x3 == 0.

StefanBruens avatar Aug 04 '22 21:08 StefanBruens

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.

StefanBruens avatar Apr 05 '23 16:04 StefanBruens

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.

Axel-Naumann avatar Apr 06 '23 09:04 Axel-Naumann