1/** 2 * \file 3 * \brief block_server process. 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 13 */ 14#include <stdio.h> 15#include <string.h> 16 17#include <barrelfish/barrelfish.h> 18 19#include <bulk_transfer/bulk_transfer.h> 20#include <bulk_transfer/bulk_allocator.h> 21 22#include "block_server.h" 23#include "local_server.h" 24#include "network_server.h" 25#include "block_storage.h" 26 27 28 29 30/** 31 * 32 * 33 */ 34int main(int argc, char *argv[]) 35{ 36 debug_printf("block server started.\n"); 37 38 errval_t err; 39 40 41 42 /* initialize the block store */ 43 err = block_storage_init(BLOCK_COUNT, BLOCK_SIZE); 44 if (err_is_fail(err)) { 45 USER_PANIC_ERR(err, "could not initialize the block service.\n"); 46 exit(EXIT_FAILURE); 47 } 48 49 50#if BLOCK_ENABLE_NETWORKING 51 /* initialize the network service */ 52 err = block_net_init(BLOCK_NET_PORT); 53 if (err_is_fail(err)) { 54 block_storage_dealloc(); 55 USER_PANIC_ERR(err, "could not initialize the network service.\n"); 56 exit(EXIT_FAILURE); 57 } 58 59 /* start the network service */ 60 debug_printf(" > Network initialization done. Starting Server.\n"); 61 err = block_net_start(); 62 63 assert(!"should not reach that point"); 64#else 65 /* Initialize the core local flounder interface */ 66 struct block_net_service local_service; 67 err = block_local_init(&local_service, SERVICE_FLAG_DEFAULT); 68 if (err_is_fail(err)) { 69 block_storage_dealloc(); 70 USER_PANIC_ERR(err, "could not initialize the flounder service.\n"); 71 exit(EXIT_FAILURE); 72 } 73 74 /* start the floudner service */ 75 debug_printf(" > Local initialization done. Starting Server.\n"); 76 err = block_local_start(); 77 78 while (1) { 79 messages_wait_and_handle_next(); 80 } 81#endif 82 83} 84 85