On Fri, Nov 29, 2013 at 08:12:13AM +1100, Dave Chinner wrote:
> On Thu, Nov 28, 2013 at 09:32:32AM -0600, Eric Sandeen wrote:
> > On 11/28/13, 4:01 AM, Dave Chinner wrote:
> > > On Wed, Nov 27, 2013 at 11:34:35PM -0600, Eric Sandeen wrote:
> > <snip>
> > >> Or maybe just stat() it, and DTRT?
> > >
> > > Well, we need to stat it to make sure that it's a file if "-d file"
> > > is specified, and a block device if it's not. That will prevent this
> > > problem. Every other xfsprogs utility has to be told that it is
> > > being pointed at an image file rather than a block device, so why
> > > should mkfs be any different?
> > The option is there but again I never really knew why. They work
> > fine without -f, at least in general:
> Just like mkfs works fine, *in general*. That doesn't mean they will always
> work, though:
FYI, here's the list of stuff on top of making mkfs detect files and
set the proper flags and avoid direct IO that I found while doing
Other file/blockdev issues fixed:
- use getstr to detect specifying the data device name
- check file/size/name parameters before anything else.
- overwrite checks need to be done before the image file is
opened and potentially truncated.
- blkid_get_topology() should not be called for image files,
so warn when it is called that way.
- zero_old_xfs_structures() emits a spurious error:
"existing superblock read failed: Success"
when it is run on a truncated image file. Don't warn if we
see this problem on an image file.
- Don't issue discards on image files.
- Use fsync() for image files, not BLKFLSBUF in
platform_flush_device() for Linux.
And so now "-d file" is only needed to trigger creation of the
image file, or if you want to truncate the old file away completely