[Top] [All Lists]

[RFC, PATCH 00/15] mkfs: sanitise input parameters

To: xfs@xxxxxxxxxxx
Subject: [RFC, PATCH 00/15] mkfs: sanitise input parameters
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 29 Nov 2013 12:43:35 +1100
Delivered-to: xfs@xxxxxxxxxxx
Hi folks,

This is still a work in progress, but is compelte enough to get
feedback on the general structure. The problem being solved here is
that mkfs does a terrible job of input validation from the command
line, has huge amounts of repeated code in the sub options
processing loops and has many, many unnecessary variable for
tracking simply things like whether a parameter was specified.

This patchset introduces a parameter table structure that is used to
define the parameters and their constraints. Things like minimum and
maximum valid values, default values, conflicting options, etc are
all contained within the table, so all the "policy" is found in a
single place.

This greatly reduces the complexity of the option parsing loop. It
doesn't remove all the complexity (yet) because many of the options
have special cases or more complex conflicts than I've yet added
support for. The idea is, however, that all of the sub-option
parameter setup will eventually end up being implemented as a
generic loop as the parameter structure will hold all the
information about in the input parameters.

To get there, the parameter table still needs more work - it needs
to hold the value/string for the parameter, and we need to reference
those in the code.

The flow on effect of this is that we can remove the many, many
individual variables and start passing the option structures to
functions rather than avoiding using functions because passing so
many variables is messy and nasty. IOWs, it lays the groundwork for
factoring xfs_mkfs.c into something more than a bunch of spagetti...

Anyway, have a look and see what you think about progress so far.

FWIW, the first patch is following up on the multi-disk discussion
Christoph and I had, and the last patch in the series covers all the
issues that arose with "-d file" and treating files like block



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