Bug 978302 - mke2fs-J should give a meaningful error when specified type is anything except 'ext{2,3,4}'
Summary: mke2fs-J should give a meaningful error when specified type is anything excep...
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
Depends On:
Blocks: 976299
TreeView+ depends on / blocked
Reported: 2013-06-26 10:14 UTC by Richard W.M. Jones
Modified: 2013-06-26 15:18 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 976299
Last Closed: 2013-06-26 15:18:37 UTC

Attachments (Terms of Use)

Description Richard W.M. Jones 2013-06-26 10:14:05 UTC
+++ This bug was initially created as a clone of Bug #976299 +++

Description of problem:
For example,
mke2fs doesn't support xfs, it should give a meaningful error message when you specified xfs, but not gives ext3 

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. create a disk with xfs
[root]# guestfish -N fsfs
><fs> quit

[root]# eval `guestfish --listen`
[root]# guestfish --remote -x -- -add test1.img
[root]# guestfish --remote -x -- -alloc journalname 50M
[root]# guestfish --remote -x -- -run
[root]# guestfish --remote -- -mke2journal 1024  /dev/sdb
[root]# guestfish --remote -- -mke2fs-J xfs 1024 /dev/sda /dev/sdb
[root]# vfs_type=`guestfish --remote -- -vfs-type /dev/sda`
[root]# echo $vfs_type

Actual results:
Got ext3 type

Expected results:
Give a error message

Additional info:

--- Additional comment from Richard W.M. Jones on 2013-06-26 06:13:27 EDT ---

One line reproducer:

$ guestfish -N part -N part mke2journal 1024 /dev/sda1 : mke2fs-J xfs 1024 /dev/sdb1 /dev/sda1
$ echo $?

The mke2fs-J command should give an error instead of succeeding.

Comment 1 Richard W.M. Jones 2013-06-26 13:27:18 UTC
So the problem here is that we use the -F option to force
mke2fs not to ask any questions.  However it has the unfortunate
side-effect of making mke2fs also ignore bad -t xfs argument.

In virt-rescue:

><rescue> mke2fs -t xfs -b 4096 -J device=/dev/sdb /dev/sda
mke2fs 1.42.5 (29-Jul-2012)
/dev/sda is entire device, not just one partition!
Proceed anyway? (y,n) y

Your mke2fs.conf file does not define the xfs filesystem type.


><rescue> mke2fs -F -t xfs -b 4096 -J device=/dev/sdb /dev/sda
mke2fs 1.42.5 (29-Jul-2012)

Your mke2fs.conf file does not define the xfs filesystem type.
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Adding journal to device /dev/sdb: done
Writing superblocks and filesystem accounting information: done 

The second command creates an ext3 filesystem.

So this is a bug in mke2fs -F option.

Note it also affects the mke2fs API, if you use the forcecreate
argument (which causes -F to be passed to mke2fs).  eg:

><fs> mke2fs /dev/sda1 fstype:xfs forcecreate:true
[no error]


><fs> mke2fs /dev/sda1 fstype:xfs forcecreate:false
libguestfs: error: mke2fs: /dev/sda1: mke2fs 1.42.5 (29-Jul-2012)

Anyhow I think the way I'm actually going to solve this is by
filtering the types allowed so they must match /^ext[234]$/.  The
reason is at the moment we also allow types from the /etc/mke2fs.conf
file, such as "floppy" or "big" which aren't supportable in a
stable API such as libguestfs.

Note You need to log in before you can comment on or make changes to this bug.