diff --git a/ChangeLog b/ChangeLog index 1c8bb08f..9c72caa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4767,6 +4767,7 @@ v0.33.20 10-Feb-2002 The hatch and magic processors now scan the filenames to test using the regexp library, this should be more reliable. Increased the size of the buffer for filesort. + Improved error reporting when file copy fails. mbmsg: When creating non-existend message bases, the path is created @@ -4801,6 +4802,7 @@ v0.33.20 10-Feb-2002 mbdiff: Removed nonsense error message when stopped on a signal. + Improved error reporting when copy fails. mbindex: Removed nonsense error message when stopped on a signal. diff --git a/mbfido/addbbs.c b/mbfido/addbbs.c index c2ee7998..ac73f42f 100644 --- a/mbfido/addbbs.c +++ b/mbfido/addbbs.c @@ -53,7 +53,7 @@ extern int tic_imp; int Add_BBS() { struct FILERecord frec; - int i, Insert, Done = FALSE, Found = FALSE; + int rc, i, Insert, Done = FALSE, Found = FALSE; char fdbname[PATH_MAX], fdbtemp[PATH_MAX]; char temp1[PATH_MAX], temp2[PATH_MAX], *fname; FILE *fdb, *fdt; @@ -87,8 +87,8 @@ int Add_BBS() sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName); mkdirs(temp2, 0755); - if (file_cp(temp1, temp2) != 0) { - WriteError("$Copy to %s failed", temp2); + if ((rc = file_cp(temp1, temp2))) { + WriteError("Copy to %s failed: %s", temp2, strerror(rc)); return FALSE; } chmod(temp2, 0644); diff --git a/mbfido/magic.c b/mbfido/magic.c index bbfeabe6..43daf710 100644 --- a/mbfido/magic.c +++ b/mbfido/magic.c @@ -269,7 +269,7 @@ void Magic_ExecCommand(void) void Magic_CopyFile(void) { - int First = TRUE; + int First = TRUE, rc; char *From, *To; From = calloc(PATH_MAX, sizeof(char)); @@ -280,11 +280,11 @@ void Magic_CopyFile(void) sprintf(From, "%s/%s", TIC.BBSpath, TIC.NewName); sprintf(To, "%s/%s", magic.Path, TIC.NewName); - if (file_cp(From, To) == 0) { + if ((rc = file_cp(From, To) == 0)) { MagicResult((char *)"%s copied to %s", From, To); Magic_CheckCompile(); } else - WriteError("Magic: copy: %s to %s failed"); + WriteError("Magic: copy: %s to %s failed, %s", strerror(rc)); } free(From); @@ -295,10 +295,10 @@ void Magic_CopyFile(void) void Magic_UnpackFile(void) { - int rc, First = TRUE; - char *buf = NULL, *unarc = NULL, *cmd = NULL; - char Fn[PATH_MAX]; + int rc, First = TRUE; + char *Fn, *buf = NULL, *unarc = NULL, *cmd = NULL; + Fn = calloc(PATH_MAX, sizeof(char)); while (GetMagicRec(MG_UNPACK, First)) { First = FALSE; buf = calloc(PATH_MAX, sizeof(char)); @@ -328,6 +328,7 @@ void Magic_UnpackFile(void) free(buf); } + free(Fn); } diff --git a/mbfido/mbdiff.c b/mbfido/mbdiff.c index e6c385ed..784264ac 100644 --- a/mbfido/mbdiff.c +++ b/mbfido/mbdiff.c @@ -334,12 +334,12 @@ int main(int argc, char **argv) die(100); } } else { - if (file_cp(nd, ond)) { + if ((rc = file_cp(nd, ond))) { show_log = TRUE; free(ond); free(onl); free(wrk); - WriteError("$Copy %s failed", nd); + WriteError("Copy %s failed, %s", nd, strerror(rc)); die(100); } Syslog('s', "Copied %s", nd); diff --git a/mbfido/mbfadopt.c b/mbfido/mbfadopt.c index d34b5169..ad19de42 100644 --- a/mbfido/mbfadopt.c +++ b/mbfido/mbfadopt.c @@ -84,7 +84,7 @@ void AdoptFile(int Area, char *File, char *Description) sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File); mkdirs(temp2, 0755); if ((rc = file_cp(temp, temp2))) { - WriteError("Can't copy file to %s", temp2); + WriteError("Can't copy file to %s, %s", temp2, strerror(rc)); if (!do_quiet) printf("Can't copy file to %s, %s\n", temp2, strerror(rc)); die(0); diff --git a/mbfido/mbfimport.c b/mbfido/mbfimport.c index 51943a54..cfdb13ce 100644 --- a/mbfido/mbfimport.c +++ b/mbfido/mbfimport.c @@ -105,7 +105,7 @@ void ImportFiles(int Area) sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName); mkdirs(temp2, 0755); if ((rc = file_cp(temp, temp2))) { - WriteError("Can't copy file to %s", temp2); + WriteError("Can't copy file to %s, %s", temp2, strerror(rc)); if (!do_quiet) printf("Can't copy file to %s, %s\n", temp2, strerror(rc)); Doit = FALSE; @@ -305,8 +305,8 @@ void ImportFiles(int Area) Syslog('+', "Unknown archive format %s", temp); sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName); mkdirs(temp2, 0755); - if (file_cp(temp, temp2)) { - WriteError("Can't copy file to %s", temp2); + if ((rc = file_cp(temp, temp2))) { + WriteError("Can't copy file to %s, %s", temp2, strerror(rc)); Doit = FALSE; } else { if (!do_quiet) { diff --git a/mbfido/mbfkill.c b/mbfido/mbfkill.c index f0ab186e..d227753b 100644 --- a/mbfido/mbfkill.c +++ b/mbfido/mbfkill.c @@ -188,8 +188,8 @@ void Kill(void) fwrite(&file, sizeof(file), 1, pFile); iMoved++; } else { - WriteError("Move %s to area %d failed rc = %d", - file.Name, area.MoveArea, rc); + WriteError("Move %s to area %d failed, %s", + file.Name, area.MoveArea, strerror(rc)); } } else { Syslog('+', "Delete %s, area %d", file.LName, i); diff --git a/mbfido/mover.c b/mbfido/mover.c index c3c1f18a..4560bec9 100644 --- a/mbfido/mover.c +++ b/mbfido/mover.c @@ -42,6 +42,7 @@ void mover(char *fn) { char *From, *To; + int rc; From = calloc(PATH_MAX, sizeof(char)); To = calloc(PATH_MAX, sizeof(char)); @@ -51,8 +52,10 @@ void mover(char *fn) Syslog('!', "Moving %s to %s", From, To); if (mkdirs(To, 0770)) { - if (file_mv(From, To) != 0) - WriteError("$Failed to move %s to %s", From, To); + if ((rc = file_mv(From, To))) + WriteError("$Failed to move %s to %s: %s", From, To, strerror(rc)); + } else { + WriteError("$Can't create directory for %s", To); } free(From); diff --git a/mbfido/ptic.c b/mbfido/ptic.c index bdee65e7..5852de36 100644 --- a/mbfido/ptic.c +++ b/mbfido/ptic.c @@ -75,7 +75,7 @@ int ProcessTic(fa_list *sbl) int DownLinks = 0; int MustRearc = FALSE; int UnPacked = FALSE, IsArchive = FALSE; - int i, j, k, File_Id = FALSE; + int rc, i, j, k, File_Id = FALSE; char *Temp, *unarc = NULL, *cmd = NULL; char temp1[PATH_MAX], temp2[PATH_MAX], sbe[24], TDesc[256]; unsigned long crc, crc2, Kb; @@ -235,7 +235,7 @@ int ProcessTic(fa_list *sbl) Magic_Keepnum(); if (!tic.FileArea) { - Syslog('f', "Passthru area!"); + Syslog('+', "Passthru TIC area!"); strcpy(TIC.BBSpath, CFG.ticout); strcpy(TIC.BBSdesc, tic.Comment); } else { @@ -276,7 +276,7 @@ int ProcessTic(fa_list *sbl) * the area is not linked to an existing BBS area. */ if (tic.FileArea && access(TIC.BBSpath, W_OK)) { - WriteError("$No write access to \"%s\"", TIC.BBSpath); + WriteError("No write access to \"%s\"", TIC.BBSpath); Bad((char *)"Dest directory not available"); free(Temp); return 1; @@ -406,10 +406,10 @@ int ProcessTic(fa_list *sbl) if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) { sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName); sprintf(temp2, "%s/%s", CFG.ticout, TIC.RealName); - if (file_cp(temp1, temp2) == 0) { + if ((rc = file_cp(temp1, temp2) == 0)) { TIC.SendOrg = TRUE; } else { - WriteError("$Copy %s to %s failed", temp1, temp2); + WriteError("Copy %s to %s failed: %s", temp1, temp2, strerror(rc)); } } @@ -492,12 +492,10 @@ int ProcessTic(fa_list *sbl) sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName); sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.RealName); - if (file_cp(temp1, temp2)) { - WriteError("Can't copy %s to %s", temp1, temp2); + if ((rc = file_cp(temp1, temp2))) { + WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc)); free(Temp); return 1; - } else { - Syslog('f', "file_cp(%s, %s) ok", temp1, temp2); } sprintf(temp2, "%s/tmp/arc", getenv("MBSE_ROOT")); @@ -704,7 +702,9 @@ int ProcessTic(fa_list *sbl) strncpy(T_File.LDesc[i], TIC.File_Id[i], 48); T_File.TotLdesc = TIC.File_Id_Ct; T_File.Announce = tic.Announce; - strncpy(T_File.Name, TIC.NewName, 12); + sprintf(Temp, "%s", TIC.NewName); + name_mangle(Temp); + strncpy(T_File.Name, Temp, 12); strncpy(T_File.LName, TIC.NewName, 80); T_File.Fdate = TIC.FileDate; T_File.Cost = TIC.TicIn.Cost; @@ -772,15 +772,11 @@ int ProcessTic(fa_list *sbl) Magic_CopyFile(); Magic_UnpackFile(); Magic_AdoptFile(); - Syslog('f', "Almost at end of ptic"); sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName); - Syslog('f', "About to erase \"%s\"", Temp); unlink(Temp); - Syslog('f', "Done, about to free Temp"); free(Temp); - Syslog('f', "Done with ptic"); return 0; } diff --git a/mbfido/tic.c b/mbfido/tic.c index ec312db9..dbda1e34 100644 --- a/mbfido/tic.c +++ b/mbfido/tic.c @@ -400,8 +400,8 @@ int LoadTic(char *inb, char *tfn) return 2; } sprintf(Temp2, "%s/%s", TIC.Inbound, TIC.TicIn.FullName); - if (file_mv(Temp, Temp2)) { - WriteError("Can't move %s to inbound", Temp); + if ((rc = file_mv(Temp, Temp2))) { + WriteError("Can't move %s to inbound: %s", Temp, strerror(rc)); tidy_falist(&sbl); return 1; }