Hi all, I picked up this patch set Dave Chinner wrote back in 2013 to clean mkfs a bit. It is just part of what I want to do, and still work in progress. I updated it to the current codebase (for-next branch) and fixed issues the original set was causing - currently, this set goes through ./check -n quick with the same result, as clean for-next branch. Two changes against the original set are left in separate patches: "mkfs: move spinodes crc check" is just a small cosmetic thing that doesn't fit into the existing patches, but "mkfs fix: handling of files" is a fix for the last patch from Dave about files. I put this fix standalone for now to make sure the changes in it are reviewed. As I'm learning about xfs, I could misunderstood something. :-) Bellow is the original message from Dave: > 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 > devices.... >␣ > Cheers, >␣ > Dave. Cheers, Jan Dave Chinner (15): xfsprogs: use common code for multi-disk detection mkfs: sanitise ftype parameter values. mkfs: Sanitise the superblock feature macros mkfs: validate all input values mkfs: factor boolean option parsing mkfs: validate logarithmic parameters sanely mkfs: structify input parameter passing mkfs: getbool is redundant mkfs: use getnum_checked for all ranged parameters mkfs: add respecification detection to generic parsing mkfs: table based parsing for converted parameters mkfs: merge getnum mkfs: encode conflicts into parsing table mkfs: add string options to generic parsing mkfs: don't treat files as though they are block devices Jan Ťulák (2): mkfs fix: handling of files mkfs: move spinodes crc check include/Makefile | 8 +- include/xfs_mkfs.h | 73 ++ libxfs/init.c | 7 + libxfs/linux.c | 11 +- man/man8/mkfs.xfs.8 | 26 +- mkfs/Makefile | 2 +- mkfs/proto.c | 56 +- mkfs/xfs_mkfs.c | 1873 ++++++++++++++++++++++++++++++--------------------- mkfs/xfs_mkfs.h | 89 --- repair/xfs_repair.c | 45 +- 10 files changed, 1305 insertions(+), 885 deletions(-) create mode 100644 include/xfs_mkfs.h delete mode 100644 mkfs/xfs_mkfs.h -- 2.1.0 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs