summaryrefslogtreecommitdiff
path: root/ufs
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-11-09 10:43:07 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-11-09 10:43:07 +0000
commit83eb31308b0ad461c79c1482456534d33457d30e (patch)
treeaec3a17655200355b87bb5d3cd471569ec8255e1 /ufs
parentaccc41675d4952569dcefda1b0d0c30aab2e7a35 (diff)
(main): Behave more reasonably if we can't open DEVNAME.
Diffstat (limited to 'ufs')
-rw-r--r--ufs/main.c30
1 files 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);