summaryrefslogtreecommitdiff
path: root/console-client
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-18 01:08:14 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-11-18 01:08:14 +0100
commitc56cf579b7d7b78d26772331efbf099b3e53c456 (patch)
tree8d5975275c34135089e64eb019ef3dea99e9f148 /console-client
parent3901af56b3bc118ff574014b1282636dd4aa95b9 (diff)
console-client: Fix listing nodes
* console-client/trans.c (netfs_get_dirents): Fix counting the start node. Return 0 when there are no entries left, instead of trying to mmap zero bytes. (console_create_consnode): Set inode number, other entries get ignored by glibc's readdir().
Diffstat (limited to 'console-client')
-rw-r--r--console-client/trans.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/console-client/trans.c b/console-client/trans.c
index a636b3f5..0285a234 100644
--- a/console-client/trans.c
+++ b/console-client/trans.c
@@ -698,8 +698,8 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
for (first_node = node_list, count = 2;
first_node && first_entry > count;
- first_node = first_node->next);
- count++;
+ first_node = first_node->next)
+ count++;
count = 0;
@@ -711,8 +711,14 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
for (cn = first_node; cn; cn = cn->next)
bump_size (cn->name);
-
-
+
+ if (size == 0)
+ {
+ *data_len = size;
+ *data_entries = count;
+ return 0;
+ }
+
/* Allocate it. */
*data = mmap (0, size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
err = ((void *) *data == (void *) -1) ? errno : 0;
@@ -798,6 +804,9 @@ console_client_translator (void *unused)
error_t
console_create_consnode (const char *name, consnode_t *cn)
{
+ /* inode number, 2 is reserved for the root */
+ static int cn_id = 3;
+
*cn = malloc (sizeof (struct consnode));
if (!*cn)
return ENOMEM;
@@ -809,6 +818,7 @@ console_create_consnode (const char *name, consnode_t *cn)
return ENOMEM;
}
+ (*cn)->id = cn_id++;
(*cn)->readlink = NULL;
(*cn)->mksymlink = NULL;