From 7868e5f8fc2ba7c4b722d7faee35fd451b1f7128 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 20 Jun 1997 19:26:29 +0000 Subject: (log2_dev_blocks_per_bsize): New variable. (main): Only require device-block-size to be <= DEV_BSIZE. Get rid of device-block-size-is-power-of-2 check. Set LOG2_DEV_BLOCKS_PER_BSIZE. Exit with an error if the disk is too small rather than assert failing. --- ufs/main.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'ufs') diff --git a/ufs/main.c b/ufs/main.c index f0ffa3f5..61531c22 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -36,6 +36,9 @@ struct store_parsed *store_parsed = 0; char *diskfs_disk_name = 0; +/* Number of device blocks per DEV_BSIZE block. */ +unsigned log2_dev_blocks_per_dev_bsize = 0; + /* Set diskfs_root_node to the root inode. */ static void warp_root (void) @@ -190,14 +193,17 @@ main (int argc, char **argv) if (err) error (3, err, "%s", diskfs_disk_name); - if (store->block_size != DEV_BSIZE) - error (4, err, "%s: Bad device record size %d (should be %d)", + if (store->block_size > DEV_BSIZE) + error (4, err, "%s: Bad device block size %d (should be <= %d)", diskfs_disk_name, store->block_size, DEV_BSIZE); - if (store->log2_block_size == 0) - error (4, err, "%s: Device block size (%d) not a power of 2", - diskfs_disk_name, store->block_size); - - assert (store->size >= SBSIZE + SBOFF); + if (store->size < SBSIZE + SBOFF) + error (5, 0, "%s: Disk too small (%ld bytes)", diskfs_disk_name, + store->size); + + log2_dev_blocks_per_dev_bsize = 0; + while ((1 << log2_dev_blocks_per_dev_bsize) < DEV_BSIZE) + log2_dev_blocks_per_dev_bsize++; + log2_dev_blocks_per_dev_bsize -= store->log2_block_size; /* Map the entire disk. */ create_disk_pager (); -- cgit v1.2.3