#include "diskfile.h"
#include "infofile.h"
#include "logfile.h"
-#include "token.h"
+#include "timestamp.h"
#define GLOBAL /* the global variables defined here */
#include "driverio.h"
error(_("taper dup2: %s"), strerror(errno));
config_options = get_config_options(2);
config_options[0] = "taper";
- config_options[1] = config_name;
+ config_options[1] = get_config_name();
safe_fd(-1, 0);
execve(taper_program, config_options, safe_env());
error("exec %s: %s", taper_program, strerror(errno));
error(_("%s dup2: %s"), dumper->name, strerror(errno));
config_options = get_config_options(2);
config_options[0] = dumper->name ? dumper->name : "dumper",
- config_options[1] = config_name;
+ config_options[1] = get_config_name();
safe_fd(-1, 0);
execve(dumper_program, config_options, safe_env());
error(_("exec %s (%s): %s"), dumper_program,
chktable[i].fd = -1;
startup_dump_process(dumper, dumper_program);
- dumper_cmd(dumper, START, (void *)timestamp);
+ dumper_cmd(dumper, START, NULL, (void *)timestamp);
}
}
}
config_options = get_config_options(2);
config_options[0] = chunker->name ? chunker->name : "chunker",
- config_options[1] = config_name;
+ config_options[1] = get_config_name();
safe_fd(-1, 0);
execve(chunker_program, config_options, safe_env());
error(_("exec %s (%s): %s"), chunker_program,
int fd,
int show,
int *result_argc,
- char **result_argv,
- int max_arg)
+ char ***result_argv)
{
- int arg;
cmd_t t;
char *line;
error(_("reading result from %s: %s"), childstr(fd), strerror(errno));
/*NOTREACHED*/
}
+ *result_argv = NULL;
*result_argc = 0; /* EOF */
} else {
- *result_argc = split(line, result_argv, max_arg, " ");
+ *result_argv = split_quoted_strings(line);
+ *result_argc = g_strv_length(*result_argv);
}
if(show) {
walltime_str(curclock()),
childstr(fd));
if(line) {
- for(arg = 1; arg <= *result_argc; arg++) {
- g_printf(" %s", result_argv[arg]);
- }
+ g_printf(" %s", line);
putchar('\n');
} else {
g_printf(" (eof)\n");
}
amfree(line);
-#ifdef DEBUG
- g_printf("argc = %d\n", *result_argc);
- for(arg = 0; arg < *result_argc; arg++)
- g_printf("argv[%d] = \"%s\"\n", arg, result_argv[arg]);
-#endif
-
if(*result_argc < 1) return BOGUS;
for(t = (cmd_t)(BOGUS+1); t < LAST_TOK; t++)
- if(strcmp(result_argv[1], cmdstr[t]) == 0) return t;
+ if(strcmp((*result_argv)[0], cmdstr[t]) == 0) return t;
return BOGUS;
}
char number[NUM_STR_SIZE];
char splitsize[NUM_STR_SIZE];
char fallback_splitsize[NUM_STR_SIZE];
+ char orig_kb[NUM_STR_SIZE];
char *diskbuffer = NULL;
disk_t *dp;
char *qname;
char *qdest;
+ char *q;
switch(cmd) {
case START_TAPER:
g_snprintf(number, SIZEOF(number), "%d", level);
g_snprintf(splitsize, SIZEOF(splitsize), "%lld",
(long long)dp->tape_splitsize * 1024);
+ g_snprintf(orig_kb, SIZEOF(orig_kb), "%jd",
+ (intmax_t)sched(dp)->origsize);
cmdline = vstralloc(cmdstr[cmd],
" ", disk2serial(dp),
" ", qdest,
" ", number,
" ", datestamp,
" ", splitsize,
+ " ", orig_kb,
"\n", NULL);
amfree(qdest);
amfree(qname);
amfree(qname);
break;
case DONE: /* handle */
+ dp = (disk_t *) ptr;
+ g_snprintf(number, SIZEOF(number), "%jd",
+ (intmax_t)(sched(dp)->origsize));
+ cmdline = vstralloc(cmdstr[cmd],
+ " ", disk2serial(dp),
+ " ", number,
+ "\n", NULL);
+ break;
case FAILED: /* handle */
dp = (disk_t *) ptr;
cmdline = vstralloc(cmdstr[cmd],
" ", disk2serial(dp),
"\n", NULL);
break;
- case NEW_TAPE:
case NO_NEW_TAPE:
+ q = quote_string((char *)ptr);
+ cmdline = vstralloc(cmdstr[cmd],
+ " ", q,
+ "\n", NULL);
+ amfree(q);
+ break;
+ case NEW_TAPE:
case QUIT:
cmdline = stralloc2(cmdstr[cmd], "\n");
break;
g_printf(_("driver: send-cmd time %s to taper: %s"),
walltime_str(curclock()), cmdline);
fflush(stdout);
- if ((fullwrite(taper, cmdline, strlen(cmdline))) < 0) {
+ if ((full_write(taper, cmdline, strlen(cmdline))) < strlen(cmdline)) {
g_printf(_("writing taper command '%s' failed: %s\n"),
cmdline, strerror(errno));
fflush(stdout);
dumper_cmd(
dumper_t *dumper,
cmd_t cmd,
- disk_t *dp)
+ disk_t *dp,
+ char *mesg)
{
char *cmdline = NULL;
char number[NUM_STR_SIZE];
char *device;
char *features;
char *qname;
- char *qdest;
+ char *qmesg;
switch(cmd) {
case START:
- cmdline = vstralloc(cmdstr[cmd], " ", (char *)dp, "\n", NULL);
+ cmdline = vstralloc(cmdstr[cmd], " ", mesg, "\n", NULL);
break;
case PORT_DUMP:
if(dp && dp->device) {
}
if (dp != NULL) {
+ application_t *application = NULL;
+ char *plugin;
+ char *qplugin;
+ char *qamandad_path;
+ char *qclient_username;
+ char *qclient_port;
+ char *qssh_keys;
+
+ if (dp->application != NULL) {
+ application = lookup_application(dp->application);
+ g_assert(application != NULL);
+ }
+
device = quote_string((dp->device) ? dp->device : "NODEVICE");
qname = quote_string(dp->name);
g_snprintf(number, SIZEOF(number), "%d", sched(dp)->level);
g_snprintf(numberport, SIZEOF(numberport), "%d", dumper->output_port);
features = am_feature_to_string(dp->host->features);
- o = optionstr(dp, dp->host->features, NULL);
- if ( o == NULL ) {
- error(_("problem with option string, check the dumptype definition.\n"));
+ if (am_has_feature(dp->host->features, fe_req_xml)) {
+ o = xml_optionstr(dp, 1);
+ if (application) {
+ char *xml_app;
+ xml_app = xml_application(dp, application,
+ dp->host->features);
+ vstrextend(&o, xml_app, NULL);
+ amfree(xml_app);
+ }
+ o = quote_string(o);
+ } else {
+ o = optionstr(dp);
}
-
+
+ g_assert(dp->program);
+ if (0 == strcmp(dp->program, "APPLICATION")) {
+ g_assert(application != NULL);
+ plugin = application_get_plugin(application);
+ } else {
+ plugin = dp->program;
+ }
+ qplugin = quote_string(plugin);
+ qamandad_path = quote_string(dp->amandad_path);
+ qclient_username = quote_string(dp->client_username);
+ qclient_port = quote_string(dp->client_port);
+ qssh_keys = quote_string(dp->ssh_keys);
+ dbprintf("security_driver %s\n", dp->auth);
+
cmdline = vstralloc(cmdstr[cmd],
" ", disk2serial(dp),
" ", numberport,
" ", device,
" ", number,
" ", sched(dp)->dumpdate,
- " ", dp->program,
- " ", dp->amandad_path,
- " ", dp->client_username,
- " ", dp->ssh_keys,
+ " ", qplugin,
+ " ", qamandad_path,
+ " ", qclient_username,
+ " ", qclient_port,
+ " ", qssh_keys,
+ " ", dp->auth,
+ " ", data_path_to_string(dp->data_path),
+ " ", dp->dataport_list,
" |", o,
"\n", NULL);
+ amfree(qplugin);
+ amfree(qamandad_path);
+ amfree(qclient_username);
+ amfree(qclient_port);
+ amfree(qssh_keys);
amfree(features);
amfree(o);
amfree(qname);
break;
case QUIT:
case ABORT:
- if( dp ) {
- qdest = quote_string(sched(dp)->destname);
- cmdline = vstralloc(cmdstr[cmd],
- " ", qdest,
- "\n", NULL );
- amfree(qdest);
- } else {
- cmdline = stralloc2(cmdstr[cmd], "\n");
- }
+ qmesg = quote_string(mesg);
+ cmdline = vstralloc(cmdstr[cmd], " ", qmesg, "\n", NULL );
+ amfree(qmesg);
break;
default:
error(_("Don't know how to send %s command to dumper"), cmdstr[cmd]);
g_printf(_("driver: send-cmd time %s to %s: %s"),
walltime_str(curclock()), dumper->name, cmdline);
fflush(stdout);
- if (fullwrite(dumper->fd, cmdline, strlen(cmdline)) < 0) {
+ if (full_write(dumper->fd, cmdline, strlen(cmdline)) < strlen(cmdline)) {
g_printf(_("writing %s command: %s\n"), dumper->name, strerror(errno));
fflush(stdout);
amfree(cmdline);
chunker_cmd(
chunker_t *chunker,
cmd_t cmd,
- disk_t *dp)
+ disk_t *dp,
+ char *mesg)
{
char *cmdline = NULL;
char number[NUM_STR_SIZE];
switch(cmd) {
case START:
- cmdline = vstralloc(cmdstr[cmd], " ", (char *)dp, "\n", NULL);
+ cmdline = vstralloc(cmdstr[cmd], " ", mesg, "\n", NULL);
break;
case PORT_WRITE:
if(dp && sched(dp) && sched(dp)->holdp) {
g_snprintf(use, SIZEOF(use), "%lld",
(long long)h[0]->reserved);
features = am_feature_to_string(dp->host->features);
- o = optionstr(dp, dp->host->features, NULL);
- if ( o == NULL ) {
- error(_("problem with option string, check the dumptype definition.\n"));
- }
+ o = optionstr(dp);
cmdline = vstralloc(cmdstr[cmd],
" ", disk2serial(dp),
" ", qdest,
break;
case QUIT:
case ABORT:
- cmdline = stralloc2(cmdstr[cmd], "\n");
+ {
+ char *q = quote_string(mesg);
+ cmdline = vstralloc(cmdstr[cmd], " ", q, "\n", NULL);
+ amfree(q);
+ }
break;
case DONE:
case FAILED:
g_printf(_("driver: send-cmd time %s to %s: %s"),
walltime_str(curclock()), chunker->name, cmdline);
fflush(stdout);
- if (fullwrite(chunker->fd, cmdline, strlen(cmdline)) < 0) {
+ if (full_write(chunker->fd, cmdline, strlen(cmdline)) < strlen(cmdline)) {
g_printf(_("writing %s command: %s\n"), chunker->name, strerror(errno));
fflush(stdout);
amfree(cmdline);
infp->size = origsize;
infp->csize = dumpsize;
infp->secs = dumptime;
- infp->date = sched(dp)->timestamp;
+ infp->date = get_time_from_timestamp(sched(dp)->datestamp);
if(level == 0) perfp = &info.full;
else perfp = &info.incr;
newperf(perfp->rate, (double)dumpsize/(double)dumptime);
}
- if(getconf_int(CNF_RESERVE)<100) {
+ if(origsize >= (off_t)0 && getconf_int(CNF_RESERVE)<100) {
info.command = NO_COMMAND;
}
- if(level == info.last_level)
+ if (origsize >= (off_t)0 && level == info.last_level) {
info.consecutive_runs++;
- else {
+ } else if (origsize >= (off_t)0 || level < info.last_level) {
info.last_level = level;
info.consecutive_runs = 1;
}
info.history[0].level = level;
info.history[0].size = origsize;
info.history[0].csize = dumpsize;
- info.history[0].date = sched(dp)->timestamp;
+ info.history[0].date = get_time_from_timestamp(sched(dp)->datestamp);
info.history[0].secs = dumptime;
}
- if(put_info(dp->host->hostname, dp->name, &info)) {
- error(_("infofile update failed (%s,'%s')\n"), dp->host->hostname, dp->name);
+ if (put_info(dp->host->hostname, dp->name, &info)) {
+ int save_errno = errno;
+ g_fprintf(stderr, _("infofile update failed (%s,'%s'): %s\n"),
+ dp->host->hostname, dp->name, strerror(save_errno));
+ log_add(L_ERROR, _("infofile update failed (%s,'%s'): %s\n"),
+ dp->host->hostname, dp->name, strerror(save_errno));
+ error(_("infofile update failed (%s,'%s'): %s\n"),
+ dp->host->hostname, dp->name, strerror(save_errno));
/*NOTREACHED*/
}
info.command = NO_COMMAND;
- if(put_info(dp->host->hostname, dp->name, &info)) {
- error(_("infofile update failed (%s,'%s')\n"), dp->host->hostname, dp->name);
+ if (put_info(dp->host->hostname, dp->name, &info)) {
+ int save_errno = errno;
+ g_fprintf(stderr, _("infofile update failed (%s,'%s'): %s\n"),
+ dp->host->hostname, dp->name, strerror(save_errno));
+ log_add(L_ERROR, _("infofile update failed (%s,'%s'): %s\n"),
+ dp->host->hostname, dp->name, strerror(save_errno));
+ error(_("infofile update failed (%s,'%s'): %s\n"),
+ dp->host->hostname, dp->name, strerror(save_errno));
/*NOTREACHED*/
}
close_infofile();