diff options
author | Michael I. Bushnell <mib@gnu.org> | 1994-11-09 10:43:07 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1994-11-09 10:43:07 +0000 |
commit | 83eb31308b0ad461c79c1482456534d33457d30e (patch) | |
tree | aec3a17655200355b87bb5d3cd471569ec8255e1 | |
parent | accc41675d4952569dcefda1b0d0c30aab2e7a35 (diff) |
(main): Behave more reasonably if we can't open DEVNAME.
-rw-r--r-- | ufs/main.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -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); |