tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Making fdisk accept percentages (and modifiers on shell)



Le 24/12/11 20:25, Julian Djamil Fagir a écrit :
Hi,

it might be useful (and specially IS, for me ;) to have fdisk specify
percentages instead of absolute size values.
Thus, the attached patches do exactly that, and they also extend the current
modifiers (MB, GB, cyl) to batch-mode (-s). Then, TB was added (though
unnecessary, but you don't have to use four digit GB sizes).

Any comments about that?
Here we go :)

1 - keep the parsing (parse_partstr) in the "case 's' " block like before, instead of deferring it at a later step (before change_part() ). The sooner you can error out because of argument errors, the better.

2 - no need to strdup(3) optarg if you can do 1).

3 - missing lower bound check on acc in decimal():

if (acc<  0 || acc>  100)
    return -1;

4 - documentation does not look right, it's "cyl/mb/gb/tb" (or "CYL/MB/GB/TB"). "c/m/g/t" are not valid according to the various strncasecmp() in the code.

5 - decimal() and parse_smodifier() have a lot to share, so I am against copy/pasting their code in two different functions. You can merge both, or at least have a common parse_digit() function. This would avoid typo like the one for 3).

6 - you have a copy/paste typo in parse_partstr(), the second "get start" comment should read "get size".

jy


Home | Main Index | Thread Index | Old Index