Signed-off-by: Eric B Munson <[EMAIL PROTECTED]> --- Changes from V1: Rebase to libhuge 2.1
hugeutils.c | 25 ++++++++++++------------- kernel-features.c | 13 +++++++------ libhugetlbfs_internal.h | 3 +++ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/hugeutils.c b/hugeutils.c index f8b5d76..31a9d8e 100644 --- a/hugeutils.c +++ b/hugeutils.c @@ -256,6 +256,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)) @@ -334,7 +337,6 @@ static int hpage_size_to_index(unsigned long size) static void probe_default_hpage_size(void) { - char *env; long size; int index; int default_overrided; @@ -349,10 +351,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"); - default_overrided = env && strlen(env) > 0; - if (default_overrided) - 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(); } @@ -481,28 +482,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 79c499c..4bb0149 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))) { INFO("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)) INFO_CONT("no\n"); else { INFO_CONT("yes\n"); diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h index 5ac4dd7..b5cee9d 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 ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel