Date: Tue, 26 Oct 2010 21:23:56 +0000 (UTC) From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r214402 - in stable/8/sbin/geom: class/cache class/eli class/journal class/mirror class/nop class/sched class/stripe class/virstor core Message-ID: <201010262123.o9QLNutG071309@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pjd Date: Tue Oct 26 21:23:55 2010 New Revision: 214402 URL: http://svn.freebsd.org/changeset/base/214402 Log: - Make it possible for default value to be const. - Default number is now also a string. Modified: stable/8/sbin/geom/class/cache/geom_cache.c stable/8/sbin/geom/class/eli/geom_eli.c stable/8/sbin/geom/class/journal/geom_journal.c stable/8/sbin/geom/class/mirror/geom_mirror.c stable/8/sbin/geom/class/nop/geom_nop.c stable/8/sbin/geom/class/sched/geom_sched.c stable/8/sbin/geom/class/stripe/geom_stripe.c stable/8/sbin/geom/class/virstor/geom_virstor.c stable/8/sbin/geom/core/geom.c Modified: stable/8/sbin/geom/class/cache/geom_cache.c ============================================================================== --- stable/8/sbin/geom/class/cache/geom_cache.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/cache/geom_cache.c Tue Oct 26 21:23:55 2010 (r214402) @@ -42,10 +42,8 @@ __FBSDID("$FreeBSD$"); uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_CACHE_VERSION; -static intmax_t blocksize_label = 65536; -static intmax_t size_label = 100; -static intmax_t blocksize_configure = 0; -static intmax_t size_configure = 0; +#define GCACHE_BLOCKSIZE "65536" +#define GCACHE_SIZE "100" static void cache_main(struct gctl_req *req, unsigned flags); static void cache_clear(struct gctl_req *req); @@ -58,16 +56,16 @@ struct g_command class_commands[] = { }, { "configure", G_FLAG_VERBOSE, NULL, { - { 'b', "blocksize", &blocksize_configure, G_TYPE_NUMBER }, - { 's', "size", &size_configure, G_TYPE_NUMBER }, + { 'b', "blocksize", "0", G_TYPE_NUMBER }, + { 's', "size", "0", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-v] [-b blocksize] [-s size] name" }, { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, { - { 'b', "blocksize", &blocksize_label, G_TYPE_NUMBER }, - { 's', "size", &size_label, G_TYPE_NUMBER }, + { 'b', "blocksize", GCACHE_BLOCKSIZE, G_TYPE_NUMBER }, + { 's', "size", GCACHE_SIZE, G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-v] [-b blocksize] [-s size] name prov" @@ -84,8 +82,8 @@ struct g_command class_commands[] = { }, { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, cache_main, { - { 'b', "blocksize", &blocksize_label, G_TYPE_NUMBER }, - { 's', "size", &size_label, G_TYPE_NUMBER }, + { 'b', "blocksize", GCACHE_BLOCKSIZE, G_TYPE_NUMBER }, + { 's', "size", GCACHE_SIZE, G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-v] [-b blocksize] [-s size] name prov" Modified: stable/8/sbin/geom/class/eli/geom_eli.c ============================================================================== --- stable/8/sbin/geom/class/eli/geom_eli.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/eli/geom_eli.c Tue Oct 26 21:23:55 2010 (r214402) @@ -55,15 +55,7 @@ uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_ELI_VERSION; #define GELI_BACKUP_DIR "/var/backups/" - -static char aalgo[] = "none"; -static char ealgo[] = "aes"; -static intmax_t keylen = 0; -static intmax_t keyno = -1; -static intmax_t iterations = -1; -static intmax_t sectorsize = 0; -static char keyfile[] = "", newkeyfile[] = ""; -static char backupfile[] = ""; +#define GELI_ENC_ALGO "aes" static void eli_main(struct gctl_req *req, unsigned flags); static void eli_init(struct gctl_req *req); @@ -101,30 +93,30 @@ static int eli_backup_create(struct gctl struct g_command class_commands[] = { { "init", G_FLAG_VERBOSE, eli_main, { - { 'a', "aalgo", aalgo, G_TYPE_STRING }, + { 'a', "aalgo", "none", G_TYPE_STRING }, { 'b', "boot", NULL, G_TYPE_BOOL }, - { 'B', "backupfile", backupfile, G_TYPE_STRING }, - { 'e', "ealgo", ealgo, G_TYPE_STRING }, - { 'i', "iterations", &iterations, G_TYPE_NUMBER }, - { 'K', "newkeyfile", newkeyfile, G_TYPE_STRING }, - { 'l', "keylen", &keylen, G_TYPE_NUMBER }, + { 'B', "backupfile", "", G_TYPE_STRING }, + { 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING }, + { 'i', "iterations", "-1", G_TYPE_NUMBER }, + { 'K', "newkeyfile", "", G_TYPE_STRING }, + { 'l', "keylen", "0", G_TYPE_NUMBER }, { 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, - { 's', "sectorsize", §orsize, G_TYPE_NUMBER }, + { 's', "sectorsize", "0", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-K newkeyfile] [-s sectorsize] prov" }, { "label", G_FLAG_VERBOSE, eli_main, { - { 'a', "aalgo", aalgo, G_TYPE_STRING }, + { 'a', "aalgo", "none", G_TYPE_STRING }, { 'b', "boot", NULL, G_TYPE_BOOL }, - { 'B', "backupfile", backupfile, G_TYPE_STRING }, - { 'e', "ealgo", ealgo, G_TYPE_STRING }, - { 'i', "iterations", &iterations, G_TYPE_NUMBER }, - { 'K', "newkeyfile", newkeyfile, G_TYPE_STRING }, - { 'l', "keylen", &keylen, G_TYPE_NUMBER }, + { 'B', "backupfile", "", G_TYPE_STRING }, + { 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING }, + { 'i', "iterations", "-1", G_TYPE_NUMBER }, + { 'K', "newkeyfile", "", G_TYPE_STRING }, + { 'l', "keylen", "0", G_TYPE_NUMBER }, { 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, - { 's', "sectorsize", §orsize, G_TYPE_NUMBER }, + { 's', "sectorsize", "0", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "- an alias for 'init'" @@ -132,7 +124,7 @@ struct g_command class_commands[] = { { "attach", G_FLAG_VERBOSE | G_FLAG_LOADKLD, eli_main, { { 'd', "detach", NULL, G_TYPE_BOOL }, - { 'k', "keyfile", keyfile, G_TYPE_STRING }, + { 'k', "keyfile", "", G_TYPE_STRING }, { 'p', "nopassphrase", NULL, G_TYPE_BOOL }, { 'r', "readonly", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL @@ -157,11 +149,11 @@ struct g_command class_commands[] = { }, { "onetime", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, { - { 'a', "aalgo", aalgo, G_TYPE_STRING }, + { 'a', "aalgo", "none", G_TYPE_STRING }, { 'd', "detach", NULL, G_TYPE_BOOL }, - { 'e', "ealgo", ealgo, G_TYPE_STRING }, - { 'l', "keylen", &keylen, G_TYPE_NUMBER }, - { 's', "sectorsize", §orsize, G_TYPE_NUMBER }, + { 'e', "ealgo", GELI_ENC_ALGO, G_TYPE_STRING }, + { 'l', "keylen", "0", G_TYPE_NUMBER }, + { 's', "sectorsize", "0", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-d] [-a aalgo] [-e ealgo] [-l keylen] [-s sectorsize] prov" @@ -176,10 +168,10 @@ struct g_command class_commands[] = { }, { "setkey", G_FLAG_VERBOSE, eli_main, { - { 'i', "iterations", &iterations, G_TYPE_NUMBER }, - { 'k', "keyfile", keyfile, G_TYPE_STRING }, - { 'K', "newkeyfile", newkeyfile, G_TYPE_STRING }, - { 'n', "keyno", &keyno, G_TYPE_NUMBER }, + { 'i', "iterations", "-1", G_TYPE_NUMBER }, + { 'k', "keyfile", "", G_TYPE_STRING }, + { 'K', "newkeyfile", "", G_TYPE_STRING }, + { 'n', "keyno", "-1", G_TYPE_NUMBER }, { 'p', "nopassphrase", NULL, G_TYPE_BOOL }, { 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL @@ -190,7 +182,7 @@ struct g_command class_commands[] = { { { 'a', "all", NULL, G_TYPE_BOOL }, { 'f', "force", NULL, G_TYPE_BOOL }, - { 'n', "keyno", &keyno, G_TYPE_NUMBER }, + { 'n', "keyno", "-1", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-afv] [-n keyno] prov" Modified: stable/8/sbin/geom/class/journal/geom_journal.c ============================================================================== --- stable/8/sbin/geom/class/journal/geom_journal.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/journal/geom_journal.c Tue Oct 26 21:23:55 2010 (r214402) @@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$"); uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_JOURNAL_VERSION; -static intmax_t default_jsize = -1; - static void journal_main(struct gctl_req *req, unsigned flags); static void journal_clear(struct gctl_req *req); static void journal_dump(struct gctl_req *req); @@ -66,7 +64,7 @@ struct g_command class_commands[] = { { 'c', "checksum", NULL, G_TYPE_BOOL }, { 'f', "force", NULL, G_TYPE_BOOL }, { 'h', "hardcode", NULL, G_TYPE_BOOL }, - { 's', "jsize", &default_jsize, G_TYPE_NUMBER }, + { 's', "jsize", "-1", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-cfhv] [-s jsize] dataprov [jprov]" Modified: stable/8/sbin/geom/class/mirror/geom_mirror.c ============================================================================== --- stable/8/sbin/geom/class/mirror/geom_mirror.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/mirror/geom_mirror.c Tue Oct 26 21:23:55 2010 (r214402) @@ -44,9 +44,9 @@ __FBSDID("$FreeBSD$"); uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_MIRROR_VERSION; -static char label_balance[] = "load", configure_balance[] = "none"; -static intmax_t label_slice = 4096, configure_slice = -1; -static intmax_t insert_priority = 0, configure_priority = -1; +#define GMIRROR_BALANCE "load" +#define GMIRROR_SLICE "4096" +#define GMIRROR_PRIORITY "0" static void mirror_main(struct gctl_req *req, unsigned flags); static void mirror_activate(struct gctl_req *req); @@ -64,14 +64,14 @@ struct g_command class_commands[] = { { "configure", G_FLAG_VERBOSE, NULL, { { 'a', "autosync", NULL, G_TYPE_BOOL }, - { 'b', "balance", configure_balance, G_TYPE_STRING }, + { 'b', "balance", "none", G_TYPE_STRING }, { 'd', "dynamic", NULL, G_TYPE_BOOL }, { 'f', "failsync", NULL, G_TYPE_BOOL }, { 'F', "nofailsync", NULL, G_TYPE_BOOL }, { 'h', "hardcode", NULL, G_TYPE_BOOL }, { 'n', "noautosync", NULL, G_TYPE_BOOL }, - { 'p', "priority", &configure_priority, G_TYPE_NUMBER }, - { 's', "slice", &configure_slice, G_TYPE_NUMBER }, + { 'p', "priority", "-1", G_TYPE_NUMBER }, + { 's', "slice", "-1", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-adfFhnv] [-b balance] [-s slice] name\n" @@ -88,11 +88,11 @@ struct g_command class_commands[] = { }, { "label", G_FLAG_VERBOSE, mirror_main, { - { 'b', "balance", label_balance, G_TYPE_STRING }, + { 'b', "balance", GMIRROR_BALANCE, G_TYPE_STRING }, { 'F', "nofailsync", NULL, G_TYPE_BOOL }, { 'h', "hardcode", NULL, G_TYPE_BOOL }, { 'n', "noautosync", NULL, G_TYPE_BOOL }, - { 's', "slice", &label_slice, G_TYPE_NUMBER }, + { 's', "slice", GMIRROR_SLICE, G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-Fhnv] [-b balance] [-s slice] name prov ..." @@ -101,7 +101,7 @@ struct g_command class_commands[] = { { { 'h', "hardcode", NULL, G_TYPE_BOOL }, { 'i', "inactive", NULL, G_TYPE_BOOL }, - { 'p', "priority", &insert_priority, G_TYPE_NUMBER }, + { 'p', "priority", GMIRROR_PRIORITY, G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-hiv] [-p priority] name prov ..." Modified: stable/8/sbin/geom/class/nop/geom_nop.c ============================================================================== --- stable/8/sbin/geom/class/nop/geom_nop.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/nop/geom_nop.c Tue Oct 26 21:23:55 2010 (r214402) @@ -38,22 +38,15 @@ __FBSDID("$FreeBSD$"); uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_NOP_VERSION; -static intmax_t error = -1; -static intmax_t rfailprob = -1; -static intmax_t wfailprob = -1; -static intmax_t offset = 0; -static intmax_t secsize = 0; -static intmax_t size = 0; - struct g_command class_commands[] = { { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, { - { 'e', "error", &error, G_TYPE_NUMBER }, - { 'o', "offset", &offset, G_TYPE_NUMBER }, - { 'r', "rfailprob", &rfailprob, G_TYPE_NUMBER }, - { 's', "size", &size, G_TYPE_NUMBER }, - { 'S', "secsize", &secsize, G_TYPE_NUMBER }, - { 'w', "wfailprob", &wfailprob, G_TYPE_NUMBER }, + { 'e', "error", "-1", G_TYPE_NUMBER }, + { 'o', "offset", "0", G_TYPE_NUMBER }, + { 'r', "rfailprob", "-1", G_TYPE_NUMBER }, + { 's', "size", "0", G_TYPE_NUMBER }, + { 'S', "secsize", "0", G_TYPE_NUMBER }, + { 'w', "wfailprob", "-1", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-v] [-e error] [-o offset] [-r rfailprob] [-s size] " @@ -61,9 +54,9 @@ struct g_command class_commands[] = { }, { "configure", G_FLAG_VERBOSE, NULL, { - { 'e', "error", &error, G_TYPE_NUMBER }, - { 'r', "rfailprob", &rfailprob, G_TYPE_NUMBER }, - { 'w', "wfailprob", &wfailprob, G_TYPE_NUMBER }, + { 'e', "error", "-1", G_TYPE_NUMBER }, + { 'r', "rfailprob", "-1", G_TYPE_NUMBER }, + { 'w', "wfailprob", "-1", G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-v] [-e error] [-r rfailprob] [-w wfailprob] prov ..." Modified: stable/8/sbin/geom/class/sched/geom_sched.c ============================================================================== --- stable/8/sbin/geom/class/sched/geom_sched.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/sched/geom_sched.c Tue Oct 26 21:23:55 2010 (r214402) @@ -54,7 +54,7 @@ uint32_t version = G_SCHED_VERSION; * storage for parameters used by this geom class. * Right now only the scheduler name is used. */ -static char algo[] = "rr"; /* default scheduler */ +#define GSCHED_ALGO "rr" /* default scheduler */ /* * Adapt to differences in geom library. @@ -76,7 +76,7 @@ gcmd_createinsert(struct gctl_req *req, if (gctl_has_param(req, "algo")) reqalgo = gctl_get_ascii(req, "algo"); else - reqalgo = algo; + reqalgo = GSCHED_ALGO; snprintf(name, sizeof(name), "gsched_%s", reqalgo); /* @@ -91,21 +91,21 @@ gcmd_createinsert(struct gctl_req *req, struct g_command class_commands[] = { { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert, { - { 'a', "algo", algo, G_TYPE_STRING }, + { 'a', "algo", GSCHED_ALGO, G_TYPE_STRING }, G_OPT_SENTINEL }, G_ARGNAME "[-v] [-a algorithm_name] dev ..." }, { "insert", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert, { - { 'a', "algo", algo, G_TYPE_STRING }, + { 'a', "algo", GSCHED_ALGO, G_TYPE_STRING }, G_OPT_SENTINEL }, G_ARGNAME "[-v] [-a algorithm_name] dev ..." }, { "configure", G_FLAG_VERBOSE, NULL, { - { 'a', "algo", algo, G_TYPE_STRING }, + { 'a', "algo", GSCHED_ALGO, G_TYPE_STRING }, G_OPT_SENTINEL }, G_ARGNAME "[-v] [-a algorithm_name] prov ..." Modified: stable/8/sbin/geom/class/stripe/geom_stripe.c ============================================================================== --- stable/8/sbin/geom/class/stripe/geom_stripe.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/stripe/geom_stripe.c Tue Oct 26 21:23:55 2010 (r214402) @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_STRIPE_VERSION; -static intmax_t default_stripesize = 65536; +#define GSTRIPE_STRIPESIZE "65536" static void stripe_main(struct gctl_req *req, unsigned flags); static void stripe_clear(struct gctl_req *req); @@ -59,7 +59,7 @@ struct g_command class_commands[] = { }, { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL, { - { 's', "stripesize", &default_stripesize, G_TYPE_NUMBER }, + { 's', "stripesize", GSTRIPE_STRIPESIZE, G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-hv] [-s stripesize] name prov prov ..." @@ -77,7 +77,7 @@ struct g_command class_commands[] = { { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, stripe_main, { { 'h', "hardcode", NULL, G_TYPE_BOOL }, - { 's', "stripesize", &default_stripesize, G_TYPE_NUMBER }, + { 's', "stripesize", GSTRIPE_STRIPESIZE, G_TYPE_NUMBER }, G_OPT_SENTINEL }, NULL, "[-hv] [-s stripesize] name prov prov ..." Modified: stable/8/sbin/geom/class/virstor/geom_virstor.c ============================================================================== --- stable/8/sbin/geom/class/virstor/geom_virstor.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/class/virstor/geom_virstor.c Tue Oct 26 21:23:55 2010 (r214402) @@ -48,8 +48,9 @@ __FBSDID("$FreeBSD$"); uint32_t lib_version = G_LIB_VERSION; uint32_t version = G_VIRSTOR_VERSION; -static intmax_t chunk_size = 4 * 1024 * 1024; /* in kB (default: 4 MB) */ -static intmax_t vir_size = 2ULL << 40; /* in MB (default: 2 TB) */ + +#define GVIRSTOR_CHUNK_SIZE "4M" +#define GVIRSTOR_VIR_SIZE "2T" #if G_LIB_VERSION == 1 /* Support RELENG_6 */ @@ -71,8 +72,8 @@ struct g_command class_commands[] = { {"label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, virstor_main, { {'h', "hardcode", NULL, G_TYPE_BOOL}, - {'m', "chunk_size", &chunk_size, G_TYPE_NUMBER}, - {'s', "vir_size", &vir_size, G_TYPE_NUMBER}, + {'m', "chunk_size", GVIRSTOR_CHUNK_SIZE, G_TYPE_NUMBER}, + {'s', "vir_size", GVIRSTOR_VIR_SIZE, G_TYPE_NUMBER}, G_OPT_SENTINEL }, NULL, "[-h] [-v] [-m chunk_size] [-s vir_size] name provider0 [provider1 ...]" Modified: stable/8/sbin/geom/core/geom.c ============================================================================== --- stable/8/sbin/geom/core/geom.c Tue Oct 26 21:22:55 2010 (r214401) +++ stable/8/sbin/geom/core/geom.c Tue Oct 26 21:23:55 2010 (r214402) @@ -374,14 +374,8 @@ parse_arguments(struct g_command *cmd, s usage(); } else if (opt->go_val == G_VAL_OPTIONAL) { /* add nothing. */ - } else if (G_OPT_TYPE(opt) == G_TYPE_STRING) { + } else { set_option(cmd, req, opt, opt->go_val); - } else if (G_OPT_TYPE(opt) == G_TYPE_NUMBER) { - char val[64]; - - snprintf(val, sizeof(val), "%jd", - *(const intmax_t *)opt->go_val); - set_option(cmd, req, opt, val); } } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010262123.o9QLNutG071309>