[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] console: fix listing of directory in netfs_get_dirents
From: |
Andrea Monaco |
Subject: |
[PATCH] console: fix listing of directory in netfs_get_dirents |
Date: |
Thu, 11 Nov 2021 10:45:48 +0100 |
Hello,
on my system, listing /dev/vcs which is translated by /hurd/console
gives the following:
$ ls /dev/vcs
ls: reading directory '/dev/vcs': Invalid argument
1 2 3 4 5 6
That error is probably harmless but annoying.
It is caused by netfs_get_dirents the last time it is called during
listing, because it calls mmap with size = 0.
Anyway, here's the patch.
Cheers,
Andrea Monaco
diff --git a/console/console.c b/console/console.c
index 6e83fbbc..7306b6b8 100644
--- a/console/console.c
+++ b/console/console.c
@@ -750,7 +750,7 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
mach_msg_type_number_t *data_len,
vm_size_t max_data_len, int *data_entries)
{
- error_t err;
+ error_t err = 0;
int count = 0;
size_t size = 0; /* Total size of our return block. */
struct vcons *first_vcons = NULL;
@@ -813,11 +813,16 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
bump_size ("input");
}
- /* Allocate it. */
- *data = mmap (0, size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
- err = ((void *) *data == (void *) -1) ? errno : 0;
+ if (!size)
+ *data_len = *data_entries = 0;
+ else
+ {
+ /* Allocate it. */
+ *data = mmap (0, size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ err = ((void *) *data == (void *) -1) ? errno : 0;
+ }
- if (! err)
+ if (size && !err)
/* Copy out the result. */
{
char *p = *data;
- [PATCH] console: fix listing of directory in netfs_get_dirents,
Andrea Monaco <=