Re: [PATCH 15/19] mkfs: don't treat files as though they are block devices

Eric Sandeen
2016-04-09T04:12:22Z

On 4/8/16 9:58 AM, Jan Tulak wrote:
> This one causes at least one interesting issue:
>
> #mkfs/mkfs.xfs
> Error accessing specified device (null): Bad address
> Usage: mkfs.xfs
> ...
>
> because:
>
> check_device_type(dfile, &xi.disfile, !dsize, !dfile,
> Nflag ? NULL : &xi.dcreat, force_overwrite, "d");
>
> so "dfile" can be NULL, but that function immediately tries to stat it.
>
>
> ​A simple if NULL, then usage() should take care of this...

Well, think hard about that. If dfile == NULL and bails with usage(), then
what is the point of having !dfile as a function argument?

Validation of having a target specified as either -dfile= or as the last argument
should probably happen before the call to check_device_type.

-Eric