[PATCH 0/2] Add pwrite-device API call
These two very simple patches add a pwrite-device API call. I have been conservative and not yet added the equivalent pread-device call, although that could be added in future. The motivation for this is in virt-resize: We need a way to zap the partition table cleanly[1], and obviously parted isn't working out for us[2]. Using this call we can zap MBR and GPT partition tables by overwriting them with zeroes (or zeroes + signature), and I have shown that this works at least for MBR. Although the semantics of pwrite and pwrite-device are not guaranteed full write, they almost certainly do this now and we could add this extra constraint in future. Rich. [1] https://bugzilla.redhat.com/show_bug.cgi?id=633766 [2] http://lists.alioth.debian.org/pipermail/parted-devel/2010-September/003748.... -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
-- 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
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
participants (1)
-
Richard W.M. Jones