From 2a4c46db59932e8012a599e71b0da4529cf5d663 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Tue, 19 Nov 2013 17:40:40 +0100 Subject: [PATCH] optset_parse: Add support for 64bit values This is needed to fix blocktest for dev_t = 64bit. Change-Id: I713e92aaa9a7a0755e212048817fa0f3e6dfe258 --- include/minix/optset.h | 1 + lib/libsys/optset.c | 10 ++++++++++ test/blocktest/blocktest.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/minix/optset.h b/include/minix/optset.h index a7e088122..bd12b6ba4 100644 --- a/include/minix/optset.h +++ b/include/minix/optset.h @@ -4,6 +4,7 @@ typedef enum { OPT_BOOL, OPT_STRING, + OPT_64INT, OPT_INT } optset_type; diff --git a/lib/libsys/optset.c b/lib/libsys/optset.c index be65cfa9e..22a54bdfb 100644 --- a/lib/libsys/optset.c +++ b/lib/libsys/optset.c @@ -33,6 +33,7 @@ int len; */ char *dst; int val; + int64_t val64; switch (entry->os_type) { case OPT_BOOL: @@ -52,6 +53,15 @@ int len; break; + case OPT_64INT: + if (len > 0) + val64 = (uint64_t) strtoull(ptr, NULL, entry->os_val); + else + val64 = 0; + + *((uint64_t *) entry->os_ptr) = val64; + + break; case OPT_INT: if (len > 0) val = (int) strtoul(ptr, NULL, entry->os_val); diff --git a/test/blocktest/blocktest.c b/test/blocktest/blocktest.c index 70c49431d..fee612f52 100644 --- a/test/blocktest/blocktest.c +++ b/test/blocktest/blocktest.c @@ -61,7 +61,7 @@ static int driver_deaths = 0; /* number of restarts that we saw */ /* Options supported by this driver. */ static struct optset optset_table[] = { { "label", OPT_STRING, driver_label, sizeof(driver_label) }, - { "minor", OPT_INT, &driver_minor, 10 }, + { "minor", OPT_64INT, &driver_minor, 10 }, { "rw", OPT_BOOL, &may_write, TRUE }, { "ro", OPT_BOOL, &may_write, FALSE }, { "sector", OPT_INT, §or_size, 10 },