[Libguestfs] [PATCH 2/2] New API: pwrite-device

Richard W.M. Jones rjones at redhat.com
Sun Sep 26 19:00:54 UTC 2010


On Sun, Sep 26, 2010 at 07:55:03PM +0100, Richard W.M. Jones wrote:
> +   [InitPartition, Always, TestOutputList (
> +      [["pwrite_device"; "/dev/sda"; "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; "446"];
> +       ["blockdev_rereadpt"; "/dev/sda"];
> +       ["list_partitions"]], [])],

This test probably deserves some more explanation.

InitPartition creates a single partition (/dev/sda1) for the test
environment.

The test code then zaps the MBR partition table, overwriting the table
and the signature with all zeroes.  This Wikipedia page is a helpful
reference:
https://secure.wikimedia.org/wikipedia/en/wiki/Master_Boot_Record

We then tell the kernel to reread the partition table, and list the
partitions (which, being zapped, we expect to be an empty list).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw




More information about the Libguestfs mailing list