[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [file PATCH] Properly detect .vdi (VirtualBox disk image) files



The current test for .vdi files is incorrect.  It tries to detect the
string "<<< Sun xVM VirtualBox Disk Image >>>".  However this string
is just free text and .vdi files often contain different strings (ref: [1]).

The correct test in this patch looks for the magic number at offset
0x40 in the file (ref: [2]).

Example:

Upstream 'file' without the patch on an example file[3]:

$ file ttylinux.vdi 
ttylinux.vdi: data

With the patch:

$ ./src/file -m magic/Magdir ttylinux.vdi 
ttylinux.vdi: VirtualBox Disk Image, major 1, minor 1

Rich.

[1] http://repo.or.cz/w/qemu.git/blob/HEAD:/block/vdi.c#l109
[2] https://forums.virtualbox.org/viewtopic.php?t=8046
[3] https://one-vbox.googlecode.com/svn-history/r117/trunk/remotes/ttylinux.vdi

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org
--- file-5.09.orig/magic/Magdir/virtual	2009-12-25 16:04:30.000000000 +0000
+++ file-5.09/magic/Magdir/virtual	2011-11-22 08:40:58.162840080 +0000
@@ -9,9 +9,9 @@
 # .vhd
 0	string	conectix	Microsoft Disk Image, Virtual Server or Virtual PC
 
-# Sun xVM VirtualBox Disk Image
-# string  <<< Sun xVM VirtualBox Disk Image >>>
+# From: Richard W.M. Jones <rich annexia org>
+# VirtualBox Disk Image
 # .vdi
-0	string	\<\<\<\ Sun\ xVM\ VirtualBox\ Disk	Sun xVM VirtualBox Disk Image
-
-
+0x40    ulelong  0xbeda107f     VirtualBox Disk Image
+>0x44   uleshort >0             \b, major %u
+>0x46   uleshort >0             \b, minor %u

Attachment: pgpbkPL6TFWFK.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]