diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-01-24 14:35:52 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 13:37:14 -0500 |
commit | b592fcfe7f06c15ec11774b5be7ce0de3aa86e73 (patch) | |
tree | 13f2cb344f8871edd30dc15007534405197d8480 /fs/sysfs/sysfs.h | |
parent | 2f65168de7d68a5795e945e781d85b313bdc97b9 (diff) |
sysfs: Shadow directory support
The problem. When implementing a network namespace I need to be able
to have multiple network devices with the same name. Currently this
is a problem for /sys/class/net/*.
What I want is a separate /sys/class/net directory in sysfs for each
network namespace, and I want to name each of them /sys/class/net.
I looked and the VFS actually allows that. All that is needed is
for /sys/class/net to implement a follow link method to redirect
lookups to the real directory you want.
Implementing a follow link method that is sensitive to the current
network namespace turns out to be 3 lines of code so it looks like a
clean approach. Modifying sysfs so it doesn't get in my was is a bit
trickier.
I am calling the concept of multiple directories all at the same path
in the filesystem shadow directories. With the directory entry really
at that location the shadow master.
The following patch modifies sysfs so it can handle a directory
structure slightly different from the kobject tree so I can implement
the shadow directories for handling /sys/class/net/.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Maneesh Soni <maneesh@in.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/sysfs.h')
-rw-r--r-- | fs/sysfs/sysfs.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 39c623fdc277..fe1cbfd208ed 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -2,6 +2,7 @@ | |||
2 | extern struct vfsmount * sysfs_mount; | 2 | extern struct vfsmount * sysfs_mount; |
3 | extern struct kmem_cache *sysfs_dir_cachep; | 3 | extern struct kmem_cache *sysfs_dir_cachep; |
4 | 4 | ||
5 | extern void sysfs_delete_inode(struct inode *inode); | ||
5 | extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *); | 6 | extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *); |
6 | extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); | 7 | extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); |
7 | 8 | ||
@@ -112,3 +113,7 @@ static inline void sysfs_put(struct sysfs_dirent * sd) | |||
112 | release_sysfs_dirent(sd); | 113 | release_sysfs_dirent(sd); |
113 | } | 114 | } |
114 | 115 | ||
116 | static inline int sysfs_is_shadowed_inode(struct inode *inode) | ||
117 | { | ||
118 | return S_ISDIR(inode->i_mode) && inode->i_op->follow_link; | ||
119 | } | ||