Set a default sysname in #cons
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 6 Sep 2016 20:39:07 +0000 (16:39 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 7 Sep 2016 16:38:17 +0000 (12:38 -0400)
gethostname() reads this.  We want something for machines that didn't set
up their hostname/sysname.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/drivers/dev/cons.c

index 757777e..be55d83 100644 (file)
@@ -677,6 +677,7 @@ int consreadstr(uint32_t off, char *buf, uint32_t n, char *str)
 
 static void consinit(void)
 {
+       kstrdup(&sysname, "nanwan");
 #if 0
        todinit();
 #endif
@@ -959,6 +960,7 @@ static long consread(struct chan *c, void *buf, long n, int64_t off)
 #endif
 
                case Qsysname:
+                       /* TODO: this is racy */
                        if (sysname == NULL)
                                return 0;
                        return consreadstr((uint32_t) offset, buf, n, sysname);
@@ -1178,6 +1180,7 @@ static long conswrite(struct chan *c, void *va, long n, int64_t off)
 #endif
 
                case Qsysname:
+                       /* TODO: this is racy */
                        if (offset != 0)
                                error(EINVAL, ERROR_FIXME);
                        if (n <= 0 || n >= sizeof buf)