daemon: mkfs: Use -I option to force mkfs.fat to write a filesystem over a whole device (RHBZ#1039995).

If you use virt-make-fs to create a partitionless FAT-formatted disk
image then currently you will get an error:

$ virt-make-fs --type=fat . /tmp/test.img
'mkfs' (create filesystem) operation failed.
Instead of 'fat', try 'vfat' (long filenames) or 'msdos' (short filenames).
mkfs: fat: /dev/sda: mkfs.fat: Device partition expected, not making filesystem on entire device '/dev/sda' (use -I to override) at /usr/bin/virt-make-fs line 508, <PIPE> line 1.
      ...propagated at /usr/bin/virt-make-fs line 518, <PIPE> line 1.

With this patch, the error goes away and partitionless disks can be
created.
This commit is contained in:
Richard W.M. Jones
2013-12-10 13:45:07 +00:00
parent 1f0e75213b
commit b121015221

View File

@@ -96,6 +96,11 @@ do_mkfs (const char *fstype, const char *device, int blocksize,
ADD_ARG (argv, i, "-O");
}
/* Force mkfs.fat to create a whole disk filesystem (RHBZ#1039995). */
if (STREQ (fstype, "fat") || STREQ (fstype, "vfat") ||
STREQ (fstype, "msdos"))
ADD_ARG (argv, i, "-I");
/* Process blocksize parameter if set. */
if (optargs_bitmask & GUESTFS_MKFS_BLOCKSIZE_BITMASK) {
if (blocksize <= 0 || !is_power_of_2 (blocksize)) {