aboutsummaryrefslogtreecommitdiff
path: root/procfs.h
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.h
parent7b027a34676880bded1a05a5c47bfa85a6e79092 (diff)
downloadhurd-b3d304167929bc199e6789fd67ffea035e7fdbf1.tar.gz
hurd-b3d304167929bc199e6789fd67ffea035e7fdbf1.tar.bz2
hurd-b3d304167929bc199e6789fd67ffea035e7fdbf1.zip
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.h')
-rw-r--r--procfs.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/procfs.h b/procfs.h
index e8ef18b3..a9665f97 100644
--- a/procfs.h
+++ b/procfs.h
@@ -32,14 +32,6 @@ struct procfs_node_ops
/* Destroy this node. */
void (*cleanup) (void *hook);
-
- /* FIXME: This is needed because the root node is persistent, and we
- want the list of processes to be updated. However, this means that
- readdir() on the root node runs the risk of returning incoherent
- results if done in multiple runs and processes are added/removed in
- the meantime. The right way to fix this is probably to add a
- getroot() user hook function to libnetfs. */
- int enable_refresh_hack_and_break_readdir;
};
/* These helper functions can be used as procfs_node_ops.cleanup_contents. */
@@ -71,6 +63,11 @@ void procfs_node_chtype (struct node *np, mode_t type);
corresponding child nodes. */
ino64_t procfs_make_ino (struct node *np, const char *filename);
+/* Forget the current cached contents for the node. This is done before reads
+ from offset 0, to ensure that the data are recent even for utilities such as
+ top which keep some nodes open. */
+void procfs_refresh (struct node *np);
+
error_t procfs_get_contents (struct node *np, char **data, ssize_t *data_len);
error_t procfs_lookup (struct node *np, const char *name, struct node **npp);
void procfs_cleanup (struct node *np);