On Thu, Feb 16, 2012 at 05:59:24PM +0800, Wanlong Gao
wrote:> we wipe the filesystem signatures from device before do mkfs,
> since we can't trust mkfs can remove the filesystem signature
absolutely.
>
> Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
> ---
> daemon/mkfs.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/daemon/mkfs.c b/daemon/mkfs.c
> index 5475582..19224ec 100644
> --- a/daemon/mkfs.c
> +++ b/daemon/mkfs.c
> @@ -181,6 +181,15 @@ do_mkfs_opts (const char *fstype, const char *device,
int blocksize,
> ADD_ARG (argv, i, device);
> ADD_ARG (argv, i, NULL);
>
> + /* we wipe the filesystem signatures from device before do mkfs,
> + * since we can't trust mkfs can remove the filesystem signature
absolutely.
> + */
> + if (do_wipefs (device)) {
You should test do_wipefs () == -1 here.
> + reply_with_error ("%s: %s: %s", fstype, device, err);
Calling reply_with_error will cause an error to be sent twice (once
from do_wipefs, once here), and you'll lose protocol synchronization.
In any case, I'm doubtful that this patch is useful. If callers want
to wipe the filesystem before doing mkfs, they can just call wipefs
themselves. It sounds like this will just slow down mkfs and make it
more likely to fail.
Rich.
--
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/