This allows variant symlinks to interpret their variables from uts.
Signed-off-by: Ken Schmidt <[email protected]>
--
diff -urN linux-2.6.22.5.orig/fs/Kconfig linux-2.6.22.5/fs/Kconfig
--- linux-2.6.22.5.orig/fs/Kconfig 2007-09-23 10:36:16.000000000 -0700
+++ linux-2.6.22.5/fs/Kconfig 2007-09-23 10:44:00.000000000 -0700
@@ -532,6 +532,13 @@
dynamically redirect their symbolic link targets based on embedded
variables. If unsure, say N
+config VARIANT_UTS
+ tristate "Variant symlinks from UTS(uname)"
+ depends on VARIANT
+ help
+ If you say Y here, Variables embedded in symbolic links (variant
+ symlinks) will be evaluated from UTS (uname).
+
config QUOTA
bool "Quota support"
help
diff -urN linux-2.6.22.5.orig/fs/variant/Makefile linux-2.6.22.5/fs/variant/Makefile
--- linux-2.6.22.5.orig/fs/variant/Makefile 2007-09-23 09:17:04.000000000 -0700
+++ linux-2.6.22.5/fs/variant/Makefile 2007-09-23 10:44:41.000000000 -0700
@@ -3,3 +3,6 @@
#
obj-$(CONFIG_VARIANT) += variant.o
+
+obj-$(CONFIG_VARIANT_UTS) += variant-uts.o
+
--- linux-2.6.22.5.unpacked/fs/variant/variant-uts.c 1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.22.5/fs/variant/variant-uts.c 2007-09-24 05:11:37.000000000 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) Pacific Northwest National Laboratory., 2007
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * written by Kevin Fox (kevin.fox <at> pnl.gov) for the
+ * Department of Energy
+ */
+
+#include<linux/init.h>
+#include<linux/module.h>
+#include<linux/string.h>
+#include<linux/utsname.h>
+#include<linux/variant.h>
+
+MODULE_LICENSE("GPL");
+
+static int variant_func_id;
+static int pri = 1;
+static char *name = "uts";
+
+static int variant_uts_replace(const char *key, int keylen, char *dest, int destlen)
+{
+ char *data = NULL;
+ int retval;
+ if (!strnicmp(key, "SYSNAME", keylen)) {
+ data = utsname()->sysname;
+ } else if (!strnicmp(key, "NODENAME", keylen)) {
+ data = utsname()->nodename;
+ } else if (!strnicmp(key, "RELEASE", keylen)) {
+ data = utsname()->release;
+ } else if (!strnicmp(key, "VERSION", keylen)) {
+ data = utsname()->version;
+ } else if (!strnicmp(key, "MACHINE", keylen)) {
+ data = utsname()->machine;
+ } else if (!strnicmp(key, "DOMAINNAME", keylen)) {
+ data = utsname()->domainname;
+ }
+ if (!data)
+ return 0;
+
+ retval = strlen(data);
+
+ if (retval > destlen)
+ return 0;
+
+ memcpy(dest, data, retval + 1);
+ return retval;
+}
+
+static int __init init_variant_uts(void)
+{
+ variant_func_id = variant_func_register(variant_uts_replace, pri, name);
+ return 0;
+}
+
+static void __exit exit_variant_uts(void)
+{
+ variant_func_unregister (variant_func_id);
+}
+
+module_init (init_variant_uts);
+module_exit (exit_variant_uts);
+module_param (pri, int, 0644);