diff options
author | Simon Rettberg | 2013-08-01 19:35:48 +0200 |
---|---|---|
committer | Simon Rettberg | 2013-08-01 19:35:48 +0200 |
commit | e7ad62c1b1627f7bab2524a4c30f1833f6b6767d (patch) | |
tree | 090473456331c3fa25eafc2db60e4c2808d808a9 /src/server/server.c | |
parent | [SERVER] Add command line options to create empty image of certain size with ... (diff) | |
download | dnbd3-e7ad62c1b1627f7bab2524a4c30f1833f6b6767d.tar.gz dnbd3-e7ad62c1b1627f7bab2524a4c30f1833f6b6767d.tar.xz dnbd3-e7ad62c1b1627f7bab2524a4c30f1833f6b6767d.zip |
[SERVER] Fix create_image() by adding fallback solutions for fallocate()
Diffstat (limited to 'src/server/server.c')
-rw-r--r-- | src/server/server.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/server/server.c b/src/server/server.c index 9b6ff30..12b437b 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -82,7 +82,8 @@ void dnbd3_print_help(char *argv_0) printf( "Management functions:\n" ); printf( "--crc [image-file] Generate crc block list for given image\n" ); printf( "--create [image-name] --revision [rid] --size [filesize]\n" - "\tCreate a local empty image file with a zeroed cache-map for the specified image" ); + "\tCreate a local empty image file with a zeroed cache-map for the specified image\n" ); + printf( "\n" ); exit( 0 ); } @@ -215,13 +216,7 @@ int main(int argc, char *argv[]) opt = getopt_long( argc, argv, optString, longOpts, &longIndex ); } - // One-shots first: - - if ( paramCreate != NULL ) { - return image_create( paramCreate, paramRevision, paramSize ) ? 0 : EXIT_FAILURE; - } - - // No one-shot detected, normal server operation + // Load general config if ( _configDir == NULL ) _configDir = strdup( "/etc/dnbd3-server" ); globals_loadConfig(); @@ -230,6 +225,14 @@ int main(int argc, char *argv[]) exit( EXIT_FAILURE ); } + // One-shots first: + + if ( paramCreate != NULL ) { + return image_create( paramCreate, paramRevision, paramSize ) ? 0 : EXIT_FAILURE; + } + + // No one-shot detected, normal server operation + if ( demonize ) daemon( 1, 0 ); initmemlog(); spin_init( &_clients_lock, PTHREAD_PROCESS_PRIVATE ); |