From 7855959f7cd0d801685f99b2793ca58b50f802c2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 17 Apr 2012 15:03:02 +0100 Subject: resize, sparsify: Add a simple-minded check to stop indisk = outdisk. (cherry picked from commit 84d450210b3ea01de3fe26b2cf1db2b492d77aec) --- resize/resize.ml | 6 ++++++ sparsify/sparsify.ml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/resize/resize.ml b/resize/resize.ml index 675a6e1c..81db30fd 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -187,6 +187,12 @@ read the man page virt-resize(1). | _ -> error "usage is: %s [--options] indisk outdisk" prog in + (* Simple-minded check that the user isn't trying to use the + * same disk for input and output. + *) + if infile = outfile then + error "you cannot use the same disk image for input and output"; + infile, outfile, align_first, alignment, copy_boot_loader, debug, debug_gc, deletes, dryrun, expand, expand_content, extra_partition, format, ignores, diff --git a/sparsify/sparsify.ml b/sparsify/sparsify.ml index cd231ee4..e9db23af 100644 --- a/sparsify/sparsify.ml +++ b/sparsify/sparsify.ml @@ -116,6 +116,12 @@ read the man page virt-sparsify(1). | _ -> error "usage is: %s [--options] indisk outdisk" prog in + (* Simple-minded check that the user isn't trying to use the + * same disk for input and output. + *) + if indisk = outdisk then + error "you cannot use the same disk image for input and output"; + (* The input disk must be an absolute path, so we can store the name * in the overlay disk. *) -- cgit