From 36bbd74ce7b1d03b34846bfd76605dcd0afb9c38 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 15 Jun 1994 20:52:03 +0000 Subject: Formerly main.c.~11~ --- ufs/main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ufs/main.c b/ufs/main.c index 8c6114ed..e47586e7 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -112,6 +112,9 @@ main (int argc, char **argv) char *devname; mach_port_t bootstrap; error_t err; + int sizes[DEV_GET_SIZE_COUNT]; + u_int sizescnt = 2; + save_argv = argv; @@ -133,9 +136,31 @@ main (int argc, char **argv) (diskfs_readonly ? 0 : D_WRITE) | D_READ, devname, &ufs_device); assert (!err); + + /* Check to make sure device sector size is reasonable. */ + err = device_get_status (ufs_device, DEV_GET_SIZE, sizes, &sizescnt); + assert (sizescnt == DEV_GET_SIZE_COUNT); + if (sizes[DEV_GET_SIZE_RECORD_SIZE] != DEV_BSIZE) + { + fprintf (stderr, "Bad device record size %d (should be %d)\n", + sizes[DEV_GET_SIZE_RECORD_SIZE], DEV_BSIZE); + exit (1); + } get_hypermetadata (); + /* Check to make sure device size is big enough. */ + if (sizes[DEV_GET_SIZE_DEVICE_SIZE] != 0) + if (sizes[DEV_GET_SIZE_DEVICE_SIZE] < sblock->fs_size * sblock->fs_fsize) + { + fprintf (stderr, + "Disk size %d less than necessary " + "(superblock says we need %ld)\n", + sizes[DEV_GET_SIZE_DEVICE_SIZE], + sblock->fs_size * sblock->fs_fsize); + exit (1); + } + if (!diskfs_readonly) { sblock->fs_clean = 0; -- cgit v1.2.3