From 16d932fbe5789433781cf698bcfcf4797d1afe74 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 29 Oct 1994 01:53:33 +0000 Subject: entered into RCS --- libdiskfs/boot-parse.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/libdiskfs/boot-parse.c b/libdiskfs/boot-parse.c index 1f83041b..09e3ecb2 100644 --- a/libdiskfs/boot-parse.c +++ b/libdiskfs/boot-parse.c @@ -160,12 +160,25 @@ diskfs_parse_bootargs (int argc, char **argv) if (diskfs_bootflags & RB_ASKNAME) { - char *tmp; + char *line = NULL; + size_t linesz = 0; + ssize_t len; printf ("Bootstrap filesystem device name [%s]: ", devname); - fflush (stdout); - scanf ("%as\n", &tmp); - if (*tmp) - devname = tmp; + switch (len = getline (&line, &linesz, stdin)) + { + case -1: + perror ("getline"); + printf ("Using default of `%s'.\n", devname); + case 0: /* Hmm. */ + case 1: /* Empty line, just a newline. */ + /* Use default. */ + free (line); + break; + default: + line[len - 1] = '\0'; /* Remove the newline. */ + devname = line; + break; + } } printf ("\nInitial bootstrap: %s", argv[0]); -- cgit v1.2.3