sfdisk: fix --bytes

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2015-01-19 12:26:37 +01:00
parent 4a79a8f177
commit 8de07279bb
1 changed files with 6 additions and 4 deletions

View File

@ -1364,7 +1364,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
int main(int argc, char *argv[])
{
const char *outarg = NULL;
int rc = -EINVAL, c, longidx = -1;
int rc = -EINVAL, c, longidx = -1, bytes = 0;
struct sfdisk _sf = {
.partno = -1,
.interactive = isatty(STDIN_FILENO) ? 1 : 0,
@ -1425,8 +1425,6 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
atexit(close_stdout);
sfdisk_init(sf);
while ((c = getopt_long(argc, argv, "aAbcdfghlLo:O:nN:qsTu:vVX:Y:",
longopts, &longidx)) != -1) {
switch(c) {
@ -1523,13 +1521,17 @@ int main(int argc, char *argv[])
sf->noreread = 1;
break;
case OPT_BYTES:
fdisk_set_size_unit(sf->cxt, FDISK_SIZEUNIT_BYTES);
bytes = 1;
break;
default:
usage(stderr);
}
}
sfdisk_init(sf);
if (bytes)
fdisk_set_size_unit(sf->cxt, FDISK_SIZEUNIT_BYTES);
if (outarg)
init_fields(NULL, outarg, NULL);