From 83eb31308b0ad461c79c1482456534d33457d30e Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 9 Nov 1994 10:43:07 +0000 Subject: (main): Behave more reasonably if we can't open DEVNAME. --- ufs/main.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/ufs/main.c b/ufs/main.c index 4c617193..0e6bd19d 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -129,10 +129,32 @@ main (int argc, char **argv) any other diskfs call. */ diskfs_init_diskfs (); - err = device_open (diskfs_master_device, - (diskfs_readonly ? 0 : D_WRITE) | D_READ, - devname, &ufs_device); - assert (!err); + do + { + char *line = 0; + size_t linesz = 0; + ssize_t len; + + err = device_open (diskfs_master_device, + (diskfs_readonly ? 0 : D_WRITE) | D_READ, + devname, &ufs_device); + if (err == D_NO_SUCH_DEVICE && getpid () <= 0) + { + /* Prompt the user to give us another name rather + than just crashing */ + printf ("Cannot open device %s\n", devname); + len = getline (&line, &linesz, stdin); + if (len > 2) + devname = line; + } + } + while (err && err == D_NO_SUCH_DEVICE && getpid () <= 0); + + if (err) + { + perror (devname); + exit (1); + } /* Check to make sure device sector size is reasonable. */ err = device_get_status (ufs_device, DEV_GET_SIZE, sizes, &sizescnt); -- cgit v1.2.3