Signed-off-by: Eric B Munson <[EMAIL PROTECTED]> --- hugeutils.c | 24 ++++++++++++------------ kernel-features.c | 13 +++++++------ libhugetlbfs_internal.h | 3 +++ 3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/hugeutils.c b/hugeutils.c index b4e8c2b..afb3053 100644 --- a/hugeutils.c +++ b/hugeutils.c @@ -254,6 +254,9 @@ void hugetlbfs_setup_env() __hugetlb_opts.share_path = getenv("HUGETLB_SHARE_PATH"); __hugetlb_opts.elfmap = getenv("HUGETLB_ELFMAP"); __hugetlb_opts.ld_preload = getenv("LD_PRELOAD"); + __hugetlb_opts.def_page_size = getenv("HUGETLB_DEFAULT_PAGE_SIZE"); + __hugetlb_opts.path = getenv("HUGETLB_PATH"); + __hugetlb_opts.features = getenv("HUGETLB_FEATURES"); env = getenv("HUGETLB_FORCE_ELFMAP"); if (env && (strcasecmp(env, "yes") == 0)) @@ -332,7 +335,6 @@ static int hpage_size_to_index(unsigned long size) static void probe_default_hpage_size(void) { - char *env; long size; int index; @@ -346,9 +348,9 @@ static void probe_default_hpage_size(void) * Check if the user specified a default size, otherwise use the * system default size as reported by /proc/meminfo. */ - env = getenv("HUGETLB_DEFAULT_PAGE_SIZE"); - if (env && strlen(env) > 0) - size = parse_page_size(env); + if (__hugetlb_opts.def_page_size && + strlen(__hugetlb_opts.def_page_size) > 0) + size = parse_page_size(__hugetlb_opts.def_page_size); else { size = kernel_default_hugepage_size(); } @@ -467,28 +469,26 @@ static void find_mounts(void) void setup_mounts(void) { - char *env; int do_scan = 1; /* If HUGETLB_PATH is set, only add mounts specified there */ - env = getenv("HUGETLB_PATH"); - while (env) { + while (__hugetlb_opts.path) { char path[PATH_MAX + 1]; - char *next = strchrnul(env, ':'); + char *next = strchrnul(__hugetlb_opts.path, ':'); do_scan = 0; - if (next - env > PATH_MAX) { + if (next - __hugetlb_opts.path > PATH_MAX) { ERROR("Path too long in HUGETLB_PATH -- " "ignoring environment\n"); break; } - strncpy(path, env, next - env); - path[next - env] = '\0'; + strncpy(path, __hugetlb_opts.path, next - __hugetlb_opts.path); + path[next - __hugetlb_opts.path] = '\0'; add_hugetlbfs_mount(path, 1); /* skip the ':' token */ - env = *next == '\0' ? NULL : next + 1; + __hugetlb_opts.path = *next == '\0' ? NULL : next + 1; } /* Then probe all mounted filesystems */ diff --git a/kernel-features.c b/kernel-features.c index 5f20249..46c5762 100644 --- a/kernel-features.c +++ b/kernel-features.c @@ -214,7 +214,6 @@ static int check_features_env_valid(const char *env) void setup_features() { struct utsname u; - char *env; int i; if (uname(&u)) { @@ -226,10 +225,10 @@ void setup_features() debug_kernel_version(); /* Check if the user has overrided any features */ - env = getenv("HUGETLB_FEATURES"); - if (env && check_features_env_valid(env) == -1) { + if (__hugetlb_opts.features && + check_features_env_valid(__hugetlb_opts.features) == -1) { ERROR("HUGETLB_FEATURES was invalid -- ignoring.\n"); - env = NULL; + __hugetlb_opts.features = NULL; } for (i = 0; i < HUGETLB_FEATURE_NR; i++) { @@ -240,10 +239,12 @@ void setup_features() str_to_ver(kernel_features[i].required_version, &ver); /* Has the user overridden feature detection? */ - if (env && (pos = strstr(env, name))) { + if (__hugetlb_opts.features && + (pos = strstr(__hugetlb_opts.features, name))) { DEBUG("Overriding feature %s: ", name); /* If feature is preceeded by 'no_' then turn it off */ - if (((pos - 3) >= env) && !strncmp(pos - 3, "no_", 3)) + if (((pos - 3) >= __hugetlb_opts.features) && + !strncmp(pos - 3, "no_", 3)) DEBUG_CONT("no\n"); else { DEBUG_CONT("yes\n"); diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h index 2ad0163..7969566 100644 --- a/libhugetlbfs_internal.h +++ b/libhugetlbfs_internal.h @@ -62,6 +62,9 @@ struct libhugeopts_t { char *ld_preload; char *elfmap; char *share_path; + char *features; + char *path; + char *def_page_size; }; /* -- 1.6.0.3 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel