* EXIT-HANDLING (1=GOOD 2=BAD)
* TAR-BLOCKSIZE (default does not add --blocking-factor option,
* using tar's default)
+ * VERBOSE
*/
#include "amanda.h"
dle_t dle;
int argc;
char **argv;
+ int verbose;
} application_argument_t;
enum { CMD_ESTIMATE, CMD_BACKUP };
static char *amgtar_get_incrname(application_argument_t *argument, int level,
FILE *mesgstream, int command);
static GPtrArray *amgtar_build_argv(application_argument_t *argument,
- char *incrname, int command);
+ char *incrname, char **file_exclude,
+ char **file_include, int command);
static char *gnutar_path;
static char *gnutar_listdir;
static char *gnutar_directory;
{"command-options" , 1, NULL, 33},
{"include-list-glob", 1, NULL, 34},
{"exclude-list-glob", 1, NULL, 35},
+ {"verbose" , 1, NULL, 36},
{NULL, 0, NULL, 0}
};
argument.command_options = NULL;
argument.include_list_glob = NULL;
argument.exclude_list_glob = NULL;
+ argument.verbose = 0;
init_dle(&argument.dle);
while (1) {
case 35: if (optarg)
argument.exclude_list_glob = stralloc(optarg);
break;
+ case 36: if (optarg && strcasecmp(optarg, "YES") == 0)
+ argument.verbose = 1;
+ break;
case ':':
case '?':
break;
times_t start_time;
int level;
GSList *levels;
+ char *file_exclude;
+ char *file_include;
if (!argument->level) {
fprintf(stderr, "ERROR No level argument\n");
if (argument->calcsize) {
char *dirname;
- char *file_exclude;
- char *file_include;
int nb_exclude;
int nb_include;
if (gnutar_directory) {
dirname = gnutar_directory;
} else {
- dirname = amname_to_dirname(argument->dle.device);
+ dirname = argument->dle.device;
}
amgtar_build_exinclude(&argument->dle, 1,
&nb_exclude, &file_exclude,
run_calcsize(argument->config, "GNUTAR", argument->dle.disk, dirname,
argument->level, file_exclude, file_include);
+
+ if (argument->verbose == 0) {
+ if (file_exclude)
+ unlink(file_exclude);
+ if (file_include)
+ unlink(file_include);
+ }
return;
}
level = GPOINTER_TO_INT(levels->data);
incrname = amgtar_get_incrname(argument, level, stdout, CMD_ESTIMATE);
cmd = stralloc(gnutar_path);
- argv_ptr = amgtar_build_argv(argument, incrname, CMD_ESTIMATE);
+ argv_ptr = amgtar_build_argv(argument, incrname, &file_exclude,
+ &file_include, CMD_ESTIMATE);
start_time = curclock();
if (incrname) {
unlink(incrname);
}
+
+ if (argument->verbose == 0) {
+ if (file_exclude)
+ unlink(file_exclude);
+ if (file_include)
+ unlink(file_include);
+ }
+
g_ptr_array_free_full(argv_ptr);
amfree(cmd);
amwait_t wait_status;
GPtrArray *argv_ptr;
int tarpid;
+ char *file_exclude;
+ char *file_include;
mesgstream = fdopen(mesgf, "w");
if (!mesgstream) {
GPOINTER_TO_INT(argument->level->data),
mesgstream, CMD_BACKUP);
cmd = stralloc(gnutar_path);
- argv_ptr = amgtar_build_argv(argument, incrname, CMD_BACKUP);
+ argv_ptr = amgtar_build_argv(argument, incrname, &file_exclude,
+ &file_include, CMD_BACKUP);
tarpid = pipespawnv(cmd, STDIN_PIPE|STDERR_PIPE, 1,
&dumpin, &dataf, &outf, (char **)argv_ptr->pdata);
}
}
if(rp->typ == DMP_SIZE) {
- dump_size = (long)((the_num(line, rp->field)* rp->scale+1023.0)/1024.0);
+ dump_size = (off_t)((the_num(line, rp->field)* rp->scale+1023.0)/1024.0);
}
switch(rp->typ) {
case DMP_NORMAL:
fclose(mesgstream);
+ if (argument->verbose == 0) {
+ if (file_exclude)
+ unlink(file_exclude);
+ if (file_include)
+ unlink(file_include);
+ }
+
amfree(incrname);
amfree(qdisk);
amfree(cmd);
char **env;
int j;
char *e;
+ char *include_filename = NULL;
+ char *exclude_filename = NULL;
+ int tarpid;
if (!gnutar_path) {
error(_("GNUTAR-PATH not defined"));
g_ptr_array_add(argv_ptr, stralloc("--selinux"));
if (gnutar_xattrs)
g_ptr_array_add(argv_ptr, stralloc("--xattrs"));
+ /* ignore trailing zero blocks on input (this was the default until tar-1.21) */
+ g_ptr_array_add(argv_ptr, stralloc("--ignore-zeros"));
g_ptr_array_add(argv_ptr, stralloc("-xpGvf"));
g_ptr_array_add(argv_ptr, stralloc("-"));
if (gnutar_directory) {
argument->dle.exclude_list->nb_element == 1) {
FILE *exclude;
char *sdisk;
- char *filename;
int in_argv;
int entry_in_exclude = 0;
char line[2*PATH_MAX];
if (argument->dle.disk) {
sdisk = sanitise_filename(argument->dle.disk);
} else {
- sdisk = g_strdup_printf("installcheck-exclude-%d", getpid());
+ sdisk = g_strdup_printf("no_dle-%d", getpid());
}
- filename = vstralloc(AMANDA_TMPDIR, "/", "exclude-", sdisk, NULL);
+ exclude_filename= vstralloc(AMANDA_TMPDIR, "/", "exclude-", sdisk, NULL);
exclude_list = fopen(argument->dle.exclude_list->first->name, "r");
- exclude = fopen(filename, "w");
+ exclude = fopen(exclude_filename, "w");
while (fgets(line, 2*PATH_MAX, exclude_list)) {
char *escaped;
line[strlen(line)-1] = '\0'; /* remove '\n' */
}
fclose(exclude);
g_ptr_array_add(argv_ptr, stralloc("--exclude-from"));
- g_ptr_array_add(argv_ptr, filename);
+ g_ptr_array_add(argv_ptr, exclude_filename);
}
if (argument->exclude_list_glob) {
GPtrArray *argv_include = g_ptr_array_new();
FILE *include;
char *sdisk;
- char *filename;
int in_argv;
guint i;
int entry_in_include = 0;
if (argument->dle.disk) {
sdisk = sanitise_filename(argument->dle.disk);
} else {
- sdisk = g_strdup_printf("installcheck-include-%d", getpid());
+ sdisk = g_strdup_printf("no_dle-%d", getpid());
}
- filename = vstralloc(AMANDA_TMPDIR, "/", "include-", sdisk, NULL);
- include = fopen(filename, "w");
+ include_filename = vstralloc(AMANDA_TMPDIR, "/", "include-", sdisk, NULL);
+ include = fopen(include_filename, "w");
if (argument->dle.include_list &&
argument->dle.include_list->nb_element == 1) {
char line[2*PATH_MAX];
if (entry_in_include) {
g_ptr_array_add(argv_ptr, stralloc("--files-from"));
- g_ptr_array_add(argv_ptr, filename);
+ g_ptr_array_add(argv_ptr, include_filename);
}
if (argument->include_list_glob) {
g_ptr_array_add(argv_ptr, NULL);
debug_executing(argv_ptr);
- env = safe_env();
- become_root();
- execve(cmd, (char **)argv_ptr->pdata, env);
- e = strerror(errno);
- error(_("error [exec %s: %s]"), cmd, e);
+
+ tarpid = fork();
+ switch (tarpid) {
+ case -1: error(_("%s: fork returned: %s"), get_pname(), strerror(errno));
+ case 0:
+ env = safe_env();
+ become_root();
+ execve(cmd, (char **)argv_ptr->pdata, env);
+ e = strerror(errno);
+ error(_("error [exec %s: %s]"), cmd, e);
+ break;
+ default: break;
+ }
+
+ waitpid(tarpid, NULL, 0);
+ if (argument->verbose == 0) {
+ if (exclude_filename)
+ unlink(exclude_filename);
+ if (include_filename)
+ unlink(include_filename);
+ }
}
static void
cmd = stralloc(gnutar_path);
g_ptr_array_add(argv_ptr, stralloc(gnutar_path));
+ /* ignore trailing zero blocks on input (this was the default until tar-1.21) */
+ g_ptr_array_add(argv_ptr, stralloc("--ignore-zeros"));
g_ptr_array_add(argv_ptr, stralloc("-tf"));
g_ptr_array_add(argv_ptr, stralloc("-"));
g_ptr_array_add(argv_ptr, NULL);
GPtrArray *amgtar_build_argv(
application_argument_t *argument,
- char *incrname,
- int command)
+ char *incrname,
+ char **file_exclude,
+ char **file_include,
+ int command)
{
int nb_exclude;
int nb_include;
- char *file_exclude;
- char *file_include;
char *dirname;
char tmppath[PATH_MAX];
GPtrArray *argv_ptr = g_ptr_array_new();
GSList *copt;
amgtar_build_exinclude(&argument->dle, 1,
- &nb_exclude, &file_exclude,
- &nb_include, &file_include);
+ &nb_exclude, file_exclude,
+ &nb_include, file_include);
if (gnutar_directory) {
dirname = gnutar_directory;
} else {
- dirname = amname_to_dirname(argument->dle.device);
+ dirname = argument->dle.device;
}
g_ptr_array_add(argv_ptr, stralloc(gnutar_path));
g_ptr_array_add(argv_ptr, stralloc((char *)copt->data));
}
- if(file_exclude) {
+ if (*file_exclude) {
g_ptr_array_add(argv_ptr, stralloc("--exclude-from"));
- g_ptr_array_add(argv_ptr, stralloc(file_exclude));
+ g_ptr_array_add(argv_ptr, stralloc(*file_exclude));
}
- if(file_include) {
+ if (*file_include) {
g_ptr_array_add(argv_ptr, stralloc("--files-from"));
- g_ptr_array_add(argv_ptr, stralloc(file_include));
+ g_ptr_array_add(argv_ptr, stralloc(*file_include));
}
else {
g_ptr_array_add(argv_ptr, stralloc("."));