[Libguestfs] [PATCH 2/2] sparsify: ignore read-only devices
Richard W.M. Jones
rjones at redhat.com
Mon Feb 2 13:19:12 UTC 2015
On Thu, Jan 29, 2015 at 06:54:31PM +0100, Pino Toscano wrote:
> In copy mode, make sure to not zero-free-space devices mounted as
> read-only, as we cannot write to them.
>
> Related to RHBZ#1079625.
> ---
> sparsify/copying.ml | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/sparsify/copying.ml b/sparsify/copying.ml
> index 4c23939..9c2c545 100644
> --- a/sparsify/copying.ml
> +++ b/sparsify/copying.ml
> @@ -233,6 +233,13 @@ You can ignore this warning or change it to a hard failure using the
> with Not_found -> false
> in
>
> + let is_readonly_device mp =
> + let statvfs = g#statvfs mp in
> + let flags = statvfs.G.flag in
> + (* 0x01 is ST_RDONLY in Linux' GNU libc. *)
> + flags <> -1_L && (flags &^ 0x1_L) <> 0_L
> + in
> +
> List.iter (
> fun fs ->
> if not (is_ignored fs) then (
> @@ -250,6 +257,9 @@ You can ignore this warning or change it to a hard failure using the
> if is_readonly_btrfs_snapshot fs "/" then (
> if not quiet then
> printf (f_"Skipping %s, as it is a read-only btrfs snapshot.\n%!") fs;
> + ) else if is_readonly_device "/" then (
> + if not quiet then
> + printf (f_"Skipping %s, as it is a read-only device.\n%!") fs;
> ) else (
> if not quiet then
> printf (f_"Fill free space in %s with zero ...\n%!") fs;
Looks good, ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
More information about the Libguestfs
mailing list