In some cases (such as a distro kernel with backported features) libhugetlbfs
will be wrong about the presence of a feature.  In these rare cases it will be
useful to tell the library whether or not the feature is present in the running
kernel.

Add a string field to 'struct feature' which contains the environment variable
to be used for overriding feature detection.  __lh_setup_features() will check
if an override variable is set for each defined feature.  If that variable is
"yes" the feature is assumed to be present.  If the variable is "no" is it
assumed to be absent.  All other values are ignored.

Signed-off-by: Adam Litke <[EMAIL PROTECTED]>
---

 kernel-features.c |   14 ++++++++++++++
 kernel-features.h |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)


diff --git a/kernel-features.c b/kernel-features.c
index 1b4508c..5eedb86 100644
--- a/kernel-features.c
+++ b/kernel-features.c
@@ -36,6 +36,7 @@ static struct feature kernel_features[] = {
        [HUGETLB_FEATURE_PRIVATE_RESV] = {
                .name                   = "private_reservations",
                .required_version       = "2.6.27-rc1",
+               .override_variable      = "HUGETLB_FEATURE_PRIVATE_RESV",
        },
 }; 
 
@@ -169,8 +170,21 @@ void __lh_setup_features()
 
        for (i = 0; i < HUGETLB_FEATURE_NR; i++) {
                struct kernel_version ver;
+               char *override = kernel_features[i].override_variable;
+               char *env;
+               
                str_to_ver(kernel_features[i].required_version, &ver);
 
+               /* Has the user overridden feature detection? */
+               if (override && (env = getenv(override))) {
+                       if (strcasecmp(env, "no") == 0)
+                               continue;
+                       else if (strcasecmp(env, "yes") == 0) {
+                               feature_mask |= (1UL << i);
+                               continue;
+                       }
+               }
+
                /* Is the running kernel version newer? */
                if (ver_cmp(&running_kernel_version, &ver) >= 0) {
                        DEBUG("Feature %s is present in this kernel\n",
diff --git a/kernel-features.h b/kernel-features.h
index e1b6ca9..b2172e8 100644
--- a/kernel-features.h
+++ b/kernel-features.h
@@ -27,4 +27,5 @@ struct kernel_version {
 struct feature {
        char *name;
        char *required_version;
+       char *override_variable;
 };


-------------------------------------------------------------------------
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

Reply via email to