[libvirt] [PATCH] fs: Add proper switch to create filesystem with overwrite

Erik Skultety eskultet at redhat.com
Wed Nov 16 08:18:21 UTC 2016


On Tue, Nov 15, 2016 at 03:37:02PM -0500, John Ferlan wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1366460
> 
> When using the --overwrite switch on a pool-build or pool-create, the
> The mkfs.ext{2|3|4} commands use mke2fs which requires using the '-F' switch
> in order to force overwriting the current filesystem on the whole disk.
> 
> Likewise, the mkfs.vfat command uses mkfs.fat which requires using the '-I'
> switch in order to force overwriting the current filesystem on the whole disk.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/storage/storage_backend_fs.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
> index 6c8bae2..de0e8d5 100644
> --- a/src/storage/storage_backend_fs.c
> +++ b/src/storage/storage_backend_fs.c
> @@ -712,9 +712,17 @@ virStorageBackendExecuteMKFS(const char *device,
>  
>      cmd = virCommandNewArgList(MKFS, "-t", format, NULL);
>  
> -    /* use the force, otherwise mkfs.xfs won't overwrite existing fs */
> +    /* use the force, otherwise mkfs.xfs won't overwrite existing fs.
> +     * Similarly mkfs.ext2, mkfs.ext3, and mkfs.ext4 require supplying -F
> +     * and mkfs.vfat uses -I */
>      if (STREQ(format, "xfs"))
>          virCommandAddArg(cmd, "-f");
> +    else if (STREQ(format, "ext2") ||
> +             STREQ(format, "ext3") ||
> +             STREQ(format, "ext4"))
> +        virCommandAddArg(cmd, "-F");
> +    else if (STREQ(format, "vfat"))
> +        virCommandAddArg(cmd, "-I");
>  
>      virCommandAddArg(cmd, device);

I'm wondering what about mkfs.btrfs -f..I'm just being curious.

ACK

Erik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161116/91b337a9/attachment-0001.sig>


More information about the libvir-list mailing list