summaryrefslogtreecommitdiff
path: root/ufs/main.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-06-20 19:26:29 +0000
committerMiles Bader <miles@gnu.org>1997-06-20 19:26:29 +0000
commit7868e5f8fc2ba7c4b722d7faee35fd451b1f7128 (patch)
treeb59b899f0ced39b8d592fa44511791aadd82401e /ufs/main.c
parent6b9d0267366154b5ba0a6be99c4778f9be8b72d7 (diff)
(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.
Diffstat (limited to 'ufs/main.c')
-rw-r--r--ufs/main.c22
1 files changed, 14 insertions, 8 deletions
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 ();