aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/file.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-06-13 15:27:22 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 19:09:08 -0400
commit608e266a2d4e62c1b98c1c573064b6afe8c06a58 (patch)
tree73d670ab6c315b42273bc9d2731ec2b8e7c199af /fs/sysfs/file.c
parentf0b0af4792d751106e2003f96af76fa95e10c68d (diff)
sysfs: make kobj point to sysfs_dirent instead of dentry
As kobj sysfs dentries and inodes are gonna be made reclaimable, dentry can't be used as naming token for sysfs file/directory, replace kobj->dentry with kobj->sd. The only external interface change is shadow directory handling. All other changes are contained in kobj and sysfs. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r--fs/sysfs/file.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index e448b88e313e..20703b9ee064 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -385,7 +385,7 @@ static struct dentry *step_down(struct dentry *dir, const char * name)
385 385
386void sysfs_notify(struct kobject * k, char *dir, char *attr) 386void sysfs_notify(struct kobject * k, char *dir, char *attr)
387{ 387{
388 struct dentry *de = k->dentry; 388 struct dentry *de = k->sd->s_dentry;
389 if (de) 389 if (de)
390 dget(de); 390 dget(de);
391 if (de && dir) 391 if (de && dir)
@@ -412,16 +412,17 @@ const struct file_operations sysfs_file_operations = {
412}; 412};
413 413
414 414
415int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type) 415int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr,
416 int type)
416{ 417{
417 struct sysfs_dirent * parent_sd = dir->d_fsdata; 418 struct dentry *dir = dir_sd->s_dentry;
418 umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG; 419 umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG;
419 struct sysfs_dirent *sd; 420 struct sysfs_dirent *sd;
420 int error = 0; 421 int error = 0;
421 422
422 mutex_lock(&dir->d_inode->i_mutex); 423 mutex_lock(&dir->d_inode->i_mutex);
423 424
424 if (sysfs_find_dirent(parent_sd, attr->name)) { 425 if (sysfs_find_dirent(dir_sd, attr->name)) {
425 error = -EEXIST; 426 error = -EEXIST;
426 goto out_unlock; 427 goto out_unlock;
427 } 428 }
@@ -432,7 +433,7 @@ int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type)
432 goto out_unlock; 433 goto out_unlock;
433 } 434 }
434 sd->s_elem.attr.attr = (void *)attr; 435 sd->s_elem.attr.attr = (void *)attr;
435 sysfs_attach_dirent(sd, parent_sd, NULL); 436 sysfs_attach_dirent(sd, dir_sd, NULL);
436 437
437 out_unlock: 438 out_unlock:
438 mutex_unlock(&dir->d_inode->i_mutex); 439 mutex_unlock(&dir->d_inode->i_mutex);
@@ -448,9 +449,9 @@ int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type)
448 449
449int sysfs_create_file(struct kobject * kobj, const struct attribute * attr) 450int sysfs_create_file(struct kobject * kobj, const struct attribute * attr)
450{ 451{
451 BUG_ON(!kobj || !kobj->dentry || !attr); 452 BUG_ON(!kobj || !kobj->sd || !attr);
452 453
453 return sysfs_add_file(kobj->dentry, attr, SYSFS_KOBJ_ATTR); 454 return sysfs_add_file(kobj->sd, attr, SYSFS_KOBJ_ATTR);
454 455
455} 456}
456 457
@@ -464,16 +465,16 @@ int sysfs_create_file(struct kobject * kobj, const struct attribute * attr)
464int sysfs_add_file_to_group(struct kobject *kobj, 465int sysfs_add_file_to_group(struct kobject *kobj,
465 const struct attribute *attr, const char *group) 466 const struct attribute *attr, const char *group)
466{ 467{
467 struct dentry *dir; 468 struct sysfs_dirent *dir_sd;
468 int error; 469 int error;
469 470
470 dir = lookup_one_len(group, kobj->dentry, strlen(group)); 471 dir_sd = sysfs_get_dirent(kobj->sd, group);
471 if (IS_ERR(dir)) 472 if (!dir_sd)
472 error = PTR_ERR(dir); 473 return -ENOENT;
473 else { 474
474 error = sysfs_add_file(dir, attr, SYSFS_KOBJ_ATTR); 475 error = sysfs_add_file(dir_sd, attr, SYSFS_KOBJ_ATTR);
475 dput(dir); 476 sysfs_put(dir_sd);
476 } 477
477 return error; 478 return error;
478} 479}
479EXPORT_SYMBOL_GPL(sysfs_add_file_to_group); 480EXPORT_SYMBOL_GPL(sysfs_add_file_to_group);
@@ -486,7 +487,7 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group);
486 */ 487 */
487int sysfs_update_file(struct kobject * kobj, const struct attribute * attr) 488int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
488{ 489{
489 struct dentry * dir = kobj->dentry; 490 struct dentry *dir = kobj->sd->s_dentry;
490 struct dentry * victim; 491 struct dentry * victim;
491 int res = -ENOENT; 492 int res = -ENOENT;
492 493
@@ -522,7 +523,7 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
522 */ 523 */
523int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) 524int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
524{ 525{
525 struct dentry *dir = kobj->dentry; 526 struct dentry *dir = kobj->sd->s_dentry;
526 struct dentry *victim; 527 struct dentry *victim;
527 struct inode * inode; 528 struct inode * inode;
528 struct iattr newattrs; 529 struct iattr newattrs;
@@ -560,7 +561,7 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file);
560 561
561void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) 562void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr)
562{ 563{
563 sysfs_hash_and_remove(kobj->dentry, attr->name); 564 sysfs_hash_and_remove(kobj->sd, attr->name);
564} 565}
565 566
566 567
@@ -573,12 +574,12 @@ void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr)
573void sysfs_remove_file_from_group(struct kobject *kobj, 574void sysfs_remove_file_from_group(struct kobject *kobj,
574 const struct attribute *attr, const char *group) 575 const struct attribute *attr, const char *group)
575{ 576{
576 struct dentry *dir; 577 struct sysfs_dirent *dir_sd;
577 578
578 dir = lookup_one_len(group, kobj->dentry, strlen(group)); 579 dir_sd = sysfs_get_dirent(kobj->sd, group);
579 if (!IS_ERR(dir)) { 580 if (dir_sd) {
580 sysfs_hash_and_remove(dir, attr->name); 581 sysfs_hash_and_remove(dir_sd, attr->name);
581 dput(dir); 582 sysfs_put(dir_sd);
582 } 583 }
583} 584}
584EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group); 585EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group);