From 4ac169deaa1eb4c8df4a49fc940700971fa5863a Mon Sep 17 00:00:00 2001 From: Jeremie Koenig Date: Thu, 19 Aug 2010 04:52:17 +0000 Subject: Add the dot entries to directories * procfs_dir.c (procfs_dir_get_contents): Prepend the . and .. entries to the ones from the given table. --- procfs_dir.c | 6 ++++-- 1 file 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); -- cgit v1.2.3