xfs
[Top] [All Lists]

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

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: [PATCH 15/19] mkfs: don't treat files as though they are block devices
From: Jan Tulak <jtulak@xxxxxxxxxx>
Date: Wed, 13 Apr 2016 17:43:15 +0200
Cc: xfs-oss <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <5708811C.5090909@xxxxxxxxxxx>
References: <1458818136-56043-1-git-send-email-jtulak@xxxxxxxxxx> <1458818136-56043-16-git-send-email-jtulak@xxxxxxxxxx> <5706FA7C.7020103@xxxxxxxxxxx> <CACj3i73JEzCj-4kp3=H9mjXCKYgcOUYCOyq-aZSWZFXUih+0MA@xxxxxxxxxxxxxx> <5708811C.5090909@xxxxxxxxxxx>
On Sat, Apr 9, 2016 at 6:12 AM, Eric Sandeen <sandeen@xxxxxxxxxxx> wrote:


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.


But what about this?

case D_NAME:
   xi.dname = getstr(value, &dopts, D_   NAME);

[...]

if (argc - optind > 1) {
   [print error]
} else if (argc - optind == 1) {
   Âdfile = xi.volname = getstr(argv[optind], &dopts, D_NAME);
} else
   Âdfile = xi.dname;â
Â
}

[
â... until the first occurence of dfile]

check_device_type(dfile, &xi.disfile, !dsize, !dfile,
    ÂNflag ? NULL : &xi.dcreat, force_overwrite, "d");
â
âso if there is -d name= and nothing at the end, then dfile contains D_NAME value. If there is a path at the end, then, then no matter about -d name, we have dfile filled with something. So I can't find a way how to have dfile == NULL without omitting both a path as the last argument, and -dname...

The no_name (!dfile) argument is inÂcheck_device_type() for a single reason - raising error on
if (*isfile && (no_size || no_name))

But !string is true only when string==NULL. For an empty string: !"" is 0. So I don't see the reason for no_name argument at all - it seems to confuse, and in current use can be replaced with test to NULL, or !name.

DTTO for xi.logname/xi.rtname.

âCheers,
Janâ

--
<Prev in Thread] Current Thread [Next in Thread>