diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-19 04:52:17 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:14:50 +0200 |
commit | 4ac169deaa1eb4c8df4a49fc940700971fa5863a (patch) | |
tree | 58d5b4c55b5fad7f68adf0a725dc2baa8069e9ec | |
parent | 97e598086b37583585b455d2b804b6e49d97ea85 (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.c | 6 |
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); |