diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-20 19:08:51 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 14:24:53 -0500 |
commit | 6b0bfe9383a54cf35046980c61f5ff8fefa557d7 (patch) | |
tree | 3206ee6374ba6b735e97ce7af60ed8a48df0df9c /fs/sysfs/dir.c | |
parent | 35df63c46c8605d00140ec4833d2104e2e9f1acc (diff) |
sysfs: Update s_iattr on link and unlink.
Currently sysfs updates the timestamps on the vfs directory
inode when we create or remove a directory entry but doesn't
update the cached copy on the sysfs_dirent, fix that oversight.
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r-- | fs/sysfs/dir.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 9ee130be03be..36ee6d817956 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -464,6 +464,8 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, | |||
464 | */ | 464 | */ |
465 | int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | 465 | int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) |
466 | { | 466 | { |
467 | struct sysfs_inode_attrs *ps_iattr; | ||
468 | |||
467 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_name)) | 469 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_name)) |
468 | return -EEXIST; | 470 | return -EEXIST; |
469 | 471 | ||
@@ -476,6 +478,13 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
476 | 478 | ||
477 | sysfs_link_sibling(sd); | 479 | sysfs_link_sibling(sd); |
478 | 480 | ||
481 | /* Update timestamps on the parent */ | ||
482 | ps_iattr = acxt->parent_sd->s_iattr; | ||
483 | if (ps_iattr) { | ||
484 | struct iattr *ps_iattrs = &ps_iattr->ia_iattr; | ||
485 | ps_iattrs->ia_ctime = ps_iattrs->ia_mtime = CURRENT_TIME; | ||
486 | } | ||
487 | |||
479 | return 0; | 488 | return 0; |
480 | } | 489 | } |
481 | 490 | ||
@@ -554,10 +563,19 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
554 | */ | 563 | */ |
555 | void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | 564 | void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) |
556 | { | 565 | { |
566 | struct sysfs_inode_attrs *ps_iattr; | ||
567 | |||
557 | BUG_ON(sd->s_flags & SYSFS_FLAG_REMOVED); | 568 | BUG_ON(sd->s_flags & SYSFS_FLAG_REMOVED); |
558 | 569 | ||
559 | sysfs_unlink_sibling(sd); | 570 | sysfs_unlink_sibling(sd); |
560 | 571 | ||
572 | /* Update timestamps on the parent */ | ||
573 | ps_iattr = acxt->parent_sd->s_iattr; | ||
574 | if (ps_iattr) { | ||
575 | struct iattr *ps_iattrs = &ps_iattr->ia_iattr; | ||
576 | ps_iattrs->ia_ctime = ps_iattrs->ia_mtime = CURRENT_TIME; | ||
577 | } | ||
578 | |||
561 | sd->s_flags |= SYSFS_FLAG_REMOVED; | 579 | sd->s_flags |= SYSFS_FLAG_REMOVED; |
562 | sd->s_sibling = acxt->removed; | 580 | sd->s_sibling = acxt->removed; |
563 | acxt->removed = sd; | 581 | acxt->removed = sd; |