aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs/file.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 14:11:58 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-11 20:39:20 -0500
commitc637b8acbe079edb477d887041755b489036f146 (patch)
tree7d6e856930752574bb1d56b56bea5a2bf816de72 /fs/kernfs/file.c
parenta797bfc30532388e8a11ca726df60cdd77aa8675 (diff)
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: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs/file.c')
-rw-r--r--fs/kernfs/file.c121
1 files changed, 61 insertions, 60 deletions
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 32364ddb24de..053cfd9a6a40 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -64,7 +64,7 @@ static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
64 * the ops aren't called concurrently for the same open file. 64 * the ops aren't called concurrently for the same open file.
65 */ 65 */
66 mutex_lock(&of->mutex); 66 mutex_lock(&of->mutex);
67 if (!sysfs_get_active(of->kn)) 67 if (!kernfs_get_active(of->kn))
68 return ERR_PTR(-ENODEV); 68 return ERR_PTR(-ENODEV);
69 69
70 ops = kernfs_ops(of->kn); 70 ops = kernfs_ops(of->kn);
@@ -104,7 +104,7 @@ static void kernfs_seq_stop(struct seq_file *sf, void *v)
104 if (ops->seq_stop) 104 if (ops->seq_stop)
105 ops->seq_stop(sf, v); 105 ops->seq_stop(sf, v);
106 106
107 sysfs_put_active(of->kn); 107 kernfs_put_active(of->kn);
108 mutex_unlock(&of->mutex); 108 mutex_unlock(&of->mutex);
109} 109}
110 110
@@ -147,7 +147,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
147 * the ops aren't called concurrently for the same open file. 147 * the ops aren't called concurrently for the same open file.
148 */ 148 */
149 mutex_lock(&of->mutex); 149 mutex_lock(&of->mutex);
150 if (!sysfs_get_active(of->kn)) { 150 if (!kernfs_get_active(of->kn)) {
151 len = -ENODEV; 151 len = -ENODEV;
152 mutex_unlock(&of->mutex); 152 mutex_unlock(&of->mutex);
153 goto out_free; 153 goto out_free;
@@ -159,7 +159,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
159 else 159 else
160 len = -EINVAL; 160 len = -EINVAL;
161 161
162 sysfs_put_active(of->kn); 162 kernfs_put_active(of->kn);
163 mutex_unlock(&of->mutex); 163 mutex_unlock(&of->mutex);
164 164
165 if (len < 0) 165 if (len < 0)
@@ -178,14 +178,14 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
178} 178}
179 179
180/** 180/**
181 * kernfs_file_read - kernfs vfs read callback 181 * kernfs_fop_read - kernfs vfs read callback
182 * @file: file pointer 182 * @file: file pointer
183 * @user_buf: data to write 183 * @user_buf: data to write
184 * @count: number of bytes 184 * @count: number of bytes
185 * @ppos: starting offset 185 * @ppos: starting offset
186 */ 186 */
187static ssize_t kernfs_file_read(struct file *file, char __user *user_buf, 187static ssize_t kernfs_fop_read(struct file *file, char __user *user_buf,
188 size_t count, loff_t *ppos) 188 size_t count, loff_t *ppos)
189{ 189{
190 struct kernfs_open_file *of = kernfs_of(file); 190 struct kernfs_open_file *of = kernfs_of(file);
191 191
@@ -196,7 +196,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
196} 196}
197 197
198/** 198/**
199 * kernfs_file_write - kernfs vfs write callback 199 * kernfs_fop_write - kernfs vfs write callback
200 * @file: file pointer 200 * @file: file pointer
201 * @user_buf: data to write 201 * @user_buf: data to write
202 * @count: number of bytes 202 * @count: number of bytes
@@ -211,8 +211,8 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
211 * modify only the the value you're changing, then write entire buffer 211 * modify only the the value you're changing, then write entire buffer
212 * back. 212 * back.
213 */ 213 */
214static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf, 214static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
215 size_t count, loff_t *ppos) 215 size_t count, loff_t *ppos)
216{ 216{
217 struct kernfs_open_file *of = kernfs_of(file); 217 struct kernfs_open_file *of = kernfs_of(file);
218 ssize_t len = min_t(size_t, count, PAGE_SIZE); 218 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 * the ops aren't called concurrently for the same open file. 234 * the ops aren't called concurrently for the same open file.
235 */ 235 */
236 mutex_lock(&of->mutex); 236 mutex_lock(&of->mutex);
237 if (!sysfs_get_active(of->kn)) { 237 if (!kernfs_get_active(of->kn)) {
238 mutex_unlock(&of->mutex); 238 mutex_unlock(&of->mutex);
239 len = -ENODEV; 239 len = -ENODEV;
240 goto out_free; 240 goto out_free;
@@ -246,7 +246,7 @@ static ssize_t kernfs_file_write(struct file *file, const char __user *user_buf,
246 else 246 else
247 len = -EINVAL; 247 len = -EINVAL;
248 248
249 sysfs_put_active(of->kn); 249 kernfs_put_active(of->kn);
250 mutex_unlock(&of->mutex); 250 mutex_unlock(&of->mutex);
251 251
252 if (len > 0) 252 if (len > 0)
@@ -264,13 +264,13 @@ static void kernfs_vma_open(struct vm_area_struct *vma)
264 if (!of->vm_ops) 264 if (!of->vm_ops)
265 return; 265 return;
266 266
267 if (!sysfs_get_active(of->kn)) 267 if (!kernfs_get_active(of->kn))
268 return; 268 return;
269 269
270 if (of->vm_ops->open) 270 if (of->vm_ops->open)
271 of->vm_ops->open(vma); 271 of->vm_ops->open(vma);
272 272
273 sysfs_put_active(of->kn); 273 kernfs_put_active(of->kn);
274} 274}
275 275
276static int kernfs_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 276static 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 if (!of->vm_ops) 282 if (!of->vm_ops)
283 return VM_FAULT_SIGBUS; 283 return VM_FAULT_SIGBUS;
284 284
285 if (!sysfs_get_active(of->kn)) 285 if (!kernfs_get_active(of->kn))
286 return VM_FAULT_SIGBUS; 286 return VM_FAULT_SIGBUS;
287 287
288 ret = VM_FAULT_SIGBUS; 288 ret = VM_FAULT_SIGBUS;
289 if (of->vm_ops->fault) 289 if (of->vm_ops->fault)
290 ret = of->vm_ops->fault(vma, vmf); 290 ret = of->vm_ops->fault(vma, vmf);
291 291
292 sysfs_put_active(of->kn); 292 kernfs_put_active(of->kn);
293 return ret; 293 return ret;
294} 294}
295 295
@@ -303,7 +303,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
303 if (!of->vm_ops) 303 if (!of->vm_ops)
304 return VM_FAULT_SIGBUS; 304 return VM_FAULT_SIGBUS;
305 305
306 if (!sysfs_get_active(of->kn)) 306 if (!kernfs_get_active(of->kn))
307 return VM_FAULT_SIGBUS; 307 return VM_FAULT_SIGBUS;
308 308
309 ret = 0; 309 ret = 0;
@@ -312,7 +312,7 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
312 else 312 else
313 file_update_time(file); 313 file_update_time(file);
314 314
315 sysfs_put_active(of->kn); 315 kernfs_put_active(of->kn);
316 return ret; 316 return ret;
317} 317}
318 318
@@ -326,14 +326,14 @@ static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
326 if (!of->vm_ops) 326 if (!of->vm_ops)
327 return -EINVAL; 327 return -EINVAL;
328 328
329 if (!sysfs_get_active(of->kn)) 329 if (!kernfs_get_active(of->kn))
330 return -EINVAL; 330 return -EINVAL;
331 331
332 ret = -EINVAL; 332 ret = -EINVAL;
333 if (of->vm_ops->access) 333 if (of->vm_ops->access)
334 ret = of->vm_ops->access(vma, addr, buf, len, write); 334 ret = of->vm_ops->access(vma, addr, buf, len, write);
335 335
336 sysfs_put_active(of->kn); 336 kernfs_put_active(of->kn);
337 return ret; 337 return ret;
338} 338}
339 339
@@ -348,14 +348,14 @@ static int kernfs_vma_set_policy(struct vm_area_struct *vma,
348 if (!of->vm_ops) 348 if (!of->vm_ops)
349 return 0; 349 return 0;
350 350
351 if (!sysfs_get_active(of->kn)) 351 if (!kernfs_get_active(of->kn))
352 return -EINVAL; 352 return -EINVAL;
353 353
354 ret = 0; 354 ret = 0;
355 if (of->vm_ops->set_policy) 355 if (of->vm_ops->set_policy)
356 ret = of->vm_ops->set_policy(vma, new); 356 ret = of->vm_ops->set_policy(vma, new);
357 357
358 sysfs_put_active(of->kn); 358 kernfs_put_active(of->kn);
359 return ret; 359 return ret;
360} 360}
361 361
@@ -369,14 +369,14 @@ static struct mempolicy *kernfs_vma_get_policy(struct vm_area_struct *vma,
369 if (!of->vm_ops) 369 if (!of->vm_ops)
370 return vma->vm_policy; 370 return vma->vm_policy;
371 371
372 if (!sysfs_get_active(of->kn)) 372 if (!kernfs_get_active(of->kn))
373 return vma->vm_policy; 373 return vma->vm_policy;
374 374
375 pol = vma->vm_policy; 375 pol = vma->vm_policy;
376 if (of->vm_ops->get_policy) 376 if (of->vm_ops->get_policy)
377 pol = of->vm_ops->get_policy(vma, addr); 377 pol = of->vm_ops->get_policy(vma, addr);
378 378
379 sysfs_put_active(of->kn); 379 kernfs_put_active(of->kn);
380 return pol; 380 return pol;
381} 381}
382 382
@@ -391,14 +391,14 @@ static int kernfs_vma_migrate(struct vm_area_struct *vma,
391 if (!of->vm_ops) 391 if (!of->vm_ops)
392 return 0; 392 return 0;
393 393
394 if (!sysfs_get_active(of->kn)) 394 if (!kernfs_get_active(of->kn))
395 return 0; 395 return 0;
396 396
397 ret = 0; 397 ret = 0;
398 if (of->vm_ops->migrate) 398 if (of->vm_ops->migrate)
399 ret = of->vm_ops->migrate(vma, from, to, flags); 399 ret = of->vm_ops->migrate(vma, from, to, flags);
400 400
401 sysfs_put_active(of->kn); 401 kernfs_put_active(of->kn);
402 return ret; 402 return ret;
403} 403}
404#endif 404#endif
@@ -415,7 +415,7 @@ static const struct vm_operations_struct kernfs_vm_ops = {
415#endif 415#endif
416}; 416};
417 417
418static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma) 418static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)
419{ 419{
420 struct kernfs_open_file *of = kernfs_of(file); 420 struct kernfs_open_file *of = kernfs_of(file);
421 const struct kernfs_ops *ops; 421 const struct kernfs_ops *ops;
@@ -434,7 +434,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
434 mutex_lock(&of->mutex); 434 mutex_lock(&of->mutex);
435 435
436 rc = -ENODEV; 436 rc = -ENODEV;
437 if (!sysfs_get_active(of->kn)) 437 if (!kernfs_get_active(of->kn))
438 goto out_unlock; 438 goto out_unlock;
439 439
440 ops = kernfs_ops(of->kn); 440 ops = kernfs_ops(of->kn);
@@ -465,7 +465,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
465 of->vm_ops = vma->vm_ops; 465 of->vm_ops = vma->vm_ops;
466 vma->vm_ops = &kernfs_vm_ops; 466 vma->vm_ops = &kernfs_vm_ops;
467out_put: 467out_put:
468 sysfs_put_active(of->kn); 468 kernfs_put_active(of->kn);
469out_unlock: 469out_unlock:
470 mutex_unlock(&of->mutex); 470 mutex_unlock(&of->mutex);
471 471
@@ -473,7 +473,7 @@ out_unlock:
473} 473}
474 474
475/** 475/**
476 * sysfs_get_open_dirent - get or create kernfs_open_node 476 * kernfs_get_open_node - get or create kernfs_open_node
477 * @kn: target kernfs_node 477 * @kn: target kernfs_node
478 * @of: kernfs_open_file for this instance of open 478 * @of: kernfs_open_file for this instance of open
479 * 479 *
@@ -486,8 +486,8 @@ out_unlock:
486 * RETURNS: 486 * RETURNS:
487 * 0 on success, -errno on failure. 487 * 0 on success, -errno on failure.
488 */ 488 */
489static int sysfs_get_open_dirent(struct kernfs_node *kn, 489static int kernfs_get_open_node(struct kernfs_node *kn,
490 struct kernfs_open_file *of) 490 struct kernfs_open_file *of)
491{ 491{
492 struct kernfs_open_node *on, *new_on = NULL; 492 struct kernfs_open_node *on, *new_on = NULL;
493 493
@@ -527,7 +527,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
527} 527}
528 528
529/** 529/**
530 * sysfs_put_open_dirent - put kernfs_open_node 530 * kernfs_put_open_node - put kernfs_open_node
531 * @kn: target kernfs_nodet 531 * @kn: target kernfs_nodet
532 * @of: associated kernfs_open_file 532 * @of: associated kernfs_open_file
533 * 533 *
@@ -537,8 +537,8 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
537 * LOCKING: 537 * LOCKING:
538 * None. 538 * None.
539 */ 539 */
540static void sysfs_put_open_dirent(struct kernfs_node *kn, 540static void kernfs_put_open_node(struct kernfs_node *kn,
541 struct kernfs_open_file *of) 541 struct kernfs_open_file *of)
542{ 542{
543 struct kernfs_open_node *on = kn->attr.open; 543 struct kernfs_open_node *on = kn->attr.open;
544 unsigned long flags; 544 unsigned long flags;
@@ -560,7 +560,7 @@ static void sysfs_put_open_dirent(struct kernfs_node *kn,
560 kfree(on); 560 kfree(on);
561} 561}
562 562
563static int kernfs_file_open(struct inode *inode, struct file *file) 563static int kernfs_fop_open(struct inode *inode, struct file *file)
564{ 564{
565 struct kernfs_node *kn = file->f_path.dentry->d_fsdata; 565 struct kernfs_node *kn = file->f_path.dentry->d_fsdata;
566 const struct kernfs_ops *ops; 566 const struct kernfs_ops *ops;
@@ -568,7 +568,7 @@ static int kernfs_file_open(struct inode *inode, struct file *file)
568 bool has_read, has_write, has_mmap; 568 bool has_read, has_write, has_mmap;
569 int error = -EACCES; 569 int error = -EACCES;
570 570
571 if (!sysfs_get_active(kn)) 571 if (!kernfs_get_active(kn))
572 return -ENODEV; 572 return -ENODEV;
573 573
574 ops = kernfs_ops(kn); 574 ops = kernfs_ops(kn);
@@ -633,13 +633,13 @@ static int kernfs_file_open(struct inode *inode, struct file *file)
633 if (file->f_mode & FMODE_WRITE) 633 if (file->f_mode & FMODE_WRITE)
634 file->f_mode |= FMODE_PWRITE; 634 file->f_mode |= FMODE_PWRITE;
635 635
636 /* make sure we have open dirent struct */ 636 /* make sure we have open node struct */
637 error = sysfs_get_open_dirent(kn, of); 637 error = kernfs_get_open_node(kn, of);
638 if (error) 638 if (error)
639 goto err_close; 639 goto err_close;
640 640
641 /* open succeeded, put active references */ 641 /* open succeeded, put active references */
642 sysfs_put_active(kn); 642 kernfs_put_active(kn);
643 return 0; 643 return 0;
644 644
645err_close: 645err_close:
@@ -647,23 +647,23 @@ err_close:
647err_free: 647err_free:
648 kfree(of); 648 kfree(of);
649err_out: 649err_out:
650 sysfs_put_active(kn); 650 kernfs_put_active(kn);
651 return error; 651 return error;
652} 652}
653 653
654static int kernfs_file_release(struct inode *inode, struct file *filp) 654static int kernfs_fop_release(struct inode *inode, struct file *filp)
655{ 655{
656 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata; 656 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
657 struct kernfs_open_file *of = kernfs_of(filp); 657 struct kernfs_open_file *of = kernfs_of(filp);
658 658
659 sysfs_put_open_dirent(kn, of); 659 kernfs_put_open_node(kn, of);
660 seq_release(inode, filp); 660 seq_release(inode, filp);
661 kfree(of); 661 kfree(of);
662 662
663 return 0; 663 return 0;
664} 664}
665 665
666void sysfs_unmap_bin_file(struct kernfs_node *kn) 666void kernfs_unmap_bin_file(struct kernfs_node *kn)
667{ 667{
668 struct kernfs_open_node *on; 668 struct kernfs_open_node *on;
669 struct kernfs_open_file *of; 669 struct kernfs_open_file *of;
@@ -686,10 +686,11 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
686 } 686 }
687 mutex_unlock(&kernfs_open_file_mutex); 687 mutex_unlock(&kernfs_open_file_mutex);
688 688
689 sysfs_put_open_dirent(kn, NULL); 689 kernfs_put_open_node(kn, NULL);
690} 690}
691 691
692/* Sysfs attribute files are pollable. The idea is that you read 692/*
693 * Kernfs attribute files are pollable. The idea is that you read
693 * the content and then you use 'poll' or 'select' to wait for 694 * the content and then you use 'poll' or 'select' to wait for
694 * the content to change. When the content changes (assuming the 695 * the content to change. When the content changes (assuming the
695 * manager for the kobject supports notification), poll will 696 * manager for the kobject supports notification), poll will
@@ -702,19 +703,19 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
702 * to see if it supports poll (Neither 'poll' nor 'select' return 703 * to see if it supports poll (Neither 'poll' nor 'select' return
703 * an appropriate error code). When in doubt, set a suitable timeout value. 704 * an appropriate error code). When in doubt, set a suitable timeout value.
704 */ 705 */
705static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait) 706static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
706{ 707{
707 struct kernfs_open_file *of = kernfs_of(filp); 708 struct kernfs_open_file *of = kernfs_of(filp);
708 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata; 709 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
709 struct kernfs_open_node *on = kn->attr.open; 710 struct kernfs_open_node *on = kn->attr.open;
710 711
711 /* need parent for the kobj, grab both */ 712 /* need parent for the kobj, grab both */
712 if (!sysfs_get_active(kn)) 713 if (!kernfs_get_active(kn))
713 goto trigger; 714 goto trigger;
714 715
715 poll_wait(filp, &on->poll, wait); 716 poll_wait(filp, &on->poll, wait);
716 717
717 sysfs_put_active(kn); 718 kernfs_put_active(kn);
718 719
719 if (of->event != atomic_read(&on->event)) 720 if (of->event != atomic_read(&on->event))
720 goto trigger; 721 goto trigger;
@@ -751,13 +752,13 @@ void kernfs_notify(struct kernfs_node *kn)
751EXPORT_SYMBOL_GPL(kernfs_notify); 752EXPORT_SYMBOL_GPL(kernfs_notify);
752 753
753const struct file_operations kernfs_file_fops = { 754const struct file_operations kernfs_file_fops = {
754 .read = kernfs_file_read, 755 .read = kernfs_fop_read,
755 .write = kernfs_file_write, 756 .write = kernfs_fop_write,
756 .llseek = generic_file_llseek, 757 .llseek = generic_file_llseek,
757 .mmap = kernfs_file_mmap, 758 .mmap = kernfs_fop_mmap,
758 .open = kernfs_file_open, 759 .open = kernfs_fop_open,
759 .release = kernfs_file_release, 760 .release = kernfs_fop_release,
760 .poll = kernfs_file_poll, 761 .poll = kernfs_fop_poll,
761}; 762};
762 763
763/** 764/**
@@ -784,8 +785,8 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
784 struct kernfs_node *kn; 785 struct kernfs_node *kn;
785 int rc; 786 int rc;
786 787
787 kn = sysfs_new_dirent(kernfs_root(parent), name, 788 kn = kernfs_new_node(kernfs_root(parent), name,
788 (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE); 789 (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE);
789 if (!kn) 790 if (!kn)
790 return ERR_PTR(-ENOMEM); 791 return ERR_PTR(-ENOMEM);
791 792
@@ -811,9 +812,9 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
811 if (ops->mmap) 812 if (ops->mmap)
812 kn->flags |= KERNFS_HAS_MMAP; 813 kn->flags |= KERNFS_HAS_MMAP;
813 814
814 sysfs_addrm_start(&acxt); 815 kernfs_addrm_start(&acxt);
815 rc = sysfs_add_one(&acxt, kn, parent); 816 rc = kernfs_add_one(&acxt, kn, parent);
816 sysfs_addrm_finish(&acxt); 817 kernfs_addrm_finish(&acxt);
817 818
818 if (rc) { 819 if (rc) {
819 kernfs_put(kn); 820 kernfs_put(kn);