Commit 324a56e1 authored by Tejun Heo's avatar Tejun Heo Committed by Greg Kroah-Hartman

kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly

kernfs has just been separated out from sysfs and we're already in
full conflict mode.  Nothing can make the situation any worse.  Let's
take the chance to name things properly.

This patch performs the following renames.

* s/sysfs_elem_dir/kernfs_elem_dir/
* s/sysfs_elem_symlink/kernfs_elem_symlink/
* s/sysfs_elem_attr/kernfs_elem_file/
* s/sysfs_dirent/kernfs_node/
* s/sd/kn/ in kernfs proper
* s/parent_sd/parent/
* s/target_sd/target/
* s/dir_sd/parent/
* s/to_sysfs_dirent()/rb_to_kn()/
* misc renames of local vars when they conflict with the above

Because md, mic and gpio dig into sysfs details, this patch ends up
modifying them.  All are sysfs_dirent renames and trivial.  While we
can avoid these by introducing a dummy wrapping struct sysfs_dirent
around kernfs_node, given the limited usage outside kernfs and sysfs
proper, I don't think such workaround is called for.

This patch is strictly rename only and doesn't introduce any
functional difference.

- mic / gpio renames were missing.  Spotted by kbuild test robot.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Neil Brown <neilb@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a8b1c019
...@@ -393,7 +393,7 @@ static const DEVICE_ATTR(value, 0644, ...@@ -393,7 +393,7 @@ static const DEVICE_ATTR(value, 0644,
static irqreturn_t gpio_sysfs_irq(int irq, void *priv) static irqreturn_t gpio_sysfs_irq(int irq, void *priv)
{ {
struct sysfs_dirent *value_sd = priv; struct kernfs_node *value_sd = priv;
sysfs_notify_dirent(value_sd); sysfs_notify_dirent(value_sd);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -402,7 +402,7 @@ static irqreturn_t gpio_sysfs_irq(int irq, void *priv) ...@@ -402,7 +402,7 @@ static irqreturn_t gpio_sysfs_irq(int irq, void *priv)
static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev, static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
unsigned long gpio_flags) unsigned long gpio_flags)
{ {
struct sysfs_dirent *value_sd; struct kernfs_node *value_sd;
unsigned long irq_flags; unsigned long irq_flags;
int ret, irq, id; int ret, irq, id;
......
...@@ -1635,7 +1635,7 @@ int bitmap_create(struct mddev *mddev) ...@@ -1635,7 +1635,7 @@ int bitmap_create(struct mddev *mddev)
sector_t blocks = mddev->resync_max_sectors; sector_t blocks = mddev->resync_max_sectors;
struct file *file = mddev->bitmap_info.file; struct file *file = mddev->bitmap_info.file;
int err; int err;
struct sysfs_dirent *bm = NULL; struct kernfs_node *bm = NULL;
BUILD_BUG_ON(sizeof(bitmap_super_t) != 256); BUILD_BUG_ON(sizeof(bitmap_super_t) != 256);
......
...@@ -225,7 +225,7 @@ struct bitmap { ...@@ -225,7 +225,7 @@ struct bitmap {
wait_queue_head_t overflow_wait; wait_queue_head_t overflow_wait;
wait_queue_head_t behind_wait; wait_queue_head_t behind_wait;
struct sysfs_dirent *sysfs_can_clear; struct kernfs_node *sysfs_can_clear;
}; };
/* the bitmap API */ /* the bitmap API */
......
...@@ -106,7 +106,7 @@ struct md_rdev { ...@@ -106,7 +106,7 @@ struct md_rdev {
*/ */
struct work_struct del_work; /* used for delayed sysfs removal */ struct work_struct del_work; /* used for delayed sysfs removal */
struct sysfs_dirent *sysfs_state; /* handle for 'state' struct kernfs_node *sysfs_state; /* handle for 'state'
* sysfs entry */ * sysfs entry */
struct badblocks { struct badblocks {
...@@ -376,10 +376,10 @@ struct mddev { ...@@ -376,10 +376,10 @@ struct mddev {
sector_t resync_max; /* resync should pause sector_t resync_max; /* resync should pause
* when it gets here */ * when it gets here */
struct sysfs_dirent *sysfs_state; /* handle for 'array_state' struct kernfs_node *sysfs_state; /* handle for 'array_state'
* file in sysfs. * file in sysfs.
*/ */
struct sysfs_dirent *sysfs_action; /* handle for 'sync_action' */ struct kernfs_node *sysfs_action; /* handle for 'sync_action' */
struct work_struct del_work; /* used for delayed sysfs removal */ struct work_struct del_work; /* used for delayed sysfs removal */
...@@ -498,13 +498,13 @@ struct md_sysfs_entry { ...@@ -498,13 +498,13 @@ struct md_sysfs_entry {
}; };
extern struct attribute_group md_bitmap_group; extern struct attribute_group md_bitmap_group;
static inline struct sysfs_dirent *sysfs_get_dirent_safe(struct sysfs_dirent *sd, char *name) static inline struct kernfs_node *sysfs_get_dirent_safe(struct kernfs_node *sd, char *name)
{ {
if (sd) if (sd)
return sysfs_get_dirent(sd, name); return sysfs_get_dirent(sd, name);
return sd; return sd;
} }
static inline void sysfs_notify_dirent_safe(struct sysfs_dirent *sd) static inline void sysfs_notify_dirent_safe(struct kernfs_node *sd)
{ {
if (sd) if (sd)
sysfs_notify_dirent(sd); sysfs_notify_dirent(sd);
......
...@@ -112,7 +112,7 @@ struct mic_device { ...@@ -112,7 +112,7 @@ struct mic_device {
struct work_struct shutdown_work; struct work_struct shutdown_work;
u8 state; u8 state;
u8 shutdown_status; u8 shutdown_status;
struct sysfs_dirent *state_sysfs; struct kernfs_node *state_sysfs;
struct completion reset_wait; struct completion reset_wait;
void *log_buf_addr; void *log_buf_addr;
int *log_buf_len; int *log_buf_len;
......
This diff is collapsed.
This diff is collapsed.
...@@ -46,36 +46,36 @@ void __init sysfs_inode_init(void) ...@@ -46,36 +46,36 @@ void __init sysfs_inode_init(void)
panic("failed to init sysfs_backing_dev_info"); panic("failed to init sysfs_backing_dev_info");
} }
static struct sysfs_inode_attrs *sysfs_inode_attrs(struct sysfs_dirent *sd) static struct sysfs_inode_attrs *sysfs_inode_attrs(struct kernfs_node *kn)
{ {
struct iattr *iattrs; struct iattr *iattrs;
if (sd->s_iattr) if (kn->s_iattr)
return sd->s_iattr; return kn->s_iattr;
sd->s_iattr = kzalloc(sizeof(struct sysfs_inode_attrs), GFP_KERNEL); kn->s_iattr = kzalloc(sizeof(struct sysfs_inode_attrs), GFP_KERNEL);
if (!sd->s_iattr) if (!kn->s_iattr)
return NULL; return NULL;
iattrs = &sd->s_iattr->ia_iattr; iattrs = &kn->s_iattr->ia_iattr;
/* assign default attributes */ /* assign default attributes */
iattrs->ia_mode = sd->s_mode; iattrs->ia_mode = kn->s_mode;
iattrs->ia_uid = GLOBAL_ROOT_UID; iattrs->ia_uid = GLOBAL_ROOT_UID;
iattrs->ia_gid = GLOBAL_ROOT_GID; iattrs->ia_gid = GLOBAL_ROOT_GID;
iattrs->ia_atime = iattrs->ia_mtime = iattrs->ia_ctime = CURRENT_TIME; iattrs->ia_atime = iattrs->ia_mtime = iattrs->ia_ctime = CURRENT_TIME;
simple_xattrs_init(&sd->s_iattr->xattrs); simple_xattrs_init(&kn->s_iattr->xattrs);
return sd->s_iattr; return kn->s_iattr;
} }
static int __kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr) static int __kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
{ {
struct sysfs_inode_attrs *attrs; struct sysfs_inode_attrs *attrs;
struct iattr *iattrs; struct iattr *iattrs;
unsigned int ia_valid = iattr->ia_valid; unsigned int ia_valid = iattr->ia_valid;
attrs = sysfs_inode_attrs(sd); attrs = sysfs_inode_attrs(kn);
if (!attrs) if (!attrs)
return -ENOMEM; return -ENOMEM;
...@@ -93,24 +93,24 @@ static int __kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr) ...@@ -93,24 +93,24 @@ static int __kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr)
iattrs->ia_ctime = iattr->ia_ctime; iattrs->ia_ctime = iattr->ia_ctime;
if (ia_valid & ATTR_MODE) { if (ia_valid & ATTR_MODE) {
umode_t mode = iattr->ia_mode; umode_t mode = iattr->ia_mode;
iattrs->ia_mode = sd->s_mode = mode; iattrs->ia_mode = kn->s_mode = mode;
} }
return 0; return 0;
} }
/** /**
* kernfs_setattr - set iattr on a node * kernfs_setattr - set iattr on a node
* @sd: target node * @kn: target node
* @iattr: iattr to set * @iattr: iattr to set
* *
* Returns 0 on success, -errno on failure. * Returns 0 on success, -errno on failure.
*/ */
int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr) int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
{ {
int ret; int ret;
mutex_lock(&sysfs_mutex); mutex_lock(&sysfs_mutex);
ret = __kernfs_setattr(sd, iattr); ret = __kernfs_setattr(kn, iattr);
mutex_unlock(&sysfs_mutex); mutex_unlock(&sysfs_mutex);
return ret; return ret;
} }
...@@ -118,10 +118,10 @@ int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr) ...@@ -118,10 +118,10 @@ int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr)
int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct sysfs_dirent *sd = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
int error; int error;
if (!sd) if (!kn)
return -EINVAL; return -EINVAL;
mutex_lock(&sysfs_mutex); mutex_lock(&sysfs_mutex);
...@@ -129,7 +129,7 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) ...@@ -129,7 +129,7 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
if (error) if (error)
goto out; goto out;
error = __kernfs_setattr(sd, iattr); error = __kernfs_setattr(kn, iattr);
if (error) if (error)
goto out; goto out;
...@@ -141,14 +141,14 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) ...@@ -141,14 +141,14 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
return error; return error;
} }
static int sysfs_sd_setsecdata(struct sysfs_dirent *sd, void **secdata, static int sysfs_sd_setsecdata(struct kernfs_node *kn, void **secdata,
u32 *secdata_len) u32 *secdata_len)
{ {
struct sysfs_inode_attrs *attrs; struct sysfs_inode_attrs *attrs;
void *old_secdata; void *old_secdata;
size_t old_secdata_len; size_t old_secdata_len;
attrs = sysfs_inode_attrs(sd); attrs = sysfs_inode_attrs(kn);
if (!attrs) if (!attrs)
return -ENOMEM; return -ENOMEM;
...@@ -166,13 +166,13 @@ static int sysfs_sd_setsecdata(struct sysfs_dirent *sd, void **secdata, ...@@ -166,13 +166,13 @@ static int sysfs_sd_setsecdata(struct sysfs_dirent *sd, void **secdata,
int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags) size_t size, int flags)
{ {
struct sysfs_dirent *sd = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs; struct sysfs_inode_attrs *attrs;
void *secdata; void *secdata;
int error; int error;
u32 secdata_len = 0; u32 secdata_len = 0;
attrs = sysfs_inode_attrs(sd); attrs = sysfs_inode_attrs(kn);
if (!attrs) if (!attrs)
return -ENOMEM; return -ENOMEM;
...@@ -188,7 +188,7 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, ...@@ -188,7 +188,7 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
return error; return error;
mutex_lock(&sysfs_mutex); mutex_lock(&sysfs_mutex);
error = sysfs_sd_setsecdata(sd, &secdata, &secdata_len); error = sysfs_sd_setsecdata(kn, &secdata, &secdata_len);
mutex_unlock(&sysfs_mutex); mutex_unlock(&sysfs_mutex);
if (secdata) if (secdata)
...@@ -204,10 +204,10 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, ...@@ -204,10 +204,10 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
int sysfs_removexattr(struct dentry *dentry, const char *name) int sysfs_removexattr(struct dentry *dentry, const char *name)
{ {
struct sysfs_dirent *sd = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs; struct sysfs_inode_attrs *attrs;
attrs = sysfs_inode_attrs(sd); attrs = sysfs_inode_attrs(kn);
if (!attrs) if (!attrs)
return -ENOMEM; return -ENOMEM;
...@@ -217,10 +217,10 @@ int sysfs_removexattr(struct dentry *dentry, const char *name) ...@@ -217,10 +217,10 @@ int sysfs_removexattr(struct dentry *dentry, const char *name)
ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf,
size_t size) size_t size)
{ {
struct sysfs_dirent *sd = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs; struct sysfs_inode_attrs *attrs;
attrs = sysfs_inode_attrs(sd); attrs = sysfs_inode_attrs(kn);
if (!attrs) if (!attrs)
return -ENOMEM; return -ENOMEM;
...@@ -229,10 +229,10 @@ ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, ...@@ -229,10 +229,10 @@ ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf,
ssize_t sysfs_listxattr(struct dentry *dentry, char *buf, size_t size) ssize_t sysfs_listxattr(struct dentry *dentry, char *buf, size_t size)
{ {
struct sysfs_dirent *sd = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_inode_attrs *attrs; struct sysfs_inode_attrs *attrs;
attrs = sysfs_inode_attrs(sd); attrs = sysfs_inode_attrs(kn);
if (!attrs) if (!attrs)
return -ENOMEM; return -ENOMEM;
...@@ -254,57 +254,58 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr) ...@@ -254,57 +254,58 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr)
inode->i_ctime = iattr->ia_ctime; inode->i_ctime = iattr->ia_ctime;
} }
static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode) static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
{ {
struct sysfs_inode_attrs *attrs = sd->s_iattr; struct sysfs_inode_attrs *attrs = kn->s_iattr;
inode->i_mode = sd->s_mode; inode->i_mode = kn->s_mode;
if (attrs) { if (attrs) {
/* sysfs_dirent has non-default attributes /*
* get them from persistent copy in sysfs_dirent * kernfs_node has non-default attributes get them from
* persistent copy in kernfs_node.
*/ */
set_inode_attr(inode, &attrs->ia_iattr); set_inode_attr(inode, &attrs->ia_iattr);
security_inode_notifysecctx(inode, attrs->ia_secdata, security_inode_notifysecctx(inode, attrs->ia_secdata,
attrs->ia_secdata_len); attrs->ia_secdata_len);
} }
if (sysfs_type(sd) == SYSFS_DIR) if (sysfs_type(kn) == SYSFS_DIR)
set_nlink(inode, sd->s_dir.subdirs + 2); set_nlink(inode, kn->s_dir.subdirs + 2);
} }
int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat) struct kstat *stat)
{ {
struct sysfs_dirent *sd = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
mutex_lock(&sysfs_mutex); mutex_lock(&sysfs_mutex);
sysfs_refresh_inode(sd, inode); sysfs_refresh_inode(kn, inode);
mutex_unlock(&sysfs_mutex); mutex_unlock(&sysfs_mutex);
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
return 0; return 0;
} }
static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
{ {
kernfs_get(sd); kernfs_get(kn);
inode->i_private = sd; inode->i_private = kn;
inode->i_mapping->a_ops = &sysfs_aops; inode->i_mapping->a_ops = &sysfs_aops;
inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
inode->i_op = &sysfs_inode_operations; inode->i_op = &sysfs_inode_operations;
set_default_inode_attr(inode, sd->s_mode); set_default_inode_attr(inode, kn->s_mode);
sysfs_refresh_inode(sd, inode); sysfs_refresh_inode(kn, inode);
/* initialize inode according to type */ /* initialize inode according to type */
switch (sysfs_type(sd)) { switch (sysfs_type(kn)) {
case SYSFS_DIR: case SYSFS_DIR:
inode->i_op = &sysfs_dir_inode_operations; inode->i_op = &sysfs_dir_inode_operations;
inode->i_fop = &sysfs_dir_operations; inode->i_fop = &sysfs_dir_operations;
break; break;
case SYSFS_KOBJ_ATTR: case SYSFS_KOBJ_ATTR:
inode->i_size = sd->s_attr.size; inode->i_size = kn->s_attr.size;
inode->i_fop = &kernfs_file_operations; inode->i_fop = &kernfs_file_operations;
break; break;
case SYSFS_KOBJ_LINK: case SYSFS_KOBJ_LINK:
...@@ -318,13 +319,13 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) ...@@ -318,13 +319,13 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
} }
/** /**
* sysfs_get_inode - get inode for sysfs_dirent * sysfs_get_inode - get inode for kernfs_node
* @sb: super block * @sb: super block
* @sd: sysfs_dirent to allocate inode for * @kn: kernfs_node to allocate inode for
* *
* Get inode for @sd. If such inode doesn't exist, a new inode * Get inode for @kn. If such inode doesn't exist, a new inode is
* is allocated and basics are initialized. New inode is * allocated and basics are initialized. New inode is returned
* returned locked. * locked.
* *
* LOCKING: * LOCKING:
* Kernel thread context (may sleep). * Kernel thread context (may sleep).
...@@ -332,44 +333,44 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) ...@@ -332,44 +333,44 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
* RETURNS: * RETURNS:
* Pointer to allocated inode on success, NULL on failure. * Pointer to allocated inode on success, NULL on failure.
*/ */
struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd) struct inode *sysfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
{ {
struct inode *inode; struct inode *inode;
inode = iget_locked(sb, sd->s_ino); inode = iget_locked(sb, kn->s_ino);
if (inode && (inode->i_state & I_NEW)) if (inode && (inode->i_state & I_NEW))
sysfs_init_inode(sd, inode); sysfs_init_inode(kn, inode);
return inode; return inode;
} }
/* /*
* The sysfs_dirent serves as both an inode and a directory entry for sysfs. * The kernfs_node serves as both an inode and a directory entry for sysfs.
* To prevent the sysfs inode numbers from being freed prematurely we take a * To prevent the sysfs inode numbers from being freed prematurely we take
* reference to sysfs_dirent from the sysfs inode. A * a reference to kernfs_node from the sysfs inode. A
* super_operations.evict_inode() implementation is needed to drop that * super_operations.evict_inode() implementation is needed to drop that
* reference upon inode destruction. * reference upon inode destruction.
*/ */
void sysfs_evict_inode(struct inode *inode) void sysfs_evict_inode(struct inode *inode)
{ {
struct sysfs_dirent *sd = inode->i_private; struct kernfs_node *kn = inode->i_private;
truncate_inode_pages(&inode->i_data, 0); truncate_inode_pages(&inode->i_data, 0);
clear_inode(inode); clear_inode(inode);
kernfs_put(sd); kernfs_put(kn);
} }
int sysfs_permission(struct inode *inode, int mask) int sysfs_permission(struct inode *inode, int mask)
{ {
struct sysfs_dirent *sd; struct kernfs_node *kn;
if (mask & MAY_NOT_BLOCK) if (mask & MAY_NOT_BLOCK)
return -ECHILD; return -ECHILD;
sd = inode->i_private; kn = inode->i_private;
mutex_lock(&sysfs_mutex); mutex_lock(&sysfs_mutex);
sysfs_refresh_inode(sd, inode); sysfs_refresh_inode(kn, inode);
mutex_unlock(&sysfs_mutex); mutex_unlock(&sysfs_mutex);
return generic_permission(inode, mask); return generic_permission(inode, mask);
......
...@@ -31,24 +31,24 @@ struct sysfs_inode_attrs { ...@@ -31,24 +31,24 @@ struct sysfs_inode_attrs {
/* SYSFS_TYPE_MASK and types are defined in include/linux/kernfs.h */ /* SYSFS_TYPE_MASK and types are defined in include/linux/kernfs.h */
/** /**
* kernfs_root - find out the kernfs_root a sysfs_dirent belongs to * kernfs_root - find out the kernfs_root a kernfs_node belongs to
* @sd: sysfs_dirent of interest * @kn: kernfs_node of interest
* *
* Return the kernfs_root @sd belongs to. * Return the kernfs_root @kn belongs to.
*/ */
static inline struct kernfs_root *kernfs_root(struct sysfs_dirent *sd) static inline struct kernfs_root *kernfs_root(struct kernfs_node *kn)
{ {
/* if parent exists, it's always a dir; otherwise, @sd is a dir */ /* if parent exists, it's always a dir; otherwise, @sd is a dir */
if (sd->s_parent) if (kn->s_parent)
sd = sd->s_parent; kn = kn->s_parent;
return sd->s_dir.root; return kn->s_dir.root;
} }
/* /*
* Context structure to be used while adding/removing nodes. * Context structure to be used while adding/removing nodes.
*/ */
struct sysfs_addrm_cxt { struct sysfs_addrm_cxt {
struct sysfs_dirent *removed; struct kernfs_node *removed;
}; };
/* /*
...@@ -62,10 +62,10 @@ struct sysfs_super_info { ...@@ -62,10 +62,10 @@ struct sysfs_super_info {
struct kernfs_root *root; struct kernfs_root *root;
/* /*
* Each sb is associated with one namespace tag, currently the network * Each sb is associated with one namespace tag, currently the
* namespace of the task which mounted this sysfs instance. If multiple * network namespace of the task which mounted this sysfs instance.
* tags become necessary, make the following an array and compare * If multiple tags become necessary, make the following an array
* sysfs_dirent tag against every entry. * and compare kernfs_node tag against every entry.
*/ */
const void *ns; const void *ns;
}; };
...@@ -76,7 +76,7 @@ extern struct kmem_cache *sysfs_dir_cachep; ...@@ -76,7 +76,7 @@ extern struct kmem_cache *sysfs_dir_cachep;
/* /*
* inode.c * inode.c
*/ */
struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd); struct inode *sysfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
void sysfs_evict_inode(struct inode *inode); void sysfs_evict_inode(struct inode *inode);
int sysfs_permission(struct inode *inode, int mask); int sysfs_permission(struct inode *inode, int mask);
int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
...@@ -98,21 +98,21 @@ extern const struct dentry_operations sysfs_dentry_ops; ...@@ -98,21 +98,21 @@ extern const struct dentry_operations sysfs_dentry_ops;
extern const struct file_operations sysfs_dir_operations; extern const struct file_operations sysfs_dir_operations;
extern const struct inode_operations sysfs_dir_inode_operations; extern const struct inode_operations sysfs_dir_inode_operations;
struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd); struct kernfs_node *sysfs_get_active(struct kernfs_node *kn);
void sysfs_put_active(struct sysfs_dirent *sd); void sysfs_put_active(struct kernfs_node *kn);
void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt); void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt);
int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct kernfs_node *kn,
struct sysfs_dirent *parent_sd); struct kernfs_node *parent);
void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
struct sysfs_dirent *sysfs_new_dirent(struct kernfs_root *root, struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root,
const char *name, umode_t mode, int type); const char *name, umode_t mode, int type);
/* /*
* file.c * file.c
*/ */
extern const struct file_operations kernfs_file_operations; extern const struct file_operations kernfs_file_operations;
void sysfs_unmap_bin_file(struct sysfs_dirent *sd); void sysfs_unmap_bin_file(struct kernfs_node *kn);
/* /*
* symlink.c * symlink.c
......
...@@ -39,7 +39,7 @@ static int sysfs_fill_super(struct super_block *sb) ...@@ -39,7 +39,7 @@ static int sysfs_fill_super(struct super_block *sb)
/* get root inode, initialize and unlock it */ /* get root inode, initialize and unlock it */
mutex_lock(&sysfs_mutex); mutex_lock(&sysfs_mutex);
inode = sysfs_get_inode(sb, info->root->sd); inode = sysfs_get_inode(sb, info->root->kn);
mutex_unlock(&sysfs_mutex); mutex_unlock(&sysfs_mutex);
if (!inode) { if (!inode) {
pr_debug("sysfs: could not get root inode\n"); pr_debug("sysfs: could not get root inode\n");
...@@ -52,8 +52,8 @@ static int sysfs_fill_super(struct super_block *sb) ...@@ -52,8 +52,8 @@ static int sysfs_fill_super(struct super_block *sb)
pr_debug("%s: could not get root dentry!\n", __func__); pr_debug("%s: could not get root dentry!\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
kernfs_get(info->root->sd); kernfs_get(info->root->kn);
root->d_fsdata = info->root->sd; root->d_fsdata = info->root->kn;
sb->s_root = root; sb->s_root = root;
sb->s_d_op = &sysfs_dentry_ops; sb->s_d_op = &sysfs_dentry_ops;
return 0; return 0;
...@@ -145,7 +145,7 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, ...@@ -145,7 +145,7 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
void kernfs_kill_sb(struct super_block *sb) void kernfs_kill_sb(struct super_block *sb)
{ {
struct sysfs_super_info *info = sysfs_info(sb); struct sysfs_super_info *info = sysfs_info(sb);
struct sysfs_dirent *root_sd = sb->s_root->d_fsdata; struct kernfs_node *root_kn = sb->s_root->d_fsdata;
/* /*
* Remove the superblock from fs_supers/s_instances * Remove the superblock from fs_supers/s_instances
...@@ -153,13 +153,13 @@ void kernfs_kill_sb(struct super_block *sb) ...@@ -153,13 +153,13 @@ void kernfs_kill_sb(struct super_block *sb)
*/ */
kill_anon_super(sb); kill_anon_super(sb);
kfree(info); kfree(info);
kernfs_put(root_sd); kernfs_put(root_kn);
} }
void __init kernfs_init(void) void __init kernfs_init(void)
{ {
sysfs_dir_cachep = kmem_cache_create("sysfs_dir_cache", sysfs_dir_cachep = kmem_cache_create("sysfs_dir_cache",
sizeof(struct sysfs_dirent), sizeof(struct kernfs_node),
0, SLAB_PANIC, NULL); 0, SLAB_PANIC, NULL);
sysfs_inode_init(); sysfs_inode_init();
} }
...@@ -22,50 +22,50 @@ ...@@ -22,50 +22,50 @@
* *
* Returns the created node on success, ERR_PTR() value on error. * Returns the created node on success, ERR_PTR() value on error.
*/ */
struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
const char *name, const char *name,
struct sysfs_dirent *target) struct kernfs_node *target)
{ {
struct sysfs_dirent *sd; struct kernfs_node *kn;
struct sysfs_addrm_cxt acxt; struct sysfs_addrm_cxt acxt;
int error; int error;
sd = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO, kn = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO,
SYSFS_KOBJ_LINK); SYSFS_KOBJ_LINK);
if (!sd) if (!kn)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (kernfs_ns_enabled(parent)) if (kernfs_ns_enabled(parent))
sd->s_ns = target->s_ns; kn->s_ns = target->s_ns;
sd->s_symlink.target_sd = target; kn->s_symlink.target_kn = target;
kernfs_get(target); /* ref owned by symlink */ kernfs_get(target); /* ref owned by symlink */
sysfs_addrm_start(&acxt); sysfs_addrm_start(&acxt);
error = sysfs_add_one(&acxt, sd, parent); error = sysfs_add_one(&acxt, kn, parent);
sysfs_addrm_finish(&acxt); sysfs_addrm_finish(&acxt);
if (!error) if (!error)
return sd; return kn;
kernfs_put(sd); kernfs_put(kn);
return ERR_PTR(error); return ERR_PTR(error);
} }
static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, static int sysfs_get_target_path(struct kernfs_node *parent,
struct sysfs_dirent *target_sd, char *path) struct kernfs_node *target, char *path)
{ {
struct sysfs_dirent *base, *sd; struct kernfs_node *base, *kn;
char *s = path; char *s = path;
int len = 0; int len = 0;
/* go up to the root, stop at the base */ /* go up to the root, stop at the base */
base = parent_sd; base = parent;
while (base->s_parent) { while (base->s_parent) {
sd = target_sd->s_parent; kn = target->s_parent;
while (sd->s_parent && base != sd) while (kn->s_parent && base != kn)
sd = sd->s_parent; kn = kn->s_parent;
if (base == sd) if (base == kn)
break; break;
strcpy(s, "../"); strcpy(s, "../");
...@@ -74,10 +74,10 @@ static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, ...@@ -74,10 +74,10 @@ static int sysfs_get_target_path(struct sysfs_dirent *parent_sd,
} }
/* determine end of target string for reverse fillup */ /* determine end of target string for reverse fillup */
sd = target_sd; kn = target;
while (sd->s_parent && sd != base) { while (kn->s_parent && kn != base) {
len += strlen(sd->s_name) + 1; len += strlen(kn->s_name) + 1;
sd = sd->s_parent; kn = kn->s_parent;
} }
/* check limits */ /* check limits */
...@@ -88,16 +88,16 @@ static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, ...@@ -88,16 +88,16 @@ static int sysfs_get_target_path(struct sysfs_dirent *parent_sd,
return -ENAMETOOLONG; return -ENAMETOOLONG;
/* reverse fillup of target string from target to base */ /* reverse fillup of target string from target to base */
sd = target_sd; kn = target;
while (sd->s_parent && sd != base) { while (kn->s_parent && kn != base) {
int slen = strlen(sd->s_name); int slen = strlen(kn->s_name);
len -= slen; len -= slen;
strncpy(s + len, sd->s_name, slen); strncpy(s + len, kn->s_name, slen);
if (len) if (len)
s[--len] = '/'; s[--len] = '/';
sd = sd->s_parent; kn = kn->s_parent;
} }
return 0; return 0;
...@@ -105,13 +105,13 @@ static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, ...@@ -105,13 +105,13 @@ static int sysfs_get_target_path(struct sysfs_dirent *parent_sd,
static int sysfs_getlink(struct dentry *dentry, char *path) static int sysfs_getlink(struct dentry *dentry, char *path)
{ {
struct sysfs_dirent *sd = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct sysfs_dirent *parent_sd = sd->s_parent; struct kernfs_node *parent = kn->s_parent;
struct sysfs_dirent *target_sd = sd->s_symlink.target_sd; struct kernfs_node *target = kn->s_symlink.target_kn;
int error; int error;
mutex_lock(&sysfs_mutex); mutex_lock(&sysfs_mutex);
error = sysfs_get_target_path(parent_sd, target_sd, path); error = sysfs_get_target_path(parent, target, path);
mutex_unlock(&sysfs_mutex); mutex_unlock(&sysfs_mutex);
return error; return error;
......
...@@ -21,23 +21,23 @@ DEFINE_SPINLOCK(sysfs_symlink_target_lock); ...@@ -21,23 +21,23 @@ DEFINE_SPINLOCK(sysfs_symlink_target_lock);
/** /**
* sysfs_pathname - return full path to sysfs dirent * sysfs_pathname - return full path to sysfs dirent
* @sd: sysfs_dirent whose path we want * @kn: kernfs_node whose path we want
* @path: caller allocated buffer of size PATH_MAX * @path: caller allocated buffer of size PATH_MAX
* *
* Gives the name "/" to the sysfs_root entry; any path returned * Gives the name "/" to the sysfs_root entry; any path returned
* is relative to wherever sysfs is mounted. * is relative to wherever sysfs is mounted.
*/ */
static char *sysfs_pathname(struct sysfs_dirent *sd, char *path) static char *sysfs_pathname(struct kernfs_node *kn, char *path)
{ {
if (sd->s_parent) { if (kn->s_parent) {
sysfs_pathname(sd->s_parent, path); sysfs_pathname(kn->s_parent, path);
strlcat(path, "/", PATH_MAX); strlcat(path, "/", PATH_MAX);
} }
strlcat(path, sd->s_name, PATH_MAX); strlcat(path, kn->s_name, PATH_MAX);
return path; return path;
} }
void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name) void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
{ {
char *path; char *path;
...@@ -61,26 +61,26 @@ void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name) ...@@ -61,26 +61,26 @@ void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name)
*/ */
int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
{ {
struct sysfs_dirent *parent_sd, *sd; struct kernfs_node *parent, *kn;
BUG_ON(!kobj); BUG_ON(!kobj);
if (kobj->parent) if (kobj->parent)
parent_sd = kobj->parent->sd; parent = kobj->parent->sd;
else else
parent_sd = sysfs_root_sd; parent = sysfs_root_kn;
if (!parent_sd) if (!parent)
return -ENOENT; return -ENOENT;
sd = kernfs_create_dir_ns(parent_sd, kobject_name(kobj), kobj, ns); kn = kernfs_create_dir_ns(parent, kobject_name(kobj), kobj, ns);
if (IS_ERR(sd)) { if (IS_ERR(kn)) {
if (PTR_ERR(sd) == -EEXIST) if (PTR_ERR(kn) == -EEXIST)
sysfs_warn_dup(parent_sd, kobject_name(kobj)); sysfs_warn_dup(parent, kobject_name(kobj));
return PTR_ERR(sd); return PTR_ERR(kn);
} }
kobj->sd = sd; kobj->sd = kn;
return 0; return 0;
} }
...@@ -94,47 +94,47 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) ...@@ -94,47 +94,47 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
*/ */
void sysfs_remove_dir(struct kobject *kobj) void sysfs_remove_dir(struct kobject *kobj)
{ {
struct sysfs_dirent *sd = kobj->sd; struct kernfs_node *kn = kobj->sd;
/* /*
* In general, kboject owner is responsible for ensuring removal * In general, kboject owner is responsible for ensuring removal
* doesn't race with other operations and sysfs doesn't provide any * doesn't race with other operations and sysfs doesn't provide any
* protection; however, when @kobj is used as a symlink target, the * protection; however, when @kobj is used as a symlink target, the
* symlinking entity usually doesn't own @kobj and thus has no * symlinking entity usually doesn't own @kobj and thus has no
* control over removal. @kobj->sd may be removed anytime and * control over removal. @kobj->sd may be removed anytime
* symlink code may end up dereferencing an already freed sd. * and symlink code may end up dereferencing an already freed node.
* *
* sysfs_symlink_target_lock synchronizes @kobj->sd disassociation * sysfs_symlink_target_lock synchronizes @kobj->sd
* against symlink operations so that symlink code can safely * disassociation against symlink operations so that symlink code
* dereference @kobj->sd. * can safely dereference @kobj->sd.
*/ */
spin_lock(&sysfs_symlink_target_lock); spin_lock(&sysfs_symlink_target_lock);
kobj->sd = NULL; kobj->sd = NULL;
spin_unlock(&sysfs_symlink_target_lock); spin_unlock(&sysfs_symlink_target_lock);
if (sd) { if (kn) {
WARN_ON_ONCE(sysfs_type(sd) != SYSFS_DIR); WARN_ON_ONCE(sysfs_type(kn) != SYSFS_DIR);
kernfs_remove(sd); kernfs_remove(kn);
} }
} }
int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
const void *new_ns) const void *new_ns)
{ {
struct sysfs_dirent *parent_sd = kobj->sd->s_parent; struct kernfs_node *parent = kobj->sd->s_parent;
return kernfs_rename_ns(kobj->sd, parent_sd, new_name, new_ns); return kernfs_rename_ns(kobj->sd, parent, new_name, new_ns);
} }
int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj, int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,
const void *new_ns) const void *new_ns)
{ {
struct sysfs_dirent *sd = kobj->sd; struct kernfs_node *kn = kobj->sd;
struct sysfs_dirent *new_parent_sd; struct kernfs_node *new_parent;
BUG_ON(!sd->s_parent); BUG_ON(!kn->s_parent);
new_parent_sd = new_parent_kobj && new_parent_kobj->sd ? new_parent = new_parent_kobj && new_parent_kobj->sd ?
new_parent_kobj->sd : sysfs_root_sd; new_parent_kobj->sd : sysfs_root_kn;
return kernfs_rename_ns(sd, new_parent_sd, sd->s_name, new_ns); return kernfs_rename_ns(kn, new_parent, kn->s_name, new_ns);
} }
...@@ -22,15 +22,15 @@ ...@@ -22,15 +22,15 @@
#include "../kernfs/kernfs-internal.h" #include "../kernfs/kernfs-internal.h"
/* /*
* Determine ktype->sysfs_ops for the given sysfs_dirent. This function * Determine ktype->sysfs_ops for the given kernfs_node. This function
* must be called while holding an active reference. * must be called while holding an active reference.
*/ */
static const struct sysfs_ops *sysfs_file_ops(struct sysfs_dirent *sd) static const struct sysfs_ops *sysfs_file_ops(struct kernfs_node *kn)
{ {
struct kobject *kobj = sd->s_parent->priv; struct kobject *kobj = kn->s_parent->priv;
if (sd->s_flags & SYSFS_FLAG_LOCKDEP) if (kn->s_flags & SYSFS_FLAG_LOCKDEP)
lockdep_assert_held(sd); lockdep_assert_held(kn);
return kobj->ktype ? kobj->ktype->sysfs_ops : NULL; return kobj->ktype ? kobj->ktype->sysfs_ops : NULL;
} }
...@@ -42,8 +42,8 @@ static const struct sysfs_ops *sysfs_file_ops(struct sysfs_dirent *sd) ...@@ -42,8 +42,8 @@ static const struct sysfs_ops *sysfs_file_ops(struct sysfs_dirent *sd)
static int sysfs_kf_seq_show(struct seq_file *sf, void *v) static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
{ {
struct sysfs_open_file *of = sf->private; struct sysfs_open_file *of = sf->private;
struct kobject *kobj = of->sd->s_parent->priv; struct kobject *kobj = of->kn->s_parent->priv;
const struct sysfs_ops *ops = sysfs_file_ops(of->sd); const struct sysfs_ops *ops = sysfs_file_ops(of->kn);
ssize_t count; ssize_t count;
char *buf; char *buf;
...@@ -59,7 +59,7 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v) ...@@ -59,7 +59,7 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
* if @ops->show() isn't implemented. * if @ops->show() isn't implemented.
*/ */
if (ops->show) { if (ops->show) {
count = ops->show(kobj, of->sd->priv, buf); count = ops->show(kobj, of->kn->priv, buf);
if (count < 0) if (count < 0)
return count; return count;
} }
...@@ -81,8 +81,8 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v) ...@@ -81,8 +81,8 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf, static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf,
size_t count, loff_t pos) size_t count, loff_t pos)
{ {
struct bin_attribute *battr = of->sd->priv; struct bin_attribute *battr = of->kn->priv;
struct kobject *kobj = of->sd->s_parent->priv; struct kobject *kobj = of->kn->s_parent->priv;
loff_t size = file_inode(of->file)->i_size; loff_t size = file_inode(of->file)->i_size;
if (!count) if (!count)
...@@ -105,21 +105,21 @@ static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf, ...@@ -105,21 +105,21 @@ static ssize_t sysfs_kf_bin_read(struct sysfs_open_file *of, char *buf,
static ssize_t sysfs_kf_write(struct sysfs_open_file *of, char *buf, static ssize_t sysfs_kf_write(struct sysfs_open_file *of, char *buf,
size_t count, loff_t pos) size_t count, loff_t pos)
{ {
const struct sysfs_ops *ops = sysfs_file_ops(of->sd); const struct sysfs_ops *ops = sysfs_file_ops(of->kn);
struct kobject *kobj = of->sd->s_parent->priv; struct kobject *kobj = of->kn->s_parent->priv;
if (!count) if (!count)
return 0; return 0;
return ops->store(kobj, of->sd->priv, buf, count); return ops->store(kobj, of->kn->priv, buf, count);
} }
/* kernfs write callback for bin sysfs files */ /* kernfs write callback for bin sysfs files */
static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf, static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf,
size_t count, loff_t pos) size_t count, loff_t pos)
{ {
struct bin_attribute *battr = of->sd->priv; struct bin_attribute *battr = of->kn->priv;
struct kobject *kobj = of->sd->s_parent->priv; struct kobject *kobj = of->kn->s_parent->priv;
loff_t size = file_inode(of->file)->i_size; loff_t size = file_inode(of->file)->i_size;
if (size) { if (size) {
...@@ -139,30 +139,30 @@ static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf, ...@@ -139,30 +139,30 @@ static ssize_t sysfs_kf_bin_write(struct sysfs_open_file *of, char *buf,
static int sysfs_kf_bin_mmap(struct sysfs_open_file *of, static int sysfs_kf_bin_mmap(struct sysfs_open_file *of,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
struct bin_attribute *battr = of->sd->priv; struct bin_attribute *battr = of->kn->priv;
struct kobject *kobj = of->sd->s_parent->priv; struct kobject *kobj = of->kn->s_parent->priv;
return battr->mmap(of->file, kobj, battr, vma); return battr->mmap(of->file, kobj, battr, vma);
} }
void sysfs_notify(struct kobject *k, const char *dir, const char *attr) void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr)
{ {
struct sysfs_dirent *sd = k->sd, *tmp; struct kernfs_node *kn = kobj->sd, *tmp;
if (sd && dir) if (kn && dir)
sd = kernfs_find_and_get(sd, dir); kn = kernfs_find_and_get(kn, dir);
else else
kernfs_get(sd); kernfs_get(kn);
if (sd && attr) { if (kn && attr) {
tmp = kernfs_find_and_get(sd, attr); tmp = kernfs_find_and_get(kn, attr);
kernfs_put(sd); kernfs_put(kn);
sd = tmp; kn = tmp;
} }
if (sd) { if (kn) {
kernfs_notify(sd); kernfs_notify(kn);
kernfs_put(sd); kernfs_put(kn);
} }
} }
EXPORT_SYMBOL_GPL(sysfs_notify); EXPORT_SYMBOL_GPL(sysfs_notify);
...@@ -202,17 +202,17 @@ static const struct kernfs_ops sysfs_bin_kfops_mmap = { ...@@ -202,17 +202,17 @@ static const struct kernfs_ops sysfs_bin_kfops_mmap = {
.mmap = sysfs_kf_bin_mmap, .mmap = sysfs_kf_bin_mmap,
}; };
int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, int sysfs_add_file_mode_ns(struct kernfs_node *parent,
const struct attribute *attr, bool is_bin, const struct attribute *attr, bool is_bin,
umode_t mode, const void *ns) umode_t mode, const void *ns)
{ {
struct lock_class_key *key = NULL; struct lock_class_key *key = NULL;
const struct kernfs_ops *ops; const struct kernfs_ops *ops;
struct sysfs_dirent *sd; struct kernfs_node *kn;
loff_t size; loff_t size;
if (!is_bin) { if (!is_bin) {
struct kobject *kobj = dir_sd->priv; struct kobject *kobj = parent->priv;
const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops; const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops;
/* every kobject with an attribute needs a ktype assigned */ /* every kobject with an attribute needs a ktype assigned */
...@@ -252,20 +252,20 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, ...@@ -252,20 +252,20 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
if (!attr->ignore_lockdep) if (!attr->ignore_lockdep)
key = attr->key ?: (struct lock_class_key *)&attr->skey; key = attr->key ?: (struct lock_class_key *)&attr->skey;
#endif #endif
sd = kernfs_create_file_ns_key(dir_sd, attr->name, mode, size, kn = kernfs_create_file_ns_key(parent, attr->name, mode, size,
ops, (void *)attr, ns, key); ops, (void *)attr, ns, key);
if (IS_ERR(sd)) { if (IS_ERR(kn)) {
if (PTR_ERR(sd) == -EEXIST) if (PTR_ERR(kn) == -EEXIST)
sysfs_warn_dup(dir_sd, attr->name); sysfs_warn_dup(parent, attr->name);
return PTR_ERR(sd); return PTR_ERR(kn);
} }
return 0; return 0;
} }
int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, int sysfs_add_file(struct kernfs_node *parent, const struct attribute *attr,
bool is_bin) bool is_bin)
{ {
return sysfs_add_file_mode_ns(dir_sd, attr, is_bin, attr->mode, NULL); return sysfs_add_file_mode_ns(parent, attr, is_bin, attr->mode, NULL);
} }
/** /**
...@@ -307,21 +307,21 @@ EXPORT_SYMBOL_GPL(sysfs_create_files); ...@@ -307,21 +307,21 @@ EXPORT_SYMBOL_GPL(sysfs_create_files);
int sysfs_add_file_to_group(struct kobject *kobj, int sysfs_add_file_to_group(struct kobject *kobj,
const struct attribute *attr, const char *group) const struct attribute *attr, const char *group)
{ {
struct sysfs_dirent *dir_sd; struct kernfs_node *parent;
int error; int error;
if (group) { if (group) {
dir_sd = kernfs_find_and_get(kobj->sd, group); parent = kernfs_find_and_get(kobj->sd, group);
} else { } else {
dir_sd = kobj->sd; parent = kobj->sd;
kernfs_get(dir_sd); kernfs_get(parent);
} }
if (!dir_sd) if (!parent)
return -ENOENT; return -ENOENT;
error = sysfs_add_file(dir_sd, attr, false); error = sysfs_add_file(parent, attr, false);
kernfs_put(dir_sd); kernfs_put(parent);
return error; return error;
} }
...@@ -337,20 +337,20 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group); ...@@ -337,20 +337,20 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group);
int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr, int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr,
umode_t mode) umode_t mode)
{ {
struct sysfs_dirent *sd; struct kernfs_node *kn;
struct iattr newattrs; struct iattr newattrs;
int rc; int rc;
sd = kernfs_find_and_get(kobj->sd, attr->name); kn = kernfs_find_and_get(kobj->sd, attr->name);
if (!sd) if (!kn)
return -ENOENT; return -ENOENT;
newattrs.ia_mode = (mode & S_IALLUGO) | (sd->s_mode & ~S_IALLUGO); newattrs.ia_mode = (mode & S_IALLUGO) | (kn->s_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE; newattrs.ia_valid = ATTR_MODE;
rc = kernfs_setattr(sd, &newattrs); rc = kernfs_setattr(kn, &newattrs);
kernfs_put(sd); kernfs_put(kn);
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(sysfs_chmod_file); EXPORT_SYMBOL_GPL(sysfs_chmod_file);
...@@ -366,9 +366,9 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file); ...@@ -366,9 +366,9 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file);
void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
const void *ns) const void *ns)
{ {
struct sysfs_dirent *dir_sd = kobj->sd; struct kernfs_node *parent = kobj->sd;
kernfs_remove_by_name_ns(dir_sd, attr->name, ns); kernfs_remove_by_name_ns(parent, attr->name, ns);
} }
EXPORT_SYMBOL_GPL(sysfs_remove_file_ns); EXPORT_SYMBOL_GPL(sysfs_remove_file_ns);
...@@ -389,18 +389,18 @@ EXPORT_SYMBOL_GPL(sysfs_remove_files); ...@@ -389,18 +389,18 @@ EXPORT_SYMBOL_GPL(sysfs_remove_files);
void sysfs_remove_file_from_group(struct kobject *kobj, void sysfs_remove_file_from_group(struct kobject *kobj,
const struct attribute *attr, const char *group) const struct attribute *attr, const char *group)
{ {
struct sysfs_dirent *dir_sd; struct kernfs_node *parent;
if (group) { if (group) {
dir_sd = kernfs_find_and_get(kobj->sd, group); parent = kernfs_find_and_get(kobj->sd, group);
} else { } else {
dir_sd = kobj->sd; parent = kobj->sd;
kernfs_get(dir_sd); kernfs_get(parent);
} }
if (dir_sd) { if (parent) {
kernfs_remove_by_name(dir_sd, attr->name); kernfs_remove_by_name(parent, attr->name);
kernfs_put(dir_sd); kernfs_put(parent);
} }
} }
EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group); EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "sysfs.h" #include "sysfs.h"
static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, static void remove_files(struct kernfs_node *parent, struct kobject *kobj,
const struct attribute_group *grp) const struct attribute_group *grp)
{ {
struct attribute *const *attr; struct attribute *const *attr;
...@@ -26,13 +26,13 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, ...@@ -26,13 +26,13 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
if (grp->attrs) if (grp->attrs)
for (attr = grp->attrs; *attr; attr++) for (attr = grp->attrs; *attr; attr++)
kernfs_remove_by_name(dir_sd, (*attr)->name); kernfs_remove_by_name(parent, (*attr)->name);
if (grp->bin_attrs) if (grp->bin_attrs)
for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++)
sysfs_remove_bin_file(kobj, *bin_attr); sysfs_remove_bin_file(kobj, *bin_attr);
} }
static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, static int create_files(struct kernfs_node *parent, struct kobject *kobj,
const struct attribute_group *grp, int update) const struct attribute_group *grp, int update)
{ {
struct attribute *const *attr; struct attribute *const *attr;
...@@ -49,20 +49,20 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, ...@@ -49,20 +49,20 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
* re-adding (if required) the file. * re-adding (if required) the file.
*/ */
if (update) if (update)
kernfs_remove_by_name(dir_sd, (*attr)->name); kernfs_remove_by_name(parent, (*attr)->name);
if (grp->is_visible) { if (grp->is_visible) {
mode = grp->is_visible(kobj, *attr, i); mode = grp->is_visible(kobj, *attr, i);
if (!mode) if (!mode)
continue; continue;
} }
error = sysfs_add_file_mode_ns(dir_sd, *attr, false, error = sysfs_add_file_mode_ns(parent, *attr, false,
(*attr)->mode | mode, (*attr)->mode | mode,
NULL); NULL);
if (unlikely(error)) if (unlikely(error))
break; break;
} }
if (error) { if (error) {
remove_files(dir_sd, kobj, grp); remove_files(parent, kobj, grp);
goto exit; goto exit;
} }
} }
...@@ -76,7 +76,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, ...@@ -76,7 +76,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
break; break;
} }
if (error) if (error)
remove_files(dir_sd, kobj, grp); remove_files(parent, kobj, grp);
} }
exit: exit:
return error; return error;
...@@ -86,7 +86,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, ...@@ -86,7 +86,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
static int internal_create_group(struct kobject *kobj, int update, static int internal_create_group(struct kobject *kobj, int update,
const struct attribute_group *grp) const struct attribute_group *grp)
{ {
struct sysfs_dirent *sd; struct kernfs_node *kn;
int error; int error;
BUG_ON(!kobj || (!update && !kobj->sd)); BUG_ON(!kobj || (!update && !kobj->sd));
...@@ -100,21 +100,21 @@ static int internal_create_group(struct kobject *kobj, int update, ...@@ -100,21 +100,21 @@ static int internal_create_group(struct kobject *kobj, int update,
return -EINVAL; return -EINVAL;
} }
if (grp->name) { if (grp->name) {
sd = kernfs_create_dir(kobj->sd, grp->name, kobj); kn = kernfs_create_dir(kobj->sd, grp->name, kobj);
if (IS_ERR(sd)) { if (IS_ERR(kn)) {
if (PTR_ERR(sd) == -EEXIST) if (PTR_ERR(kn) == -EEXIST)
sysfs_warn_dup(kobj->sd, grp->name); sysfs_warn_dup(kobj->sd, grp->name);
return PTR_ERR(sd); return PTR_ERR(kn);
} }
} else } else
sd = kobj->sd; kn = kobj->sd;
kernfs_get(sd); kernfs_get(kn);
error = create_files(sd, kobj, grp, update); error = create_files(kn, kobj, grp, update);
if (error) { if (error) {
if (grp->name) if (grp->name)
kernfs_remove(sd); kernfs_remove(kn);
} }
kernfs_put(sd); kernfs_put(kn);
return error; return error;
} }
...@@ -204,27 +204,27 @@ EXPORT_SYMBOL_GPL(sysfs_update_group); ...@@ -204,27 +204,27 @@ EXPORT_SYMBOL_GPL(sysfs_update_group);
void sysfs_remove_group(struct kobject *kobj, void sysfs_remove_group(struct kobject *kobj,
const struct attribute_group *grp) const struct attribute_group *grp)
{ {
struct sysfs_dirent *dir_sd = kobj->sd; struct kernfs_node *parent = kobj->sd;
struct sysfs_dirent *sd; struct kernfs_node *kn;
if (grp->name) { if (grp->name) {
sd = kernfs_find_and_get(dir_sd, grp->name); kn = kernfs_find_and_get(parent, grp->name);
if (!sd) { if (!kn) {
WARN(!sd, KERN_WARNING WARN(!kn, KERN_WARNING
"sysfs group %p not found for kobject '%s'\n", "sysfs group %p not found for kobject '%s'\n",
grp, kobject_name(kobj)); grp, kobject_name(kobj));
return; return;
} }
} else { } else {
sd = dir_sd; kn = parent;
kernfs_get(sd); kernfs_get(kn);
} }
remove_files(sd, kobj, grp); remove_files(kn, kobj, grp);
if (grp->name) if (grp->name)
kernfs_remove(sd); kernfs_remove(kn);
kernfs_put(sd); kernfs_put(kn);
} }
EXPORT_SYMBOL_GPL(sysfs_remove_group); EXPORT_SYMBOL_GPL(sysfs_remove_group);
...@@ -260,22 +260,22 @@ EXPORT_SYMBOL_GPL(sysfs_remove_groups); ...@@ -260,22 +260,22 @@ EXPORT_SYMBOL_GPL(sysfs_remove_groups);
int sysfs_merge_group(struct kobject *kobj, int sysfs_merge_group(struct kobject *kobj,
const struct attribute_group *grp) const struct attribute_group *grp)
{ {
struct sysfs_dirent *dir_sd; struct kernfs_node *parent;
int error = 0; int error = 0;
struct attribute *const *attr; struct attribute *const *attr;
int i; int i;
dir_sd = kernfs_find_and_get(kobj->sd, grp->name); parent = kernfs_find_and_get(kobj->sd, grp->name);
if (!dir_sd) if (!parent)
return -ENOENT; return -ENOENT;
for ((i = 0, attr = grp->attrs); *attr && !error; (++i, ++attr)) for ((i = 0, attr = grp->attrs); *attr && !error; (++i, ++attr))
error = sysfs_add_file(dir_sd, *attr, false); error = sysfs_add_file(parent, *attr, false);
if (error) { if (error) {
while (--i >= 0) while (--i >= 0)
kernfs_remove_by_name(dir_sd, (*--attr)->name); kernfs_remove_by_name(parent, (*--attr)->name);
} }
kernfs_put(dir_sd); kernfs_put(parent);
return error; return error;
} }
...@@ -289,14 +289,14 @@ EXPORT_SYMBOL_GPL(sysfs_merge_group); ...@@ -289,14 +289,14 @@ EXPORT_SYMBOL_GPL(sysfs_merge_group);
void sysfs_unmerge_group(struct kobject *kobj, void sysfs_unmerge_group(struct kobject *kobj,
const struct attribute_group *grp) const struct attribute_group *grp)
{ {
struct sysfs_dirent *dir_sd; struct kernfs_node *parent;
struct attribute *const *attr; struct attribute *const *attr;
dir_sd = kernfs_find_and_get(kobj->sd, grp->name); parent = kernfs_find_and_get(kobj->sd, grp->name);
if (dir_sd) { if (parent) {
for (attr = grp->attrs; *attr; ++attr) for (attr = grp->attrs; *attr; ++attr)
kernfs_remove_by_name(dir_sd, (*attr)->name); kernfs_remove_by_name(parent, (*attr)->name);
kernfs_put(dir_sd); kernfs_put(parent);
} }
} }
EXPORT_SYMBOL_GPL(sysfs_unmerge_group); EXPORT_SYMBOL_GPL(sysfs_unmerge_group);
...@@ -311,15 +311,15 @@ EXPORT_SYMBOL_GPL(sysfs_unmerge_group); ...@@ -311,15 +311,15 @@ EXPORT_SYMBOL_GPL(sysfs_unmerge_group);
int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name, int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
struct kobject *target, const char *link_name) struct kobject *target, const char *link_name)
{ {
struct sysfs_dirent *dir_sd; struct kernfs_node *parent;
int error = 0; int error = 0;
dir_sd = kernfs_find_and_get(kobj->sd, group_name); parent = kernfs_find_and_get(kobj->sd, group_name);
if (!dir_sd) if (!parent)
return -ENOENT; return -ENOENT;
error = sysfs_create_link_sd(dir_sd, target, link_name); error = sysfs_create_link_sd(parent, target, link_name);
kernfs_put(dir_sd); kernfs_put(parent);
return error; return error;
} }
...@@ -334,12 +334,12 @@ EXPORT_SYMBOL_GPL(sysfs_add_link_to_group); ...@@ -334,12 +334,12 @@ EXPORT_SYMBOL_GPL(sysfs_add_link_to_group);
void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name, void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
const char *link_name) const char *link_name)
{ {
struct sysfs_dirent *dir_sd; struct kernfs_node *parent;
dir_sd = kernfs_find_and_get(kobj->sd, group_name); parent = kernfs_find_and_get(kobj->sd, group_name);
if (dir_sd) { if (parent) {
kernfs_remove_by_name(dir_sd, link_name); kernfs_remove_by_name(parent, link_name);
kernfs_put(dir_sd); kernfs_put(parent);
} }
} }
EXPORT_SYMBOL_GPL(sysfs_remove_link_from_group); EXPORT_SYMBOL_GPL(sysfs_remove_link_from_group);
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "sysfs.h" #include "sysfs.h"
static struct kernfs_root *sysfs_root; static struct kernfs_root *sysfs_root;
struct sysfs_dirent *sysfs_root_sd; struct kernfs_node *sysfs_root_kn;
static struct dentry *sysfs_mount(struct file_system_type *fs_type, static struct dentry *sysfs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data) int flags, const char *dev_name, void *data)
...@@ -66,7 +66,7 @@ int __init sysfs_init(void) ...@@ -66,7 +66,7 @@ int __init sysfs_init(void)
if (IS_ERR(sysfs_root)) if (IS_ERR(sysfs_root))
return PTR_ERR(sysfs_root); return PTR_ERR(sysfs_root);
sysfs_root_sd = sysfs_root->sd; sysfs_root_kn = sysfs_root->kn;
err = register_filesystem(&sysfs_fs_type); err = register_filesystem(&sysfs_fs_type);
if (err) { if (err) {
......
...@@ -18,66 +18,66 @@ ...@@ -18,66 +18,66 @@
#include "sysfs.h" #include "sysfs.h"
static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd, static int sysfs_do_create_link_sd(struct kernfs_node *parent,
struct kobject *target, struct kobject *target_kobj,
const char *name, int warn) const char *name, int warn)
{ {
struct sysfs_dirent *sd, *target_sd = NULL; struct kernfs_node *kn, *target = NULL;
BUG_ON(!name || !parent_sd); BUG_ON(!name || !parent);
/* /*
* We don't own @target and it may be removed at any time. * We don't own @target_kobj and it may be removed at any time.
* Synchronize using sysfs_symlink_target_lock. See * Synchronize using sysfs_symlink_target_lock. See
* sysfs_remove_dir() for details. * sysfs_remove_dir() for details.
*/ */
spin_lock(&sysfs_symlink_target_lock); spin_lock(&sysfs_symlink_target_lock);
if (target->sd) { if (target_kobj->sd) {
target_sd = target->sd; target = target_kobj->sd;
kernfs_get(target_sd); kernfs_get(target);
} }
spin_unlock(&sysfs_symlink_target_lock); spin_unlock(&sysfs_symlink_target_lock);
if (!target_sd) if (!target)
return -ENOENT; return -ENOENT;
sd = kernfs_create_link(parent_sd, name, target_sd); kn = kernfs_create_link(parent, name, target);
kernfs_put(target_sd); kernfs_put(target);
if (!IS_ERR(sd)) if (!IS_ERR(kn))
return 0; return 0;
if (warn && PTR_ERR(sd) == -EEXIST) if (warn && PTR_ERR(kn) == -EEXIST)
sysfs_warn_dup(parent_sd, name); sysfs_warn_dup(parent, name);
return PTR_ERR(sd); return PTR_ERR(kn);
} }
/** /**
* sysfs_create_link_sd - create symlink to a given object. * sysfs_create_link_sd - create symlink to a given object.
* @sd: directory we're creating the link in. * @kn: directory we're creating the link in.
* @target: object we're pointing to. * @target: object we're pointing to.
* @name: name of the symlink. * @name: name of the symlink.
*/ */
int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target, int sysfs_create_link_sd(struct kernfs_node *kn, struct kobject *target,
const char *name) const char *name)
{ {
return sysfs_do_create_link_sd(sd, target, name, 1); return sysfs_do_create_link_sd(kn, target, name, 1);
} }
static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target, static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
const char *name, int warn) const char *name, int warn)
{ {
struct sysfs_dirent *parent_sd = NULL; struct kernfs_node *parent = NULL;
if (!kobj) if (!kobj)
parent_sd = sysfs_root_sd; parent = sysfs_root_kn;
else else
parent_sd = kobj->sd; parent = kobj->sd;
if (!parent_sd) if (!parent)
return -EFAULT; return -EFAULT;
return sysfs_do_create_link_sd(parent_sd, target, name, warn); return sysfs_do_create_link_sd(parent, target, name, warn);
} }
/** /**
...@@ -141,14 +141,14 @@ void sysfs_delete_link(struct kobject *kobj, struct kobject *targ, ...@@ -141,14 +141,14 @@ void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,
*/ */
void sysfs_remove_link(struct kobject *kobj, const char *name) void sysfs_remove_link(struct kobject *kobj, const char *name)
{ {
struct sysfs_dirent *parent_sd = NULL; struct kernfs_node *parent = NULL;
if (!kobj) if (!kobj)
parent_sd = sysfs_root_sd; parent = sysfs_root_kn;
else else
parent_sd = kobj->sd; parent = kobj->sd;
kernfs_remove_by_name(parent_sd, name); kernfs_remove_by_name(parent, name);
} }
EXPORT_SYMBOL_GPL(sysfs_remove_link); EXPORT_SYMBOL_GPL(sysfs_remove_link);
...@@ -165,33 +165,33 @@ EXPORT_SYMBOL_GPL(sysfs_remove_link); ...@@ -165,33 +165,33 @@ EXPORT_SYMBOL_GPL(sysfs_remove_link);
int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ, int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ,
const char *old, const char *new, const void *new_ns) const char *old, const char *new, const void *new_ns)
{ {
struct sysfs_dirent *parent_sd, *sd = NULL; struct kernfs_node *parent, *kn = NULL;
const void *old_ns = NULL; const void *old_ns = NULL;
int result; int result;
if (!kobj) if (!kobj)
parent_sd = sysfs_root_sd; parent = sysfs_root_kn;
else else
parent_sd = kobj->sd; parent = kobj->sd;
if (targ->sd) if (targ->sd)
old_ns = targ->sd->s_ns; old_ns = targ->sd->s_ns;
result = -ENOENT; result = -ENOENT;
sd = kernfs_find_and_get_ns(parent_sd, old, old_ns); kn = kernfs_find_and_get_ns(parent, old, old_ns);
if (!sd) if (!kn)
goto out; goto out;
result = -EINVAL; result = -EINVAL;
if (sysfs_type(sd) != SYSFS_KOBJ_LINK) if (sysfs_type(kn) != SYSFS_KOBJ_LINK)
goto out; goto out;
if (sd->s_symlink.target_sd->priv != targ) if (kn->s_symlink.target_kn->priv != targ)
goto out; goto out;
result = kernfs_rename_ns(sd, parent_sd, new, new_ns); result = kernfs_rename_ns(kn, parent, new, new_ns);
out: out:
kernfs_put(sd); kernfs_put(kn);
return result; return result;
} }
EXPORT_SYMBOL_GPL(sysfs_rename_link_ns); EXPORT_SYMBOL_GPL(sysfs_rename_link_ns);
...@@ -16,28 +16,28 @@ ...@@ -16,28 +16,28 @@
/* /*
* mount.c * mount.c
*/ */
extern struct sysfs_dirent *sysfs_root_sd; extern struct kernfs_node *sysfs_root_kn;
/* /*
* dir.c * dir.c
*/ */
extern spinlock_t sysfs_symlink_target_lock; extern spinlock_t sysfs_symlink_target_lock;
void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name); void sysfs_warn_dup(struct kernfs_node *parent, const char *name);
/* /*
* file.c * file.c
*/ */
int sysfs_add_file(struct sysfs_dirent *dir_sd, int sysfs_add_file(struct kernfs_node *parent,
const struct attribute *attr, bool is_bin); const struct attribute *attr, bool is_bin);
int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, int sysfs_add_file_mode_ns(struct kernfs_node *parent,
const struct attribute *attr, bool is_bin, const struct attribute *attr, bool is_bin,
umode_t amode, const void *ns); umode_t amode, const void *ns);
/* /*
* symlink.c * symlink.c
*/ */
int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target, int sysfs_create_link_sd(struct kernfs_node *kn, struct kobject *target,
const char *name); const char *name);
#endif /* __SYSFS_INTERNAL_H */ #endif /* __SYSFS_INTERNAL_H */
This diff is collapsed.
...@@ -64,7 +64,7 @@ struct kobject { ...@@ -64,7 +64,7 @@ struct kobject {
struct kobject *parent; struct kobject *parent;
struct kset *kset; struct kset *kset;
struct kobj_type *ktype; struct kobj_type *ktype;
struct sysfs_dirent *sd; struct kernfs_node *sd;
struct kref kref; struct kref kref;
#ifdef CONFIG_DEBUG_KOBJECT_RELEASE #ifdef CONFIG_DEBUG_KOBJECT_RELEASE
struct delayed_work release; struct delayed_work release;
......
...@@ -438,26 +438,26 @@ static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target ...@@ -438,26 +438,26 @@ static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target
return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL); return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
} }
static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) static inline void sysfs_notify_dirent(struct kernfs_node *kn)
{ {
kernfs_notify(sd); kernfs_notify(kn);
} }
static inline struct sysfs_dirent * static inline struct kernfs_node *sysfs_get_dirent(struct kernfs_node *parent,
sysfs_get_dirent(struct sysfs_dirent *parent_sd, const unsigned char *name) const unsigned char *name)
{ {
return kernfs_find_and_get(parent_sd, name); return kernfs_find_and_get(parent, name);
} }
static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) static inline struct kernfs_node *sysfs_get(struct kernfs_node *kn)
{ {
kernfs_get(sd); kernfs_get(kn);
return sd; return kn;
} }
static inline void sysfs_put(struct sysfs_dirent *sd) static inline void sysfs_put(struct kernfs_node *kn)
{ {
kernfs_put(sd); kernfs_put(kn);
} }
#endif /* _SYSFS_H_ */ #endif /* _SYSFS_H_ */
...@@ -556,7 +556,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) ...@@ -556,7 +556,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
*/ */
void kobject_del(struct kobject *kobj) void kobject_del(struct kobject *kobj)
{ {
struct sysfs_dirent *sd; struct kernfs_node *sd;
if (!kobj) if (!kobj)
return; return;
......
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