summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-19 04:52:17 +0000
committerJeremie Koenig <jk@jk.fr.eu.org>2010-08-30 14:14:50 +0200
commite9b239bbec8cae14a9a4d510bae7496d733e5812 (patch)
tree03502e0eeb64752ceb60d1434dc9e5a028470a71
parent1f9c094faa066aff3e02f00f997bfc37756cdd1f (diff)
Add the dot entries to directories
* procfs_dir.c (procfs_dir_get_contents): Prepend the . and .. entries to the ones from the given table.
-rw-r--r--procfs_dir.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/procfs_dir.c b/procfs_dir.c
index b7fb28fa..431fea3e 100644
--- a/procfs_dir.c
+++ b/procfs_dir.c
@@ -13,11 +13,12 @@ struct procfs_dir_node
static error_t
procfs_dir_get_contents (void *hook, void **contents, size_t *contents_len)
{
+ static const char dot_dotdot[] = ".\0..";
struct procfs_dir_node *dn = hook;
const struct procfs_dir_entry *ent;
char *pos;
- *contents_len = 0;
+ *contents_len = sizeof dot_dotdot;
for (ent = dn->entries; ent->name; ent++)
*contents_len += strlen (ent->name) + 1;
@@ -25,7 +26,8 @@ procfs_dir_get_contents (void *hook, void **contents, size_t *contents_len)
if (! *contents)
return ENOMEM;
- pos = *contents;
+ memcpy (*contents, dot_dotdot, sizeof dot_dotdot);
+ pos = *contents + sizeof dot_dotdot;
for (ent = dn->entries; ent->name; ent++)
{
strcpy (pos, ent->name);