diff options
| -rw-r--r-- | ChangeLog | 10 | ||||
| -rw-r--r-- | libmpio/mpio.c | 4 | ||||
| -rw-r--r-- | mpiosh/callback.c | 38 | ||||
| -rw-r--r-- | mpiosh/mpiosh.c | 5 | ||||
| -rw-r--r-- | mpiosh/mpiosh.h | 3 | 
5 files changed, 43 insertions, 17 deletions
@@ -1,3 +1,13 @@ +2002-09-22  Markus Germeier  <mager@tzi.de> +	* mpiosh/callback.c (mpiosh_cmd_mdel):  +	  fixed logical error in abort handling which corrupted +	  FAT and directory +	  (mpiosh_cmd_mget): call the correct callback function +	  (mpiosh_callback_put): introduced mpiosh_cancel_ack +	  to fix annoying displays in case of an abort +	  (mpiosh_cmd_mput): don't break mput if an FILE_EXITS +	  is encountered +  2002-09-21  Andreas Buesching  <crunchy@tzi.de>  	* mpio.spec.in (CFLAGS): add 'depmod -a' call to post install diff --git a/libmpio/mpio.c b/libmpio/mpio.c index fdfba8b..1bd9f41 100644 --- a/libmpio/mpio.c +++ b/libmpio/mpio.c @@ -1,6 +1,6 @@  /*    * - * $Id: mpio.c,v 1.24 2002/09/20 20:49:36 germeier Exp $ + * $Id: mpio.c,v 1.25 2002/09/21 22:17:15 germeier Exp $   *   * Library for USB MPIO-*   * @@ -388,7 +388,7 @@ mpio_file_get(mpio_t *m, mpio_mem_t mem, BYTE *filename,  	if (progress_callback)  	  abort=(*progress_callback)((fsize-filesize), fsize);  	if (abort) -	  debug("aborting operation\n");	 +	  debug("aborting operation");	        } while ((mpio_fatentry_next_entry(m, mem, f) && (filesize>0)) &&  	       (!abort)); diff --git a/mpiosh/callback.c b/mpiosh/callback.c index 0376989..6f9463c 100644 --- a/mpiosh/callback.c +++ b/mpiosh/callback.c @@ -2,7 +2,7 @@   *   * Author: Andreas Büsching  <crunchy@tzi.de>   * - * $Id: callback.c,v 1.16 2002/09/20 20:49:36 germeier Exp $ + * $Id: callback.c,v 1.17 2002/09/21 22:17:15 germeier Exp $   *   * Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>   * @@ -287,7 +287,7 @@ mpiosh_cmd_mget(char *args[])        debugn (2, "error in regular expression: %s (%s)\n", args[i], errortext);      } else {        p = mpio_directory_open(mpiosh.dev, mpiosh.card); -      while ((p != NULL) ) { +      while (p != NULL) {  	memset(fname, '\0', 100);  	mpio_dentry_get(mpiosh.dev, mpiosh.card, p, fname, 100,  			&year, &month, &day, &hour, &minute, &fsize); @@ -295,16 +295,16 @@ mpiosh_cmd_mget(char *args[])  	if (!(error = regexec(®ex, fname, 0, NULL, 0))) {  	  printf("getting '%s' ... \n", fname);  	  if ((mpio_file_get(mpiosh.dev, mpiosh.card, -				    fname, mpiosh_callback_put)) == -1) { +				    fname, mpiosh_callback_get)) == -1) {  	    debug("cancelled operation\n");  	    mpio_perror("error");  	    break;  	  } +	  printf("\n");  	  if (mpiosh_cancel) {  	    debug("operation cancelled by user\n");  	    break;  	  } -	  printf("\n");  	} else {  	  regerror(error, ®ex, errortext, 100);  	  debugn (2, "file does not match: %s (%s)\n", fname, errortext); @@ -325,6 +325,11 @@ mpiosh_callback_put(int read, int total)    printf("\rwrote %.2f %%", ((double) read / total) * 100.0 );    fflush(stdout); +  if ((mpiosh_cancel) && (!mpiosh_cancel_ack)) { +    debug ("user cancelled operation\n"); +    mpiosh_cancel_ack = 1; +  } +      return mpiosh_cancel; // continue  } @@ -387,16 +392,14 @@ mpiosh_cmd_mput(char *args[])  	    if (mpio_file_put(mpiosh.dev, mpiosh.card,  			      (*run)->d_name, mpiosh_callback_put) == -1) {  	      mpio_perror("error"); +	      /* an existing file is no reason for a complete abort!! */ +	      if (mpio_errno()==MPIO_ERR_FILE_EXISTS) +		continue;  	      break; -	    } -	     -	    if (mpiosh_cancel) { -	      debug("operation cancelled by user\n"); -	      break; -	    } +	    }  +	    written=1; /* we did write something, so do mpio_sync afterwards */  	    printf("\n"); -	    written=1; /* we did write something, so do mpio_sync afterwards */  	  } else {  	    regerror(error, ®ex, errortext, 100);  	    debugn (2, "file does not match: %s (%s)\n",  @@ -410,6 +413,9 @@ mpiosh_cmd_mput(char *args[])      i++;    }    regfree(®ex); +  if (mpiosh_cancel)  +    debug("operation cancelled by user\n"); +    if (written)      mpio_sync(mpiosh.dev, mpiosh.card);  } @@ -420,6 +426,9 @@ mpiosh_callback_del(int read, int total)    printf("\rdeleted %.2f %%", ((double) read / total) * 100.0 );    fflush(stdout); +  if (mpiosh_cancel)  +    debug ("user cancelled operation\n"); +    return mpiosh_cancel; // continue  } @@ -467,12 +476,15 @@ mpiosh_cmd_mdel(char *args[])  			&year, &month, &day, &hour, &minute, &fsize);  	if (!(error = regexec(®ex, fname, 0, NULL, 0))) { +	  /* this line has to be above the del, or we won't write +	   * the FAT and directory in case of an abort!!! +	   */ +	  deleted=1;  	  printf("deleting '%s' ... \n", fname);  	  size = mpio_file_del(mpiosh.dev, mpiosh.card,  			       fname, mpiosh_callback_del); -	  if (mpiosh_cancel) break;  	  printf("\n"); -	  deleted=1; +	  if (mpiosh_cancel) break;  	  /* if we delete a file, start again from the beginning,   	     because the directory has changed !! */  	  p = mpio_directory_open(mpiosh.dev, mpiosh.card); diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c index fa2f75f..f40fd9d 100644 --- a/mpiosh/mpiosh.c +++ b/mpiosh/mpiosh.c @@ -2,7 +2,7 @@  /*    * - * $Id: mpiosh.c,v 1.16 2002/09/19 22:23:01 crunchy Exp $ + * $Id: mpiosh.c,v 1.17 2002/09/21 22:17:15 germeier Exp $   *   * Author: Andreas Büsching  <crunchy@tzi.de>   * @@ -44,6 +44,7 @@ mpiosh_t mpiosh;  /* flag indicating a user-interrupt of the current command */  int mpiosh_cancel = 0; +int mpiosh_cancel_ack = 0;  /* prompt strings */  const char *PROMPT_INT = "\033[;1mmpio <i>\033[m "; @@ -383,6 +384,7 @@ void  mpiosh_signal_handler(int signal)  {    mpiosh_cancel = 1; +  mpiosh_cancel_ack = 0;  }  void @@ -440,6 +442,7 @@ main(int argc, char *argv[]) {      if ((*line == '\0') || mpiosh_cancel) {        rl_clear_pending_input ();        mpiosh_cancel = 0; +      mpiosh_cancel_ack = 0;        continue;      } diff --git a/mpiosh/mpiosh.h b/mpiosh/mpiosh.h index a983293..ba7079b 100644 --- a/mpiosh/mpiosh.h +++ b/mpiosh/mpiosh.h @@ -2,7 +2,7 @@   *   * Author: Andreas Büsching  <crunchy@tzi.de>   * - * $Id: mpiosh.h,v 1.5 2002/09/14 11:19:30 crunchy Exp $ + * $Id: mpiosh.h,v 1.6 2002/09/21 22:17:15 germeier Exp $   *   * Copyright (C) 2002 Andreas Büsching <crunchy@tzi.de>   * @@ -60,6 +60,7 @@ void mpiosh_command_free_args(char **args);  extern mpiosh_t mpiosh;  extern mpiosh_cmd_t commands[];  extern int mpiosh_cancel; +extern int mpiosh_cancel_ack;  extern const char *PROMPT_INT;  extern const char *PROMPT_EXT;  | 
