Commit eee352d6 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sysfs ->follow_link() switched to new scheme

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 11e86a4a
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/namei.h>
#include "sysfs.h" #include "sysfs.h"
static struct inode_operations sysfs_symlink_inode_operations = { static struct inode_operations sysfs_symlink_inode_operations = {
.readlink = sysfs_readlink, .readlink = generic_readlink,
.follow_link = sysfs_follow_link, .follow_link = sysfs_follow_link,
.put_link = sysfs_put_link,
}; };
static int init_symlink(struct inode * inode) static int init_symlink(struct inode * inode)
...@@ -140,38 +142,21 @@ static int sysfs_getlink(struct dentry *dentry, char * path) ...@@ -140,38 +142,21 @@ static int sysfs_getlink(struct dentry *dentry, char * path)
} }
int sysfs_readlink(struct dentry *dentry, char __user *buffer, int buflen) int sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
{ {
int error = 0; int error = -ENOMEM;
unsigned long page = get_zeroed_page(GFP_KERNEL); unsigned long page = get_zeroed_page(GFP_KERNEL);
if (page)
if (!page)
return -ENOMEM;
error = sysfs_getlink(dentry, (char *) page); error = sysfs_getlink(dentry, (char *) page);
if (!error) nd_set_link(nd, error ? ERR_PTR(error) : (char *)page);
error = vfs_readlink(dentry, buffer, buflen, (char *) page); return 0;
free_page(page);
return error;
} }
int sysfs_follow_link(struct dentry *dentry, struct nameidata *nd) void sysfs_put_link(struct dentry *dentry, struct nameidata *nd)
{ {
int error = 0; char *page = nd_get_link(nd);
unsigned long page = get_zeroed_page(GFP_KERNEL); if (!IS_ERR(page))
free_page((unsigned long)page);
if (!page)
return -ENOMEM;
error = sysfs_getlink(dentry, (char *) page);
if (!error)
error = vfs_follow_link(nd, (char *) page);
free_page(page);
return error;
} }
EXPORT_SYMBOL(sysfs_create_link); EXPORT_SYMBOL(sysfs_create_link);
......
...@@ -12,8 +12,8 @@ extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); ...@@ -12,8 +12,8 @@ extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **); extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
extern void sysfs_remove_subdir(struct dentry *); extern void sysfs_remove_subdir(struct dentry *);
extern int sysfs_readlink(struct dentry *, char __user *, int );
extern int sysfs_follow_link(struct dentry *, struct nameidata *); extern int sysfs_follow_link(struct dentry *, struct nameidata *);
extern void sysfs_put_link(struct dentry *, struct nameidata *);
extern struct rw_semaphore sysfs_rename_sem; extern struct rw_semaphore sysfs_rename_sem;
static inline struct kobject *sysfs_get_kobject(struct dentry *dentry) static inline struct kobject *sysfs_get_kobject(struct dentry *dentry)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment