提交 c637b8ac 编写于 作者: T Tejun Heo 提交者: Greg Kroah-Hartman

kernfs: s/sysfs/kernfs/ in internal functions and whatever is left

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_*()/kernfs_*()/ in all internal functions
* s/sysfs/kernfs/ in internal strings, comments and whatever is remaining
* Uniformly rename various vfs operations so that they're consistently
  named and distinguishable.

This patch is strictly rename only and doesn't introduce any
functional difference.
Signed-off-by: NTejun Heo <tj@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a797bfc3
此差异已折叠。
...@@ -64,7 +64,7 @@ static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos) ...@@ -64,7 +64,7 @@ static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
* the ops aren't called concurrently for the same open file. * the ops aren't called concurrently for the same open file.
*/ */
mutex_lock(&of->mutex); mutex_lock(&of->mutex);
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
ops = kernfs_ops(of->kn); ops = kernfs_ops(of->kn);
...@@ -104,7 +104,7 @@ static void kernfs_seq_stop(struct seq_file *sf, void *v) ...@@ -104,7 +104,7 @@ static void kernfs_seq_stop(struct seq_file *sf, void *v)
if (ops->seq_stop) if (ops->seq_stop)
ops->seq_stop(sf, v); ops->seq_stop(sf, v);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
mutex_unlock(&of->mutex); mutex_unlock(&of->mutex);
} }
...@@ -147,7 +147,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of, ...@@ -147,7 +147,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
* the ops aren't called concurrently for the same open file. * the ops aren't called concurrently for the same open file.
*/ */
mutex_lock(&of->mutex); mutex_lock(&of->mutex);
if (!sysfs_get_active(of->kn)) { if (!kernfs_get_active(of->kn)) {
len = -ENODEV; len = -ENODEV;
mutex_unlock(&of->mutex); mutex_unlock(&of->mutex);
goto out_free; goto out_free;
...@@ -159,7 +159,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of, ...@@ -159,7 +159,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
else else
len = -EINVAL; len = -EINVAL;
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
mutex_unlock(&of->mutex); mutex_unlock(&of->mutex);
if (len < 0) if (len < 0)
...@@ -178,14 +178,14 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of, ...@@ -178,14 +178,14 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
} }
/** /**
* kernfs_file_read - kernfs vfs read callback * kernfs_fop_read - kernfs vfs read callback
* @file: file pointer * @file: file pointer
* @user_buf: data to write * @user_buf: data to write
* @count: number of bytes * @count: number of bytes
* @ppos: starting offset * @ppos: starting offset
*/ */
static ssize_t kernfs_file_read(struct file *file, char __user *user_buf, static ssize_t kernfs_fop_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct kernfs_open_file *of = kernfs_of(file); struct kernfs_open_file *of = kernfs_of(file);
...@@ -196,7 +196,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf, ...@@ -196,7 +196,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
} }
/** /**
* kernfs_file_write - kernfs vfs write callback * kernfs_fop_write - kernfs vfs write callback
* @file: file pointer * @file: file pointer
* @user_buf: data to write * @user_buf: data to write
* @count: number of bytes * @count: number of bytes
...@@ -211,8 +211,8 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf, ...@@ -211,8 +211,8 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
* modify only the the value you're changing, then write entire buffer * modify only the the value you're changing, then write entire buffer
* back. * back.
*/ */
static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf, static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct kernfs_open_file *of = kernfs_of(file); struct kernfs_open_file *of = kernfs_of(file);
ssize_t len = min_t(size_t, count, PAGE_SIZE); ssize_t len = min_t(size_t, count, PAGE_SIZE);
...@@ -234,7 +234,7 @@ static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf, ...@@ -234,7 +234,7 @@ static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf,
* the ops aren't called concurrently for the same open file. * the ops aren't called concurrently for the same open file.
*/ */
mutex_lock(&of->mutex); mutex_lock(&of->mutex);
if (!sysfs_get_active(of->kn)) { if (!kernfs_get_active(of->kn)) {
mutex_unlock(&of->mutex); mutex_unlock(&of->mutex);
len = -ENODEV; len = -ENODEV;
goto out_free; goto out_free;
...@@ -246,7 +246,7 @@ static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf, ...@@ -246,7 +246,7 @@ static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf,
else else
len = -EINVAL; len = -EINVAL;
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
mutex_unlock(&of->mutex); mutex_unlock(&of->mutex);
if (len > 0) if (len > 0)
...@@ -264,13 +264,13 @@ static void kernfs_vma_open(struct vm_area_struct *vma) ...@@ -264,13 +264,13 @@ static void kernfs_vma_open(struct vm_area_struct *vma)
if (!of->vm_ops) if (!of->vm_ops)
return; return;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return; return;
if (of->vm_ops->open) if (of->vm_ops->open)
of->vm_ops->open(vma); of->vm_ops->open(vma);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
} }
static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
...@@ -282,14 +282,14 @@ static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -282,14 +282,14 @@ static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
if (!of->vm_ops) if (!of->vm_ops)
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
ret = VM_FAULT_SIGBUS; ret = VM_FAULT_SIGBUS;
if (of->vm_ops->fault) if (of->vm_ops->fault)
ret = of->vm_ops->fault(vma, vmf); ret = of->vm_ops->fault(vma, vmf);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
return ret; return ret;
} }
...@@ -303,7 +303,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma, ...@@ -303,7 +303,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
if (!of->vm_ops) if (!of->vm_ops)
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
ret = 0; ret = 0;
...@@ -312,7 +312,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma, ...@@ -312,7 +312,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
else else
file_update_time(file); file_update_time(file);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
return ret; return ret;
} }
...@@ -326,14 +326,14 @@ static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr, ...@@ -326,14 +326,14 @@ static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
if (!of->vm_ops) if (!of->vm_ops)
return -EINVAL; return -EINVAL;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return -EINVAL; return -EINVAL;
ret = -EINVAL; ret = -EINVAL;
if (of->vm_ops->access) if (of->vm_ops->access)
ret = of->vm_ops->access(vma, addr, buf, len, write); ret = of->vm_ops->access(vma, addr, buf, len, write);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
return ret; return ret;
} }
...@@ -348,14 +348,14 @@ static int kernfs_vma_set_policy(struct vm_area_struct *vma, ...@@ -348,14 +348,14 @@ static int kernfs_vma_set_policy(struct vm_area_struct *vma,
if (!of->vm_ops) if (!of->vm_ops)
return 0; return 0;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return -EINVAL; return -EINVAL;
ret = 0; ret = 0;
if (of->vm_ops->set_policy) if (of->vm_ops->set_policy)
ret = of->vm_ops->set_policy(vma, new); ret = of->vm_ops->set_policy(vma, new);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
return ret; return ret;
} }
...@@ -369,14 +369,14 @@ static struct mempolicy *kernfs_vma_get_policy(struct vm_area_struct *vma, ...@@ -369,14 +369,14 @@ static struct mempolicy *kernfs_vma_get_policy(struct vm_area_struct *vma,
if (!of->vm_ops) if (!of->vm_ops)
return vma->vm_policy; return vma->vm_policy;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return vma->vm_policy; return vma->vm_policy;
pol = vma->vm_policy; pol = vma->vm_policy;
if (of->vm_ops->get_policy) if (of->vm_ops->get_policy)
pol = of->vm_ops->get_policy(vma, addr); pol = of->vm_ops->get_policy(vma, addr);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
return pol; return pol;
} }
...@@ -391,14 +391,14 @@ static int kernfs_vma_migrate(struct vm_area_struct *vma, ...@@ -391,14 +391,14 @@ static int kernfs_vma_migrate(struct vm_area_struct *vma,
if (!of->vm_ops) if (!of->vm_ops)
return 0; return 0;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
return 0; return 0;
ret = 0; ret = 0;
if (of->vm_ops->migrate) if (of->vm_ops->migrate)
ret = of->vm_ops->migrate(vma, from, to, flags); ret = of->vm_ops->migrate(vma, from, to, flags);
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
return ret; return ret;
} }
#endif #endif
...@@ -415,7 +415,7 @@ static const struct vm_operations_struct kernfs_vm_ops = { ...@@ -415,7 +415,7 @@ static const struct vm_operations_struct kernfs_vm_ops = {
#endif #endif
}; };
static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma) static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)
{ {
struct kernfs_open_file *of = kernfs_of(file); struct kernfs_open_file *of = kernfs_of(file);
const struct kernfs_ops *ops; const struct kernfs_ops *ops;
...@@ -434,7 +434,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -434,7 +434,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
mutex_lock(&of->mutex); mutex_lock(&of->mutex);
rc = -ENODEV; rc = -ENODEV;
if (!sysfs_get_active(of->kn)) if (!kernfs_get_active(of->kn))
goto out_unlock; goto out_unlock;
ops = kernfs_ops(of->kn); ops = kernfs_ops(of->kn);
...@@ -465,7 +465,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -465,7 +465,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
of->vm_ops = vma->vm_ops; of->vm_ops = vma->vm_ops;
vma->vm_ops = &kernfs_vm_ops; vma->vm_ops = &kernfs_vm_ops;
out_put: out_put:
sysfs_put_active(of->kn); kernfs_put_active(of->kn);
out_unlock: out_unlock:
mutex_unlock(&of->mutex); mutex_unlock(&of->mutex);
...@@ -473,7 +473,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -473,7 +473,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
} }
/** /**
* sysfs_get_open_dirent - get or create kernfs_open_node * kernfs_get_open_node - get or create kernfs_open_node
* @kn: target kernfs_node * @kn: target kernfs_node
* @of: kernfs_open_file for this instance of open * @of: kernfs_open_file for this instance of open
* *
...@@ -486,8 +486,8 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -486,8 +486,8 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
* RETURNS: * RETURNS:
* 0 on success, -errno on failure. * 0 on success, -errno on failure.
*/ */
static int sysfs_get_open_dirent(struct kernfs_node *kn, static int kernfs_get_open_node(struct kernfs_node *kn,
struct kernfs_open_file *of) struct kernfs_open_file *of)
{ {
struct kernfs_open_node *on, *new_on = NULL; struct kernfs_open_node *on, *new_on = NULL;
...@@ -527,7 +527,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn, ...@@ -527,7 +527,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
} }
/** /**
* sysfs_put_open_dirent - put kernfs_open_node * kernfs_put_open_node - put kernfs_open_node
* @kn: target kernfs_nodet * @kn: target kernfs_nodet
* @of: associated kernfs_open_file * @of: associated kernfs_open_file
* *
...@@ -537,8 +537,8 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn, ...@@ -537,8 +537,8 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
* LOCKING: * LOCKING:
* None. * None.
*/ */
static void sysfs_put_open_dirent(struct kernfs_node *kn, static void kernfs_put_open_node(struct kernfs_node *kn,
struct kernfs_open_file *of) struct kernfs_open_file *of)
{ {
struct kernfs_open_node *on = kn->attr.open; struct kernfs_open_node *on = kn->attr.open;
unsigned long flags; unsigned long flags;
...@@ -560,7 +560,7 @@ static void sysfs_put_open_dirent(struct kernfs_node *kn, ...@@ -560,7 +560,7 @@ static void sysfs_put_open_dirent(struct kernfs_node *kn,
kfree(on); kfree(on);
} }
static int kernfs_file_open(struct inode *inode, struct file *file) static int kernfs_fop_open(struct inode *inode, struct file *file)
{ {
struct kernfs_node *kn = file->f_path.dentry->d_fsdata; struct kernfs_node *kn = file->f_path.dentry->d_fsdata;
const struct kernfs_ops *ops; const struct kernfs_ops *ops;
...@@ -568,7 +568,7 @@ static int kernfs_file_open(struct inode *inode, struct file *file) ...@@ -568,7 +568,7 @@ static int kernfs_file_open(struct inode *inode, struct file *file)
bool has_read, has_write, has_mmap; bool has_read, has_write, has_mmap;
int error = -EACCES; int error = -EACCES;
if (!sysfs_get_active(kn)) if (!kernfs_get_active(kn))
return -ENODEV; return -ENODEV;
ops = kernfs_ops(kn); ops = kernfs_ops(kn);
...@@ -633,13 +633,13 @@ static int kernfs_file_open(struct inode *inode, struct file *file) ...@@ -633,13 +633,13 @@ static int kernfs_file_open(struct inode *inode, struct file *file)
if (file->f_mode & FMODE_WRITE) if (file->f_mode & FMODE_WRITE)
file->f_mode |= FMODE_PWRITE; file->f_mode |= FMODE_PWRITE;
/* make sure we have open dirent struct */ /* make sure we have open node struct */
error = sysfs_get_open_dirent(kn, of); error = kernfs_get_open_node(kn, of);
if (error) if (error)
goto err_close; goto err_close;
/* open succeeded, put active references */ /* open succeeded, put active references */
sysfs_put_active(kn); kernfs_put_active(kn);
return 0; return 0;
err_close: err_close:
...@@ -647,23 +647,23 @@ static int kernfs_file_open(struct inode *inode, struct file *file) ...@@ -647,23 +647,23 @@ static int kernfs_file_open(struct inode *inode, struct file *file)
err_free: err_free:
kfree(of); kfree(of);
err_out: err_out:
sysfs_put_active(kn); kernfs_put_active(kn);
return error; return error;
} }
static int kernfs_file_release(struct inode *inode, struct file *filp) static int kernfs_fop_release(struct inode *inode, struct file *filp)
{ {
struct kernfs_node *kn = filp->f_path.dentry->d_fsdata; struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
struct kernfs_open_file *of = kernfs_of(filp); struct kernfs_open_file *of = kernfs_of(filp);
sysfs_put_open_dirent(kn, of); kernfs_put_open_node(kn, of);
seq_release(inode, filp); seq_release(inode, filp);
kfree(of); kfree(of);
return 0; return 0;
} }
void sysfs_unmap_bin_file(struct kernfs_node *kn) void kernfs_unmap_bin_file(struct kernfs_node *kn)
{ {
struct kernfs_open_node *on; struct kernfs_open_node *on;
struct kernfs_open_file *of; struct kernfs_open_file *of;
...@@ -686,10 +686,11 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn) ...@@ -686,10 +686,11 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
} }
mutex_unlock(&kernfs_open_file_mutex); mutex_unlock(&kernfs_open_file_mutex);
sysfs_put_open_dirent(kn, NULL); kernfs_put_open_node(kn, NULL);
} }
/* Sysfs attribute files are pollable. The idea is that you read /*
* Kernfs attribute files are pollable. The idea is that you read
* the content and then you use 'poll' or 'select' to wait for * the content and then you use 'poll' or 'select' to wait for
* the content to change. When the content changes (assuming the * the content to change. When the content changes (assuming the
* manager for the kobject supports notification), poll will * manager for the kobject supports notification), poll will
...@@ -702,19 +703,19 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn) ...@@ -702,19 +703,19 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
* to see if it supports poll (Neither 'poll' nor 'select' return * to see if it supports poll (Neither 'poll' nor 'select' return
* an appropriate error code). When in doubt, set a suitable timeout value. * an appropriate error code). When in doubt, set a suitable timeout value.
*/ */
static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait) static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
{ {
struct kernfs_open_file *of = kernfs_of(filp); struct kernfs_open_file *of = kernfs_of(filp);
struct kernfs_node *kn = filp->f_path.dentry->d_fsdata; struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
struct kernfs_open_node *on = kn->attr.open; struct kernfs_open_node *on = kn->attr.open;
/* need parent for the kobj, grab both */ /* need parent for the kobj, grab both */
if (!sysfs_get_active(kn)) if (!kernfs_get_active(kn))
goto trigger; goto trigger;
poll_wait(filp, &on->poll, wait); poll_wait(filp, &on->poll, wait);
sysfs_put_active(kn); kernfs_put_active(kn);
if (of->event != atomic_read(&on->event)) if (of->event != atomic_read(&on->event))
goto trigger; goto trigger;
...@@ -751,13 +752,13 @@ void kernfs_notify(struct kernfs_node *kn) ...@@ -751,13 +752,13 @@ void kernfs_notify(struct kernfs_node *kn)
EXPORT_SYMBOL_GPL(kernfs_notify); EXPORT_SYMBOL_GPL(kernfs_notify);
const struct file_operations kernfs_file_fops = { const struct file_operations kernfs_file_fops = {
.read = kernfs_file_read, .read = kernfs_fop_read,
.write = kernfs_file_write, .write = kernfs_fop_write,
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
.mmap = kernfs_file_mmap, .mmap = kernfs_fop_mmap,
.open = kernfs_file_open, .open = kernfs_fop_open,
.release = kernfs_file_release, .release = kernfs_fop_release,
.poll = kernfs_file_poll, .poll = kernfs_fop_poll,
}; };
/** /**
...@@ -784,8 +785,8 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent, ...@@ -784,8 +785,8 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
struct kernfs_node *kn; struct kernfs_node *kn;
int rc; int rc;
kn = sysfs_new_dirent(kernfs_root(parent), name, kn = kernfs_new_node(kernfs_root(parent), name,
(mode & S_IALLUGO) | S_IFREG, KERNFS_FILE); (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE);
if (!kn) if (!kn)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -811,9 +812,9 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent, ...@@ -811,9 +812,9 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
if (ops->mmap) if (ops->mmap)
kn->flags |= KERNFS_HAS_MMAP; kn->flags |= KERNFS_HAS_MMAP;
sysfs_addrm_start(&acxt); kernfs_addrm_start(&acxt);
rc = sysfs_add_one(&acxt, kn, parent); rc = kernfs_add_one(&acxt, kn, parent);
sysfs_addrm_finish(&acxt); kernfs_addrm_finish(&acxt);
if (rc) { if (rc) {
kernfs_put(kn); kernfs_put(kn);
......
...@@ -31,16 +31,16 @@ static struct backing_dev_info kernfs_bdi = { ...@@ -31,16 +31,16 @@ static struct backing_dev_info kernfs_bdi = {
}; };
static const struct inode_operations kernfs_iops = { static const struct inode_operations kernfs_iops = {
.permission = sysfs_permission, .permission = kernfs_iop_permission,
.setattr = sysfs_setattr, .setattr = kernfs_iop_setattr,
.getattr = sysfs_getattr, .getattr = kernfs_iop_getattr,
.setxattr = sysfs_setxattr, .setxattr = kernfs_iop_setxattr,
.removexattr = sysfs_removexattr, .removexattr = kernfs_iop_removexattr,
.getxattr = sysfs_getxattr, .getxattr = kernfs_iop_getxattr,
.listxattr = sysfs_listxattr, .listxattr = kernfs_iop_listxattr,
}; };
void __init sysfs_inode_init(void) void __init kernfs_inode_init(void)
{ {
if (bdi_init(&kernfs_bdi)) if (bdi_init(&kernfs_bdi))
panic("failed to init kernfs_bdi"); panic("failed to init kernfs_bdi");
...@@ -115,7 +115,7 @@ int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr) ...@@ -115,7 +115,7 @@ int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
return ret; return ret;
} }
int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct kernfs_node *kn = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
...@@ -141,8 +141,8 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) ...@@ -141,8 +141,8 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
return error; return error;
} }
static int sysfs_sd_setsecdata(struct kernfs_node *kn, void **secdata, static int kernfs_node_setsecdata(struct kernfs_node *kn, void **secdata,
u32 *secdata_len) u32 *secdata_len)
{ {
struct kernfs_iattrs *attrs; struct kernfs_iattrs *attrs;
void *old_secdata; void *old_secdata;
...@@ -163,8 +163,8 @@ static int sysfs_sd_setsecdata(struct kernfs_node *kn, void **secdata, ...@@ -163,8 +163,8 @@ static int sysfs_sd_setsecdata(struct kernfs_node *kn, void **secdata,
return 0; return 0;
} }
int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, int kernfs_iop_setxattr(struct dentry *dentry, const char *name,
size_t size, int flags) const void *value, size_t size, int flags)
{ {
struct kernfs_node *kn = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct kernfs_iattrs *attrs; struct kernfs_iattrs *attrs;
...@@ -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(&kernfs_mutex); mutex_lock(&kernfs_mutex);
error = sysfs_sd_setsecdata(kn, &secdata, &secdata_len); error = kernfs_node_setsecdata(kn, &secdata, &secdata_len);
mutex_unlock(&kernfs_mutex); mutex_unlock(&kernfs_mutex);
if (secdata) if (secdata)
...@@ -202,7 +202,7 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, ...@@ -202,7 +202,7 @@ int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
return -EINVAL; return -EINVAL;
} }
int sysfs_removexattr(struct dentry *dentry, const char *name) int kernfs_iop_removexattr(struct dentry *dentry, const char *name)
{ {
struct kernfs_node *kn = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct kernfs_iattrs *attrs; struct kernfs_iattrs *attrs;
...@@ -214,8 +214,8 @@ int sysfs_removexattr(struct dentry *dentry, const char *name) ...@@ -214,8 +214,8 @@ int sysfs_removexattr(struct dentry *dentry, const char *name)
return simple_xattr_remove(&attrs->xattrs, name); return simple_xattr_remove(&attrs->xattrs, name);
} }
ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
size_t size) size_t size)
{ {
struct kernfs_node *kn = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct kernfs_iattrs *attrs; struct kernfs_iattrs *attrs;
...@@ -227,7 +227,7 @@ ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, ...@@ -227,7 +227,7 @@ ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf,
return simple_xattr_get(&attrs->xattrs, name, buf, size); return simple_xattr_get(&attrs->xattrs, name, buf, size);
} }
ssize_t sysfs_listxattr(struct dentry *dentry, char *buf, size_t size) ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size)
{ {
struct kernfs_node *kn = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct kernfs_iattrs *attrs; struct kernfs_iattrs *attrs;
...@@ -254,7 +254,7 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr) ...@@ -254,7 +254,7 @@ 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 kernfs_node *kn, struct inode *inode) static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
{ {
struct kernfs_iattrs *attrs = kn->iattr; struct kernfs_iattrs *attrs = kn->iattr;
...@@ -273,21 +273,21 @@ static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode) ...@@ -273,21 +273,21 @@ static void sysfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
set_nlink(inode, kn->dir.subdirs + 2); set_nlink(inode, kn->dir.subdirs + 2);
} }
int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat) struct kstat *stat)
{ {
struct kernfs_node *kn = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
mutex_lock(&kernfs_mutex); mutex_lock(&kernfs_mutex);
sysfs_refresh_inode(kn, inode); kernfs_refresh_inode(kn, inode);
mutex_unlock(&kernfs_mutex); mutex_unlock(&kernfs_mutex);
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
return 0; return 0;
} }
static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode) static void kernfs_init_inode(struct kernfs_node *kn, struct inode *inode)
{ {
kernfs_get(kn); kernfs_get(kn);
inode->i_private = kn; inode->i_private = kn;
...@@ -296,7 +296,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode) ...@@ -296,7 +296,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
inode->i_op = &kernfs_iops; inode->i_op = &kernfs_iops;
set_default_inode_attr(inode, kn->mode); set_default_inode_attr(inode, kn->mode);
sysfs_refresh_inode(kn, inode); kernfs_refresh_inode(kn, inode);
/* initialize inode according to type */ /* initialize inode according to type */
switch (kernfs_type(kn)) { switch (kernfs_type(kn)) {
...@@ -319,7 +319,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode) ...@@ -319,7 +319,7 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode)
} }
/** /**
* sysfs_get_inode - get inode for kernfs_node * kernfs_get_inode - get inode for kernfs_node
* @sb: super block * @sb: super block
* @kn: kernfs_node to allocate inode for * @kn: kernfs_node to allocate inode for
* *
...@@ -333,25 +333,25 @@ static void sysfs_init_inode(struct kernfs_node *kn, struct inode *inode) ...@@ -333,25 +333,25 @@ static void sysfs_init_inode(struct kernfs_node *kn, 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 kernfs_node *kn) struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
{ {
struct inode *inode; struct inode *inode;
inode = iget_locked(sb, kn->ino); inode = iget_locked(sb, kn->ino);
if (inode && (inode->i_state & I_NEW)) if (inode && (inode->i_state & I_NEW))
sysfs_init_inode(kn, inode); kernfs_init_inode(kn, inode);
return inode; return inode;
} }
/* /*
* The kernfs_node serves as both an inode and a directory entry for sysfs. * The kernfs_node serves as both an inode and a directory entry for
* To prevent the sysfs inode numbers from being freed prematurely we take * kernfs. To prevent the kernfs inode numbers from being freed
* a reference to kernfs_node from the sysfs inode. A * prematurely we take a reference to kernfs_node from the kernfs 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 kernfs_evict_inode(struct inode *inode)
{ {
struct kernfs_node *kn = inode->i_private; struct kernfs_node *kn = inode->i_private;
...@@ -360,7 +360,7 @@ void sysfs_evict_inode(struct inode *inode) ...@@ -360,7 +360,7 @@ void sysfs_evict_inode(struct inode *inode)
kernfs_put(kn); kernfs_put(kn);
} }
int sysfs_permission(struct inode *inode, int mask) int kernfs_iop_permission(struct inode *inode, int mask)
{ {
struct kernfs_node *kn; struct kernfs_node *kn;
...@@ -370,7 +370,7 @@ int sysfs_permission(struct inode *inode, int mask) ...@@ -370,7 +370,7 @@ int sysfs_permission(struct inode *inode, int mask)
kn = inode->i_private; kn = inode->i_private;
mutex_lock(&kernfs_mutex); mutex_lock(&kernfs_mutex);
sysfs_refresh_inode(kn, inode); kernfs_refresh_inode(kn, inode);
mutex_unlock(&kernfs_mutex); mutex_unlock(&kernfs_mutex);
return generic_permission(inode, mask); return generic_permission(inode, mask);
......
...@@ -76,19 +76,19 @@ extern struct kmem_cache *kernfs_node_cache; ...@@ -76,19 +76,19 @@ extern struct kmem_cache *kernfs_node_cache;
/* /*
* inode.c * inode.c
*/ */
struct inode *sysfs_get_inode(struct super_block *sb, struct kernfs_node *kn); struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
void sysfs_evict_inode(struct inode *inode); void kernfs_evict_inode(struct inode *inode);
int sysfs_permission(struct inode *inode, int mask); int kernfs_iop_permission(struct inode *inode, int mask);
int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat); struct kstat *stat);
int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags); size_t size, int flags);
int sysfs_removexattr(struct dentry *dentry, const char *name); int kernfs_iop_removexattr(struct dentry *dentry, const char *name);
ssize_t sysfs_getxattr(struct dentry *dentry, const char *name, void *buf, ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
size_t size); size_t size);
ssize_t sysfs_listxattr(struct dentry *dentry, char *buf, size_t size); ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
void sysfs_inode_init(void); void kernfs_inode_init(void);
/* /*
* dir.c * dir.c
...@@ -98,21 +98,21 @@ extern const struct dentry_operations kernfs_dops; ...@@ -98,21 +98,21 @@ extern const struct dentry_operations kernfs_dops;
extern const struct file_operations kernfs_dir_fops; extern const struct file_operations kernfs_dir_fops;
extern const struct inode_operations kernfs_dir_iops; extern const struct inode_operations kernfs_dir_iops;
struct kernfs_node *sysfs_get_active(struct kernfs_node *kn); struct kernfs_node *kernfs_get_active(struct kernfs_node *kn);
void sysfs_put_active(struct kernfs_node *kn); void kernfs_put_active(struct kernfs_node *kn);
void sysfs_addrm_start(struct kernfs_addrm_cxt *acxt); void kernfs_addrm_start(struct kernfs_addrm_cxt *acxt);
int sysfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn, int kernfs_add_one(struct kernfs_addrm_cxt *acxt, struct kernfs_node *kn,
struct kernfs_node *parent); struct kernfs_node *parent);
void sysfs_addrm_finish(struct kernfs_addrm_cxt *acxt); void kernfs_addrm_finish(struct kernfs_addrm_cxt *acxt);
struct kernfs_node *sysfs_new_dirent(struct kernfs_root *root, struct kernfs_node *kernfs_new_node(struct kernfs_root *root, const char *name,
const char *name, umode_t mode, int type); umode_t mode, int type);
/* /*
* file.c * file.c
*/ */
extern const struct file_operations kernfs_file_fops; extern const struct file_operations kernfs_file_fops;
void sysfs_unmap_bin_file(struct kernfs_node *kn); void kernfs_unmap_bin_file(struct kernfs_node *kn);
/* /*
* symlink.c * symlink.c
......
...@@ -22,10 +22,10 @@ struct kmem_cache *kernfs_node_cache; ...@@ -22,10 +22,10 @@ struct kmem_cache *kernfs_node_cache;
static const struct super_operations kernfs_sops = { static const struct super_operations kernfs_sops = {
.statfs = simple_statfs, .statfs = simple_statfs,
.drop_inode = generic_delete_inode, .drop_inode = generic_delete_inode,
.evict_inode = sysfs_evict_inode, .evict_inode = kernfs_evict_inode,
}; };
static int sysfs_fill_super(struct super_block *sb) static int kernfs_fill_super(struct super_block *sb)
{ {
struct kernfs_super_info *info = kernfs_info(sb); struct kernfs_super_info *info = kernfs_info(sb);
struct inode *inode; struct inode *inode;
...@@ -39,10 +39,10 @@ static int sysfs_fill_super(struct super_block *sb) ...@@ -39,10 +39,10 @@ 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(&kernfs_mutex); mutex_lock(&kernfs_mutex);
inode = sysfs_get_inode(sb, info->root->kn); inode = kernfs_get_inode(sb, info->root->kn);
mutex_unlock(&kernfs_mutex); mutex_unlock(&kernfs_mutex);
if (!inode) { if (!inode) {
pr_debug("sysfs: could not get root inode\n"); pr_debug("kernfs: could not get root inode\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -59,7 +59,7 @@ static int sysfs_fill_super(struct super_block *sb) ...@@ -59,7 +59,7 @@ static int sysfs_fill_super(struct super_block *sb)
return 0; return 0;
} }
static int sysfs_test_super(struct super_block *sb, void *data) static int kernfs_test_super(struct super_block *sb, void *data)
{ {
struct kernfs_super_info *sb_info = kernfs_info(sb); struct kernfs_super_info *sb_info = kernfs_info(sb);
struct kernfs_super_info *info = data; struct kernfs_super_info *info = data;
...@@ -67,7 +67,7 @@ static int sysfs_test_super(struct super_block *sb, void *data) ...@@ -67,7 +67,7 @@ static int sysfs_test_super(struct super_block *sb, void *data)
return sb_info->root == info->root && sb_info->ns == info->ns; return sb_info->root == info->root && sb_info->ns == info->ns;
} }
static int sysfs_set_super(struct super_block *sb, void *data) static int kernfs_set_super(struct super_block *sb, void *data)
{ {
int error; int error;
error = set_anon_super(sb, data); error = set_anon_super(sb, data);
...@@ -117,13 +117,13 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, ...@@ -117,13 +117,13 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
info->root = root; info->root = root;
info->ns = ns; info->ns = ns;
sb = sget(fs_type, sysfs_test_super, sysfs_set_super, flags, info); sb = sget(fs_type, kernfs_test_super, kernfs_set_super, flags, info);
if (IS_ERR(sb) || sb->s_fs_info != info) if (IS_ERR(sb) || sb->s_fs_info != info)
kfree(info); kfree(info);
if (IS_ERR(sb)) if (IS_ERR(sb))
return ERR_CAST(sb); return ERR_CAST(sb);
if (!sb->s_root) { if (!sb->s_root) {
error = sysfs_fill_super(sb); error = kernfs_fill_super(sb);
if (error) { if (error) {
deactivate_locked_super(sb); deactivate_locked_super(sb);
return ERR_PTR(error); return ERR_PTR(error);
...@@ -161,5 +161,5 @@ void __init kernfs_init(void) ...@@ -161,5 +161,5 @@ void __init kernfs_init(void)
kernfs_node_cache = kmem_cache_create("kernfs_node_cache", kernfs_node_cache = kmem_cache_create("kernfs_node_cache",
sizeof(struct kernfs_node), sizeof(struct kernfs_node),
0, SLAB_PANIC, NULL); 0, SLAB_PANIC, NULL);
sysfs_inode_init(); kernfs_inode_init();
} }
...@@ -30,8 +30,8 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent, ...@@ -30,8 +30,8 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
struct kernfs_addrm_cxt acxt; struct kernfs_addrm_cxt acxt;
int error; int error;
kn = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO, kn = kernfs_new_node(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO,
KERNFS_LINK); KERNFS_LINK);
if (!kn) if (!kn)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -40,9 +40,9 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent, ...@@ -40,9 +40,9 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
kn->symlink.target_kn = target; kn->symlink.target_kn = target;
kernfs_get(target); /* ref owned by symlink */ kernfs_get(target); /* ref owned by symlink */
sysfs_addrm_start(&acxt); kernfs_addrm_start(&acxt);
error = sysfs_add_one(&acxt, kn, parent); error = kernfs_add_one(&acxt, kn, parent);
sysfs_addrm_finish(&acxt); kernfs_addrm_finish(&acxt);
if (!error) if (!error)
return kn; return kn;
...@@ -51,8 +51,8 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent, ...@@ -51,8 +51,8 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
return ERR_PTR(error); return ERR_PTR(error);
} }
static int sysfs_get_target_path(struct kernfs_node *parent, static int kernfs_get_target_path(struct kernfs_node *parent,
struct kernfs_node *target, char *path) struct kernfs_node *target, char *path)
{ {
struct kernfs_node *base, *kn; struct kernfs_node *base, *kn;
char *s = path; char *s = path;
...@@ -103,7 +103,7 @@ static int sysfs_get_target_path(struct kernfs_node *parent, ...@@ -103,7 +103,7 @@ static int sysfs_get_target_path(struct kernfs_node *parent,
return 0; return 0;
} }
static int sysfs_getlink(struct dentry *dentry, char *path) static int kernfs_getlink(struct dentry *dentry, char *path)
{ {
struct kernfs_node *kn = dentry->d_fsdata; struct kernfs_node *kn = dentry->d_fsdata;
struct kernfs_node *parent = kn->parent; struct kernfs_node *parent = kn->parent;
...@@ -111,18 +111,18 @@ static int sysfs_getlink(struct dentry *dentry, char *path) ...@@ -111,18 +111,18 @@ static int sysfs_getlink(struct dentry *dentry, char *path)
int error; int error;
mutex_lock(&kernfs_mutex); mutex_lock(&kernfs_mutex);
error = sysfs_get_target_path(parent, target, path); error = kernfs_get_target_path(parent, target, path);
mutex_unlock(&kernfs_mutex); mutex_unlock(&kernfs_mutex);
return error; return error;
} }
static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd) static void *kernfs_iop_follow_link(struct dentry *dentry, struct nameidata *nd)
{ {
int error = -ENOMEM; int error = -ENOMEM;
unsigned long page = get_zeroed_page(GFP_KERNEL); unsigned long page = get_zeroed_page(GFP_KERNEL);
if (page) { if (page) {
error = sysfs_getlink(dentry, (char *) page); error = kernfs_getlink(dentry, (char *) page);
if (error < 0) if (error < 0)
free_page((unsigned long)page); free_page((unsigned long)page);
} }
...@@ -130,8 +130,8 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -130,8 +130,8 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
return NULL; return NULL;
} }
static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, static void kernfs_iop_put_link(struct dentry *dentry, struct nameidata *nd,
void *cookie) void *cookie)
{ {
char *page = nd_get_link(nd); char *page = nd_get_link(nd);
if (!IS_ERR(page)) if (!IS_ERR(page))
...@@ -139,14 +139,14 @@ static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, ...@@ -139,14 +139,14 @@ static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
} }
const struct inode_operations kernfs_symlink_iops = { const struct inode_operations kernfs_symlink_iops = {
.setxattr = sysfs_setxattr, .setxattr = kernfs_iop_setxattr,
.removexattr = sysfs_removexattr, .removexattr = kernfs_iop_removexattr,
.getxattr = sysfs_getxattr, .getxattr = kernfs_iop_getxattr,
.listxattr = sysfs_listxattr, .listxattr = kernfs_iop_listxattr,
.readlink = generic_readlink, .readlink = generic_readlink,
.follow_link = sysfs_follow_link, .follow_link = kernfs_iop_follow_link,
.put_link = sysfs_put_link, .put_link = kernfs_iop_put_link,
.setattr = sysfs_setattr, .setattr = kernfs_iop_setattr,
.getattr = sysfs_getattr, .getattr = kernfs_iop_getattr,
.permission = sysfs_permission, .permission = kernfs_iop_permission,
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册