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/inode.c | |
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/inode.c')
-rw-r--r-- | fs/sysfs/inode.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index dbd820f9aeed..542d2bcc73df 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -33,6 +33,16 @@ static struct inode_operations sysfs_inode_operations ={ | |||
33 | .setattr = sysfs_setattr, | 33 | .setattr = sysfs_setattr, |
34 | }; | 34 | }; |
35 | 35 | ||
36 | void sysfs_delete_inode(struct inode *inode) | ||
37 | { | ||
38 | /* Free the shadowed directory inode operations */ | ||
39 | if (sysfs_is_shadowed_inode(inode)) { | ||
40 | kfree(inode->i_op); | ||
41 | inode->i_op = NULL; | ||
42 | } | ||
43 | return generic_delete_inode(inode); | ||
44 | } | ||
45 | |||
36 | int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) | 46 | int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) |
37 | { | 47 | { |
38 | struct inode * inode = dentry->d_inode; | 48 | struct inode * inode = dentry->d_inode; |