summaryrefslogtreecommitdiff
path: root/procfs.c
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-23 20:43:16 +0000
committerJeremie Koenig <jk@jk.fr.eu.org>2010-08-30 14:31:32 +0200
commitb3d304167929bc199e6789fd67ffea035e7fdbf1 (patch)
tree4a69de8b4442a7bd66350fb6876788d0e779d459 /procfs.c
parent7b027a34676880bded1a05a5c47bfa85a6e79092 (diff)
Refresh nodes when they're read from the start.
This is necessary for top, for instance, which keeps some files open and re-reads them regularly. As an extra bonus we can drop the refresh hack. * procfs.c, procfs.h: Remove the refresh hack. (procfs_refresh): New function, invalidates the cached contents. * netfs.c (netfs_attempt_read, netfs_get_dirents): Call procfs_refresh when the read is from offset 0. * proclist.c (proclist_make_node): Remove the refresh hack. * dircat.c (dircat_make_node): Likewise. (dircat_get_contents): Use procfs_refresh to avoid keeping old data from the component nodes.
Diffstat (limited to 'procfs.c')
-rw-r--r--procfs.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/procfs.c b/procfs.c
index 6d15e4f..f7b2834 100644
--- a/procfs.c
+++ b/procfs.c
@@ -111,14 +111,6 @@ procfs_make_ino (struct node *np, const char *filename)
error_t procfs_get_contents (struct node *np, char **data, ssize_t *data_len)
{
- if (np->nn->ops->enable_refresh_hack_and_break_readdir && np->nn->contents)
- {
- if (np->nn->ops->cleanup_contents)
- np->nn->ops->cleanup_contents (np->nn->hook, np->nn->contents,
- np->nn->contents_len);
- np->nn->contents = NULL;
- }
-
if (! np->nn->contents && np->nn->ops->get_contents)
{
char *contents;
@@ -141,6 +133,14 @@ error_t procfs_get_contents (struct node *np, char **data, ssize_t *data_len)
return 0;
}
+void procfs_refresh (struct node *np)
+{
+ if (np->nn->contents && np->nn->ops->cleanup_contents)
+ np->nn->ops->cleanup_contents (np->nn->hook, np->nn->contents, np->nn->contents_len);
+
+ np->nn->contents = NULL;
+}
+
error_t procfs_lookup (struct node *np, const char *name, struct node **npp)
{
error_t err = ENOENT;
@@ -172,8 +172,7 @@ error_t procfs_lookup (struct node *np, const char *name, struct node **npp)
void procfs_cleanup (struct node *np)
{
- if (np->nn->contents && np->nn->ops->cleanup_contents)
- np->nn->ops->cleanup_contents (np->nn->hook, np->nn->contents, np->nn->contents_len);
+ procfs_refresh (np);
if (np->nn->ops->cleanup)
np->nn->ops->cleanup (np->nn->hook);