From: Ken Schmidt <kenneth.schmidt@pnl.gov>
To: viro@zeniv.linux.org.uk
Cc: linux-kernel@vger.kernel.org, kenneth.schmidt@pnl.gov
Subject: [patch 02/02] vfs: variant symlinks from uts
Date: Fri, 28 Sep 2007 10:16:03 -0700 [thread overview]
Message-ID: <20070928101603.712857d6.kenneth.schmidt@pnl.gov> (raw)
This allows variant symlinks to interpret their variables from uts.
Signed-off-by: Ken Schmidt <kenneth.schmidt@pnl.gov>
--
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);
reply other threads:[~2007-09-28 18:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070928101603.712857d6.kenneth.schmidt@pnl.gov \
--to=kenneth.schmidt@pnl.gov \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®