vfs: variant symlinks
PATCH 1/2 vfs: variant symlinks
Variant symlinks add the ability to embed variables in to the contents of symbolic links so their targets can change based on outside sources (user environment, uts, filesystems, etc.)
---
include/linux/variant.h +10 -0
@@ -0,0 +1,10 @@ +#ifndef _LINUX_VARIANT_H +#define _LINUX_VARIANT_H + +int variant_func_register (int ( *variant_func)(const char *,int ,char *,int ),int priority,char *name); +void variant_func_unregister (int id); +int do_variant_lookup (const char *path,char **newpath); + +extern int variant_links_enabled; + +#endif /* _LINUX_VARIANT_H */
fs/Kconfig +8 -0
@@ -524,6 +524,14 @@ If unsure, say Y. +config VARIANT + bool "Variant symlink support (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + If you say Y here, all filesystems will have the ability to + dynamically redirect their symbolic link targets based on embedded + variables. If unsure, say N + config QUOTA bool "Quota support" help
fs/Makefile +2 -0
@@ -63,6 +63,8 @@ obj-$(CONFIG_PROFILING) += dcookies.o obj-$(CONFIG_DLM) += dlm/ + +obj-$(CONFIG_VARIANT) += variant/ # Do not add any filesystems before this line obj-$(CONFIG_REISERFS_FS) += reiserfs/
fs/variant/Makefile +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the variant symlinks +# + +obj-$(CONFIG_VARIANT) += variant.o
fs/namei.c +21 -0
@@ -31,6 +31,7 @@#include <linux/file.h> #include <linux/fcntl.h> #include <linux/namei.h> +#include <linux/variant.h> #include <asm/namei.h> #include <asm/uaccess.h>
@@ -539,10 +540,25 @@ static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) {int res =0 ; +#ifdef CONFIG_VARIANT +char *newlink =NULL ; +int err; +#endif char *name;if (IS_ERR (link)) goto fail; +#ifdef CONFIG_VARIANT +if (variant_links_enabled &&strchr (link,'$' )) { + err =do_variant_lookup (link, &newlink); +if (err) { +path_release (nd); +return err; + } + link = newlink; + } +#endif +if (*link =='/' ) {path_release (nd);if (!walk_init_root (link, nd))
@@ -551,6 +565,11 @@ } res =link_path_walk (link, nd); out: +#ifdef CONFIG_VARIANT +if (newlink == link) +kfree (newlink); +#endif +if (nd->depth || res || nd->last_type!=LAST_NORM )return res;/*
fs/variant/variant.c +183 -0
183 lines not on this page · raw message
Quoted 3 lines · Ken Schmidt
Variant symlinks add the ability to embed variables in to the contents of symbolic links so their targets can change based on outside sources (user environment, uts, filesystems, etc.)
Could you elaborate why this is needed and what part cannot be solved in userspace (linkfarm on tmpfs or intelligent scripts)?
Thanks,
Jan
Al Viro
NAKQuoted 1 line · Ken Schmidt
Variant symlinks add the ability to embed variables in to the contents of symbolic links so their targets can change based on outside sources (user environment, uts, filesystems, etc.)
NAK - it's too ugly to live.