#include "kernfs-internal.h"
-DEFINE_MUTEX(sysfs_mutex);
+DEFINE_MUTEX(kernfs_mutex);
#define rb_to_kn(X) rb_entry((X), struct kernfs_node, rb)
* @kn->parent->dir.children.
*
* Locking:
- * mutex_lock(sysfs_mutex)
+ * mutex_lock(kernfs_mutex)
*
* RETURNS:
* 0 on susccess -EEXIST on failure.
* kn->parent->dir.children.
*
* Locking:
- * mutex_lock(sysfs_mutex)
+ * mutex_lock(kernfs_mutex)
*/
static void sysfs_unlink_sibling(struct kernfs_node *kn)
{
}
kfree(kn->iattr);
ida_simple_remove(&root->ino_ida, kn->ino);
- kmem_cache_free(sysfs_dir_cachep, kn);
+ kmem_cache_free(kernfs_node_cache, kn);
kn = parent;
if (kn) {
return -ECHILD;
kn = dentry->d_fsdata;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
/* The sysfs dirent has been deleted */
if (kn->flags & KERNFS_REMOVED)
kernfs_info(dentry->d_sb)->ns != kn->ns)
goto out_bad;
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
out_valid:
return 1;
out_bad:
* is performed at its new name the dentry will be readded
* to the dcache hashes.
*/
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
/* If we have submounts we must allow the vfs caches
* to lie about the state of the filesystem to prevent
kernfs_put(dentry->d_fsdata);
}
-const struct dentry_operations sysfs_dentry_ops = {
+const struct dentry_operations kernfs_dops = {
.d_revalidate = sysfs_dentry_revalidate,
.d_delete = sysfs_dentry_delete,
.d_release = sysfs_dentry_release,
return NULL;
}
- kn = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL);
+ kn = kmem_cache_zalloc(kernfs_node_cache, GFP_KERNEL);
if (!kn)
goto err_out1;
return kn;
err_out2:
- kmem_cache_free(sysfs_dir_cachep, kn);
+ kmem_cache_free(kernfs_node_cache, kn);
err_out1:
kfree(dup_name);
return NULL;
* @acxt: pointer to kernfs_addrm_cxt to be used
*
* This function is called when the caller is about to add or remove
- * kernfs_node. This function acquires sysfs_mutex. @acxt is used to
- * keep and pass context to other addrm functions.
+ * kernfs_node. This function acquires kernfs_mutex. @acxt is used
+ * to keep and pass context to other addrm functions.
*
* LOCKING:
- * Kernel thread context (may sleep). sysfs_mutex is locked on
+ * Kernel thread context (may sleep). kernfs_mutex is locked on
* return.
*/
void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt)
- __acquires(sysfs_mutex)
+ __acquires(kernfs_mutex)
{
memset(acxt, 0, sizeof(*acxt));
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
}
/**
* cleaned up.
*
* LOCKING:
- * sysfs_mutex is released.
+ * kernfs_mutex is released.
*/
void sysfs_addrm_finish(struct kernfs_addrm_cxt *acxt)
- __releases(sysfs_mutex)
+ __releases(kernfs_mutex)
{
/* release resources acquired by sysfs_addrm_start() */
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
/* kill removed kernfs_nodes */
while (acxt->removed) {
bool has_ns = kernfs_ns_enabled(parent);
unsigned int hash;
- lockdep_assert_held(&sysfs_mutex);
+ lockdep_assert_held(&kernfs_mutex);
if (has_ns != (bool)ns) {
WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n",
{
struct kernfs_node *kn;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
kn = kernfs_find_ns(parent, name, ns);
kernfs_get(kn);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
return kn;
}
struct inode *inode;
const void *ns = NULL;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
if (kernfs_ns_enabled(parent))
ns = kernfs_info(dir->i_sb)->ns;
/* instantiate and hash dentry */
ret = d_materialise_unique(dentry, inode);
out_unlock:
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
return ret;
}
-const struct inode_operations sysfs_dir_inode_operations = {
+const struct inode_operations kernfs_dir_iops = {
.lookup = sysfs_lookup,
.permission = sysfs_permission,
.setattr = sysfs_setattr,
{
struct rb_node *rbn;
- lockdep_assert_held(&sysfs_mutex);
+ lockdep_assert_held(&kernfs_mutex);
/* if first iteration, visit leftmost descendant which may be root */
if (!pos)
{
int error;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
error = 0;
if ((kn->parent == new_parent) && (kn->ns == new_ns) &&
error = 0;
out:
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
return error;
}
if (!dir_emit_dots(file, ctx))
return 0;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
if (kernfs_ns_enabled(parent))
ns = kernfs_info(dentry->d_sb)->ns;
file->private_data = pos;
kernfs_get(pos);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
if (!dir_emit(ctx, name, len, ino, type))
return 0;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
}
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
file->private_data = NULL;
ctx->pos = INT_MAX;
return 0;
return ret;
}
-const struct file_operations sysfs_dir_operations = {
+const struct file_operations kernfs_dir_fops = {
.read = generic_read_dir,
.iterate = sysfs_readdir,
.release = sysfs_dir_release,
}
EXPORT_SYMBOL_GPL(kernfs_notify);
-const struct file_operations kernfs_file_operations = {
+const struct file_operations kernfs_file_fops = {
.read = kernfs_file_read,
.write = kernfs_file_write,
.llseek = generic_file_llseek,
#include "kernfs-internal.h"
-static const struct address_space_operations sysfs_aops = {
+static const struct address_space_operations kernfs_aops = {
.readpage = simple_readpage,
.write_begin = simple_write_begin,
.write_end = simple_write_end,
};
-static struct backing_dev_info sysfs_backing_dev_info = {
- .name = "sysfs",
+static struct backing_dev_info kernfs_bdi = {
+ .name = "kernfs",
.ra_pages = 0, /* No readahead */
.capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
};
-static const struct inode_operations sysfs_inode_operations = {
+static const struct inode_operations kernfs_iops = {
.permission = sysfs_permission,
.setattr = sysfs_setattr,
.getattr = sysfs_getattr,
void __init sysfs_inode_init(void)
{
- if (bdi_init(&sysfs_backing_dev_info))
- panic("failed to init sysfs_backing_dev_info");
+ if (bdi_init(&kernfs_bdi))
+ panic("failed to init kernfs_bdi");
}
static struct kernfs_iattrs *kernfs_iattrs(struct kernfs_node *kn)
{
int ret;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
ret = __kernfs_setattr(kn, iattr);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
return ret;
}
if (!kn)
return -EINVAL;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
error = inode_change_ok(inode, iattr);
if (error)
goto out;
setattr_copy(inode, iattr);
out:
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
return error;
}
if (error)
return error;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
error = sysfs_sd_setsecdata(kn, &secdata, &secdata_len);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
if (secdata)
security_release_secctx(secdata, secdata_len);
struct kernfs_node *kn = dentry->d_fsdata;
struct inode *inode = dentry->d_inode;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
sysfs_refresh_inode(kn, inode);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
generic_fillattr(inode, stat);
return 0;
{
kernfs_get(kn);
inode->i_private = kn;
- inode->i_mapping->a_ops = &sysfs_aops;
- inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
- inode->i_op = &sysfs_inode_operations;
+ inode->i_mapping->a_ops = &kernfs_aops;
+ inode->i_mapping->backing_dev_info = &kernfs_bdi;
+ inode->i_op = &kernfs_iops;
set_default_inode_attr(inode, kn->mode);
sysfs_refresh_inode(kn, inode);
/* initialize inode according to type */
switch (kernfs_type(kn)) {
case KERNFS_DIR:
- inode->i_op = &sysfs_dir_inode_operations;
- inode->i_fop = &sysfs_dir_operations;
+ inode->i_op = &kernfs_dir_iops;
+ inode->i_fop = &kernfs_dir_fops;
break;
case KERNFS_FILE:
inode->i_size = kn->attr.size;
- inode->i_fop = &kernfs_file_operations;
+ inode->i_fop = &kernfs_file_fops;
break;
case KERNFS_LINK:
- inode->i_op = &sysfs_symlink_inode_operations;
+ inode->i_op = &kernfs_symlink_iops;
break;
default:
BUG();
kn = inode->i_private;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
sysfs_refresh_inode(kn, inode);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
return generic_permission(inode, mask);
}
};
#define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
-extern struct kmem_cache *sysfs_dir_cachep;
+extern struct kmem_cache *kernfs_node_cache;
/*
* inode.c
/*
* dir.c
*/
-extern struct mutex sysfs_mutex;
-extern const struct dentry_operations sysfs_dentry_ops;
-extern const struct file_operations sysfs_dir_operations;
-extern const struct inode_operations sysfs_dir_inode_operations;
+extern struct mutex kernfs_mutex;
+extern const struct dentry_operations kernfs_dops;
+extern const struct file_operations kernfs_dir_fops;
+extern const struct inode_operations kernfs_dir_iops;
struct kernfs_node *sysfs_get_active(struct kernfs_node *kn);
void sysfs_put_active(struct kernfs_node *kn);
/*
* file.c
*/
-extern const struct file_operations kernfs_file_operations;
+extern const struct file_operations kernfs_file_fops;
void sysfs_unmap_bin_file(struct kernfs_node *kn);
/*
* symlink.c
*/
-extern const struct inode_operations sysfs_symlink_inode_operations;
+extern const struct inode_operations kernfs_symlink_iops;
#endif /* __KERNFS_INTERNAL_H */
#include "kernfs-internal.h"
-struct kmem_cache *sysfs_dir_cachep;
+struct kmem_cache *kernfs_node_cache;
-static const struct super_operations sysfs_ops = {
+static const struct super_operations kernfs_sops = {
.statfs = simple_statfs,
.drop_inode = generic_delete_inode,
.evict_inode = sysfs_evict_inode,
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
sb->s_magic = SYSFS_MAGIC;
- sb->s_op = &sysfs_ops;
+ sb->s_op = &kernfs_sops;
sb->s_time_gran = 1;
/* get root inode, initialize and unlock it */
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
inode = sysfs_get_inode(sb, info->root->kn);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
if (!inode) {
pr_debug("sysfs: could not get root inode\n");
return -ENOMEM;
kernfs_get(info->root->kn);
root->d_fsdata = info->root->kn;
sb->s_root = root;
- sb->s_d_op = &sysfs_dentry_ops;
+ sb->s_d_op = &kernfs_dops;
return 0;
}
void __init kernfs_init(void)
{
- sysfs_dir_cachep = kmem_cache_create("sysfs_dir_cache",
+ kernfs_node_cache = kmem_cache_create("kernfs_node_cache",
sizeof(struct kernfs_node),
0, SLAB_PANIC, NULL);
sysfs_inode_init();
struct kernfs_node *target = kn->symlink.target_kn;
int error;
- mutex_lock(&sysfs_mutex);
+ mutex_lock(&kernfs_mutex);
error = sysfs_get_target_path(parent, target, path);
- mutex_unlock(&sysfs_mutex);
+ mutex_unlock(&kernfs_mutex);
return error;
}
free_page((unsigned long)page);
}
-const struct inode_operations sysfs_symlink_inode_operations = {
+const struct inode_operations kernfs_symlink_iops = {
.setxattr = sysfs_setxattr,
.removexattr = sysfs_removexattr,
.getxattr = sysfs_getxattr,