From c6c22c4fadb3000453389f3ecf471392674adfd1 Mon Sep 17 00:00:00 2001 From: crunchy Date: Fri, 27 Jun 2003 12:21:21 +0000 Subject: add backup and restore commands; little bug fix and clean up. Need to be tested! Just give me 5 minutes, please! --- mpiosh/callback.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) (limited to 'mpiosh/callback.c') diff --git a/mpiosh/callback.c b/mpiosh/callback.c index 70c2e5a..daf99a0 100644 --- a/mpiosh/callback.c +++ b/mpiosh/callback.c @@ -2,7 +2,7 @@ * * Author: Andreas Büsching * - * $Id: callback.c,v 1.42 2003/06/26 19:53:58 germeier Exp $ + * $Id: callback.c,v 1.43 2003/06/27 12:21:21 crunchy Exp $ * * Copyright (C) 2001 Andreas Büsching * @@ -833,6 +833,96 @@ mpiosh_cmd_health(char *args[]) } +void +mpiosh_cmd_backup(char *args[]) +{ + int size; + char filename[ 1024 ]; + + UNUSED(args); + + MPIOSH_CHECK_CONNECTION_CLOSED; + + if ( !mpiosh_config_check_backup_dir( mpiosh.config, TRUE ) ) { + fprintf( stderr, "error: could not create backup directory: %s\n", + CONFIG_BACKUP ); + return; + } + + snprintf( filename, 1024, "%s%s", CONFIG_BACKUP, MPIO_CONFIG_FILE ); + size = mpio_file_get_as( mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CONFIG_FILE, + filename, + mpiosh_callback_get ); + if ( size == -1 ) return; + if ( !size ) + debugn (1, "file does not exist: %s\n", MPIO_CONFIG_FILE ); + + snprintf( filename, 1024, "%s%s", CONFIG_BACKUP, MPIO_CHANNEL_FILE ); + size = mpio_file_get_as( mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CHANNEL_FILE, + filename, + mpiosh_callback_get ); + if ( size == -1 ) return; + if ( !size ) + debugn (2, "file does not exist: %s\n", MPIO_CHANNEL_FILE ); + + snprintf( filename, 1024, "%s%s", CONFIG_BACKUP, MPIO_FONT_FON ); + size = mpio_file_get_as( mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_FONT_FON, + filename, + mpiosh_callback_get ); + if ( size == -1 ) return; + if ( !size ) + debugn (2, "file does not exist: %s\n", MPIO_FONT_FON ); +} + +void +mpiosh_cmd_restore(char *args[]) +{ + int size; + char filename[ 1024 ]; + + UNUSED(args); + + MPIOSH_CHECK_CONNECTION_CLOSED; + + if ( !mpiosh_config_check_backup_dir( mpiosh.config, FALSE ) ) { + fprintf( stderr, "error: there is no backup: %s\n", + CONFIG_BACKUP ); + return; + } + + snprintf( filename, 1024, "%s%s", CONFIG_BACKUP, MPIO_CONFIG_FILE ); + size = mpio_file_put_as( mpiosh.dev, MPIO_INTERNAL_MEM, + filename, + MPIO_CONFIG_FILE, + FTYPE_CONF, mpiosh_callback_put ); + if ( size == -1 ) return; + if ( !size ) + debugn (1, "file does not exist: %s\n", MPIO_CONFIG_FILE ); + + snprintf( filename, 1024, "%s%s", CONFIG_BACKUP, MPIO_CHANNEL_FILE ); + size = mpio_file_put_as( mpiosh.dev, MPIO_INTERNAL_MEM, + filename, + MPIO_CHANNEL_FILE, + FTYPE_CHAN, mpiosh_callback_put ); + if ( size == -1 ) return; + if ( !size ) + debugn (2, "file does not exist: %s\n", MPIO_CHANNEL_FILE ); + + snprintf( filename, 1024, "%s%s", CONFIG_BACKUP, MPIO_FONT_FON ); + size = mpio_file_put_as( mpiosh.dev, MPIO_INTERNAL_MEM, + filename, + MPIO_FONT_FON, + FTYPE_FONT, mpiosh_callback_put ); + if ( size == -1 ) return; + if ( !size ) + debugn (2, "file does not exist: %s\n", MPIO_FONT_FON ); +} + + +#if 0 void mpiosh_cmd_config(char *args[]) { @@ -906,6 +996,7 @@ mpiosh_cmd_config(char *args[]) printf("config [read|write|show] <\n"); } } +#endif void mpiosh_cmd_channel(char *args[]) -- cgit v1.2.3