diff options
Diffstat (limited to 'ufs/main.c')
-rw-r--r-- | ufs/main.c | 63 |
1 files changed, 20 insertions, 43 deletions
@@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994,95,96,97,98,99,2002 Free Software Foundation, Inc. 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) @@ -133,7 +136,7 @@ struct argp *diskfs_runtime_argp = (struct argp *)&runtime_argp; /* Override the standard diskfs routine so we can add our own output. */ error_t -diskfs_append_args (char **argz, unsigned *argz_len) +diskfs_append_args (char **argz, size_t *argz_len) { error_t err; @@ -155,56 +158,28 @@ diskfs_append_args (char **argz, unsigned *argz_len) int main (int argc, char **argv) { - error_t err; mach_port_t bootstrap; - struct store_argp_params store_params = { 0 }; - - argp_parse (&startup_argp, argc, argv, 0, 0, &store_params); - store_parsed = store_params.result; - err = store_parsed_name (store_parsed, &diskfs_disk_name); - if (err) - error (2, err, "store_parsed_name"); + /* Initialize the diskfs library, parse arguments, and open the store. + This starts the first diskfs thread for us. */ + store = diskfs_init_main (&startup_argp, argc, argv, + &store_parsed, &bootstrap); - /* This must come after the args have been parsed, as this is where the - host priv ports are set for booting. */ - diskfs_console_stdio (); - - if (diskfs_boot_flags) - /* We are the bootstrap filesystem. */ - bootstrap = MACH_PORT_NULL; - else - { - task_get_bootstrap_port (mach_task_self (), &bootstrap); - if (bootstrap == MACH_PORT_NULL) - error (2, 0, "Must be started as a translator"); - } - - /* Initialize the diskfs library. Must come before any other diskfs call. */ - err = diskfs_init_diskfs (); - if (err) - error (4, err, "init"); - - err = store_parsed_open (store_parsed, diskfs_readonly ? STORE_READONLY : 0, - &store); - 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, 0, "%s: Bad device block size %zd (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); + if (store->size < SBSIZE + SBOFF) + error (5, 0, "%s: Disk too small (%Ld bytes)", diskfs_disk_name, + store->size); - assert (store->size >= SBSIZE + SBOFF); + 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 (); - /* Start the first request thread, to handle RPCs and page requests. */ - diskfs_spawn_first_thread (); - get_hypermetadata (); inode_init (); @@ -217,6 +192,8 @@ main (int argc, char **argv) outside world. */ diskfs_startup_diskfs (bootstrap, 0); + /* SET HOST NAME */ + /* And this thread is done with its work. */ cthread_exit (0); |