Fixed creation of tmpwork directory

This commit is contained in:
Michiel Broek 2005-12-04 11:46:07 +00:00
parent 21592bcc89
commit 99091e9542
3 changed files with 27 additions and 13 deletions

View File

@ -2,6 +2,13 @@ $Id$
v0.83.3 03-Dec-2005 v0.83.3 03-Dec-2005
libmbse.a:
Fixed new tmpwork functions.
mbfido:
Fixed creation of tmpwork directory.
v0.83.2 16-Nov-2005 - 03-Dec-2005 v0.83.2 16-Nov-2005 - 03-Dec-2005
libmbse.a: libmbse.a:

View File

@ -45,11 +45,11 @@ void clean_tmpwork(void)
arc = calloc(PATH_MAX, sizeof(char)); arc = calloc(PATH_MAX, sizeof(char));
getcwd(buf, PATH_MAX); getcwd(buf, PATH_MAX);
snprintf(temp, PATH_MAX, "%s/tmp", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/tmp", getenv("MBSE_ROOT"));
snprintf(arc, PATH_MAX, "arc%d", (int)getpid()); snprintf(arc, PATH_MAX, "-r -f arc%d", (int)getpid());
if (chdir(temp) == 0) { if (chdir(temp) == 0) {
Syslog('f', "clean_tmpwork %s/%s", temp, arc); Syslog('f', "clean_tmpwork %s/arc%d", temp, (int)getpid());
execute_pth((char *)"rm -r -f", arc, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"); execute_pth((char *)"rm", arc, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
} else { } else {
WriteError("$Can't chdir to %s", temp); WriteError("$Can't chdir to %s", temp);
} }
@ -70,8 +70,7 @@ int create_tmpwork(void)
if (! is_tmpwork) { if (! is_tmpwork) {
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
getcwd(buf, PATH_MAX); snprintf(temp, PATH_MAX, "%s/tmp/arc%d/foobar", getenv("MBSE_ROOT"), (int)getpid());
snprintf(temp, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
if (! mkdirs(temp, 0755)) if (! mkdirs(temp, 0755))
rc = 1; rc = 1;

View File

@ -340,6 +340,15 @@ int ProcessTic(fa_list **sbl, orphans **opl)
* is used for this file. * is used for this file.
*/ */
if (strlen(tic.Convert) || tic.VirScan || tic.FileId || tic.ConvertAll || strlen(tic.Banner)) { if (strlen(tic.Convert) || tic.VirScan || tic.FileId || tic.ConvertAll || strlen(tic.Banner)) {
/*
* Create tmp workdir
*/
if (create_tmpwork()) {
free(Temp);
tidy_qualify(&qal);
return 1;
}
if ((unarc = unpacker(TIC.TicIn.File)) == NULL) if ((unarc = unpacker(TIC.TicIn.File)) == NULL)
Syslog('+', "Unknown archive format %s", TIC.TicIn.File); Syslog('+', "Unknown archive format %s", TIC.TicIn.File);
else { else {
@ -366,15 +375,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
if ((tic.VirScan || MustRearc) && IsArchive) { if ((tic.VirScan || MustRearc) && IsArchive) {
/*
* Create a temp directory for the archive conversion.
*/
snprintf(temp2, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid()); snprintf(temp2, PATH_MAX, "%s/tmp/arc%d", getenv("MBSE_ROOT"), (int)getpid());
if (create_tmpwork) {
free(Temp);
tidy_qualify(&qal);
return 1;
}
/* /*
* Check for stale FILE_ID.DIZ files * Check for stale FILE_ID.DIZ files
@ -396,6 +397,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
Bad((char *)"Not enough free diskspace left"); Bad((char *)"Not enough free diskspace left");
free(Temp); free(Temp);
tidy_qualify(&qal); tidy_qualify(&qal);
clean_tmpwork();
return 1; return 1;
} }
@ -403,6 +405,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
WriteError("$Can't change to %s", temp2); WriteError("$Can't change to %s", temp2);
free(Temp); free(Temp);
tidy_qualify(&qal); tidy_qualify(&qal);
clean_tmpwork();
return 1; return 1;
} }
@ -411,6 +414,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
chdir(TIC.Inbound); chdir(TIC.Inbound);
free(Temp); free(Temp);
tidy_qualify(&qal); tidy_qualify(&qal);
clean_tmpwork();
return 1; return 1;
} }
@ -446,6 +450,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc)); WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc));
free(Temp); free(Temp);
tidy_qualify(&qal); tidy_qualify(&qal);
clean_tmpwork();
return 1; return 1;
} }
@ -454,6 +459,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
WriteError("$Can't change to %s", temp2); WriteError("$Can't change to %s", temp2);
free(Temp); free(Temp);
tidy_qualify(&qal); tidy_qualify(&qal);
clean_tmpwork();
return 1; return 1;
} }
} }
@ -471,6 +477,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
Bad((char *)"Possible virus found!"); Bad((char *)"Possible virus found!");
free(Temp); free(Temp);
tidy_qualify(&qal); tidy_qualify(&qal);
clean_tmpwork();
return 1; return 1;
} }
@ -662,6 +669,7 @@ int ProcessTic(fa_list **sbl, orphans **opl)
Bad((char *)"File Import Error"); Bad((char *)"File Import Error");
free(Temp); free(Temp);
tidy_qualify(&qal); tidy_qualify(&qal);
clean_tmpwork();
return 1; return 1;
} }
} }