aboutsummaryrefslogtreecommitdiff
path: root/mpiosh
diff options
context:
space:
mode:
authorgermeier <germeier>2002-09-21 22:17:15 +0000
committergermeier <germeier>2002-09-21 22:17:15 +0000
commitd363f02d3a1aa42dda78f09a7eff46b76ccf6311 (patch)
treed6190b6372b42c32fcb4adebb1a4755f14e03e78 /mpiosh
parentb1694e9b68bf4de24367fdfdad694538e684291f (diff)
downloadmpiosh-d363f02d3a1aa42dda78f09a7eff46b76ccf6311.tar.gz
mpiosh-d363f02d3a1aa42dda78f09a7eff46b76ccf6311.tar.bz2
mpiosh-d363f02d3a1aa42dda78f09a7eff46b76ccf6311.zip
fixed bug in abort code of mput
make output more consistent fixed a few display "bugs"
Diffstat (limited to 'mpiosh')
-rw-r--r--mpiosh/callback.c38
-rw-r--r--mpiosh/mpiosh.c5
-rw-r--r--mpiosh/mpiosh.h3
3 files changed, 31 insertions, 15 deletions
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(&regex, 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, &regex, 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, &regex, errortext, 100);
debugn (2, "file does not match: %s (%s)\n",
@@ -410,6 +413,9 @@ mpiosh_cmd_mput(char *args[])
i++;
}
regfree(&regex);
+ 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(&regex, 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;