Bug 64845 - MIME type for raw disk images
Summary: MIME type for raw disk images
Status: RESOLVED FIXED
Alias: None
Product: shared-mime-info
Classification: Unclassified
Component: freedesktop.org.xml (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Shared Mime Info group
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-22 02:22 UTC by David Zeuthen (not reading bugmail)
Modified: 2013-07-26 20:15 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch (1004 bytes, patch)
2013-05-22 02:23 UTC, David Zeuthen (not reading bugmail)
Details | Splinter Review
Updated patch (3.28 KB, patch)
2013-07-26 19:55 UTC, David Zeuthen (not reading bugmail)
Details | Splinter Review
Patch v3 (3.30 KB, patch)
2013-07-26 20:10 UTC, David Zeuthen (not reading bugmail)
Details | Splinter Review

Description David Zeuthen (not reading bugmail) 2013-05-22 02:22:00 UTC
It would be useful [0] to have a MIME type for identifying raw disk images. By their very nature we can't sniff anything so we have to rely on things like file extensions to identify them. Proposing to use the extensions .raw-disk-image (because being precise is good and verbosity isn't a big factor here) and .img (because it's already used for disk images).

[0] : obvious use case: OS vendor provides a web app where users pick the OS to download. In the end the browser returns the file VendorOS-V42-x86_64.raw-disk-image. Once downloaded the web browser then launches the "Disk Image Copier" application (after user confirmation etc) which, when launched, assists the user in picking the device the image should be written to
Comment 1 David Zeuthen (not reading bugmail) 2013-05-22 02:23:46 UTC
Created attachment 79634 [details] [review]
Patch

Here's a patch that does this. Thanks for considering.
Comment 2 David Zeuthen (not reading bugmail) 2013-05-22 02:26:43 UTC
Btw, I've already implemented most of the functionality in Disks for this:

 https://git.gnome.org/browse/gnome-disk-utility/commit/?id=55ceb75042cb22a041847278aa3aaec9d044b729

With this MIME type, all I really need to add to Disks is a .desktop file with something along these lines

 _Name=Disk Image Copier
 Exec=gnome-disks --restore-disk-image %U
 Icon=drive-removable-media
 MimeType=application/x-cd-image;application/x-raw-disk-image;
Comment 3 David Zeuthen (not reading bugmail) 2013-07-10 18:45:38 UTC
Comment on attachment 79634 [details] [review]
Patch

The original patch is now obsolete as we also want to support compressed disk images. The changes I'd like to see are these

 https://git.gnome.org/browse/gnome-disk-utility/tree/data/gdu-mimetypes.xml

If you think this is a good idea, I'll prepare a patch post-haste. Thanks!
Comment 4 Bastien Nocera 2013-07-11 14:50:37 UTC
Comment on attachment 79634 [details] [review]
Patch

Review of attachment 79634 [details] [review]:
-----------------------------------------------------------------

::: freedesktop.org.xml.in
@@ +1475,5 @@
>      <glob pattern="*.dmg"/>
>    </mime-type>
> +  <mime-type type="application/x-raw-disk-image">
> +    <_comment>raw disk image</_comment>
> +    <glob pattern="*.img"/>

Could that be a parent of the application/x-cd-image mime-type?
Can we have test cases for this?

And can you please update the git-formatted patch with your latest g-d-u changes?

Please see the HACKING file for details about the test suite.
Comment 5 David Zeuthen (not reading bugmail) 2013-07-11 17:40:23 UTC
(In reply to comment #4)
> Comment on attachment 79634 [details] [review] [review]
> Patch
> 
> Review of attachment 79634 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: freedesktop.org.xml.in
> @@ +1475,5 @@
> >      <glob pattern="*.dmg"/>
> >    </mime-type>
> > +  <mime-type type="application/x-raw-disk-image">
> > +    <_comment>raw disk image</_comment>
> > +    <glob pattern="*.img"/>
> 
> Could that be a parent of the application/x-cd-image mime-type?

What are the implications of doing this? IOW, what will it break.

> Can we have test cases for this?
> 
> And can you please update the git-formatted patch with your latest g-d-u
> changes?
> 
> Please see the HACKING file for details about the test suite.

Will do.
Comment 6 Bastien Nocera 2013-07-12 08:25:01 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > Comment on attachment 79634 [details] [review] [review] [review]
> > Patch
> > 
> > Review of attachment 79634 [details] [review] [review] [review]:
> > -----------------------------------------------------------------
> > 
> > ::: freedesktop.org.xml.in
> > @@ +1475,5 @@
> > >      <glob pattern="*.dmg"/>
> > >    </mime-type>
> > > +  <mime-type type="application/x-raw-disk-image">
> > > +    <_comment>raw disk image</_comment>
> > > +    <glob pattern="*.img"/>
> > 
> > Could that be a parent of the application/x-cd-image mime-type?
> 
> What are the implications of doing this? IOW, what will it break.

Nothing should break. It means that g-d-u would show ISO images as being something you can dd to a USB disk as well for example, but still having a separate description.

> > Can we have test cases for this?
> > 
> > And can you please update the git-formatted patch with your latest g-d-u
> > changes?
> > 
> > Please see the HACKING file for details about the test suite.
> 
> Will do.

Note that the generic icon name is wrong. There's a small list of icons at the top of the freedesktop.org.xml.in file that are allowed. Icon themes should gracefully fallback if they can't find an exactly matching icon.

Install xmllint and run "make check" (as part of the test suite as well), it should show the errors.
Comment 7 David Zeuthen (not reading bugmail) 2013-07-26 19:53:20 UTC
Sorry for the delay, my Fedora box stopped working and I've only just got hold of another one.

(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > Comment on attachment 79634 [details] [review] [review] [review] [review]
> > > Patch
> > > 
> > > Review of attachment 79634 [details] [review] [review] [review] [review]:
> > > -----------------------------------------------------------------
> > > 
> > > ::: freedesktop.org.xml.in
> > > @@ +1475,5 @@
> > > >      <glob pattern="*.dmg"/>
> > > >    </mime-type>
> > > > +  <mime-type type="application/x-raw-disk-image">
> > > > +    <_comment>raw disk image</_comment>
> > > > +    <glob pattern="*.img"/>
> > > 
> > > Could that be a parent of the application/x-cd-image mime-type?
> > 
> > What are the implications of doing this? IOW, what will it break.
> 
> Nothing should break. It means that g-d-u would show ISO images as being
> something you can dd to a USB disk as well for example, but still having a
> separate description.

Done.

> 
> > > Can we have test cases for this?
> > > 
> > > And can you please update the git-formatted patch with your latest g-d-u
> > > changes?
> > > 
> > > Please see the HACKING file for details about the test suite.
> > 
> > Will do.

Done.

> Note that the generic icon name is wrong. There's a small list of icons at
> the top of the freedesktop.org.xml.in file that are allowed. Icon themes
> should gracefully fallback if they can't find an exactly matching icon.

OK. I'v removed the <generic-icon> tags. Will file a bug against gnome-icon-theme for the icon association (just like for application/x-cd-image).

> Install xmllint and run "make check" (as part of the test suite as well), it
> should show the errors.

Done.
Comment 8 David Zeuthen (not reading bugmail) 2013-07-26 19:55:05 UTC
Created attachment 83054 [details] [review]
Updated patch

Here's an updated patch with the changes you requested. Please take another look! Thanks and Cheers!
Comment 9 David Zeuthen (not reading bugmail) 2013-07-26 20:10:42 UTC
Created attachment 83057 [details] [review]
Patch v3

Sorry, I uploaded the wrong patch file missing the third file in the added lines in tests/list. The test suite passes with this one.
Comment 10 Bastien Nocera 2013-07-26 20:15:09 UTC
Thanks for the patch!

commit 33bce05a5fed6ca8d85ff4c7e0205c9a1ed32e25
Author: David Zeuthen <zeuthen@gmail.com>
Date:   Fri Jul 26 12:51:17 2013 -0700

    Add MIME types for raw disk images
    
    https://bugs.freedesktop.org/show_bug.cgi?id=64845


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.