static int estimate_cmd(UAContext *ua, char *cmd)
{
- JOB *job;
+ JOB *job = NULL;
+ CLIENT *client = NULL;
+ FILESET *fileset = NULL;
+ int listing = 0;
BSOCK *fd;
- if (ua->argc < 2) {
- return 1;
+
+ for (int i=1; i<ua->argc; i++) {
+ if (strcasecmp(ua->argk[i], _("client")) == 0) {
+ if (ua->argv[i]) {
+ client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
+ continue;
+ }
+ }
+ if (strcasecmp(ua->argk[i], _("job")) == 0) {
+ if (ua->argv[i]) {
+ job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ continue;
+ }
+ }
+ if (strcasecmp(ua->argk[i], _("fileset")) == 0) {
+ if (ua->argv[i]) {
+ fileset = (FILESET *)GetResWithName(R_FILESET, ua->argv[i]);
+ continue;
+ }
+ }
+ if (strcasecmp(ua->argk[i], _("listing")) == 0) {
+ listing = 1;
+ }
+ }
+ if (!job && !(client && fileset)) {
+ if (!(job = select_job_resource(ua))) {
+ return 1;
+ }
+ }
+ if (!job) {
+ job = (JOB *)GetResWithName(R_JOB, ua->argk[1]);
}
- job = (JOB *)GetResWithName(R_JOB, ua->argk[1]);
- ua->jcr->client = job->client;
+ if (!client) {
+ client = job->client;
+ }
+ if (!fileset) {
+ fileset = job->fileset;
+ }
+ ua->jcr->client = client;
+ ua->jcr->fileset = fileset;
bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"),
job->client->hdr.name, job->client->address, job->client->FDport);
if (!connect_to_file_daemon(ua->jcr, 1, 15, 0)) {
bsendmsg(ua, "%s", fd->msg);
}
- bnet_fsend(fd, "estimate list=1\n");
+ bnet_fsend(fd, "estimate listing=%d\n", listing);
while (bnet_recv(fd) >= 0) {
bsendmsg(ua, "%s", fd->msg);
}
static char restorecmd[] = "restore replace=%c where=%s\n";
static char restorecmd1[] = "restore replace=%c where=\n";
static char verifycmd[] = "verify level=%30s\n";
+static char estimatecmd[] = "estimate listing=%d\n";
/* Responses sent to Director */
static char errmsg[] = "2999 Invalid command\n";
Dmsg1(110, "setdebug_cmd: %s", dir->msg);
if (sscanf(dir->msg, "setdebug=%d", &level) != 1 || level < 0) {
- bnet_fsend(dir, "2991 Bad setdebug command: %s\n", dir->msg);
+ pm_strcpy(&jcr->errmsg, dir->msg);
+ bnet_fsend(dir, "2991 Bad setdebug command: %s\n", jcr->errmsg);
return 0;
}
debug_level = level;
BSOCK *dir = jcr->dir_bsock;
char ed2[50];
- jcr->listing = 1;
+ if (sscanf(dir->msg, estimatecmd, &jcr->listing) != 1) {
+ pm_strcpy(&jcr->errmsg, dir->msg);
+ Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s"), jcr->errmsg);
+ bnet_fsend(dir, "2992 Bad estimate command.\n");
+ return 0;
+ }
make_estimate(jcr);
bnet_fsend(dir, OKest, jcr->num_files_examined,
edit_uint64(jcr->JobBytes, ed2));
if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job,
&jcr->VolSessionId, &jcr->VolSessionTime,
sd_auth_key) != 5) {
+ pm_strcpy(&jcr->errmsg, dir->msg);
bnet_fsend(dir, BADjob);
- Jmsg(jcr, M_FATAL, 0, _("Bad Job Command: %s\n"), dir->msg);
+ Jmsg(jcr, M_FATAL, 0, _("Bad Job Command: %s"), jcr->errmsg);
free_pool_memory(sd_auth_key);
return 0;
}
level = get_memory(dir->msglen+1);
Dmsg1(110, "level_cmd: %s", dir->msg);
if (sscanf(dir->msg, "level = %s ", level) != 1) {
- Jmsg1(jcr, M_FATAL, 0, _("Bad level command: %s\n"), dir->msg);
+ pm_strcpy(&jcr->errmsg, dir->msg);
+ Jmsg1(jcr, M_FATAL, 0, _("Bad level command: %s\n"), jcr->errmsg);
free_memory(level);
return 0;
}
if (sscanf(dir->msg, "level = since %d-%d-%d %d:%d:%d mtime_only=%d",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec, &mtime_only) != 7) {
- Jmsg1(jcr, M_FATAL, 0, _("Bad scan of date/time: %s\n"), dir->msg);
+ pm_strcpy(&jcr->errmsg, dir->msg);
+ Jmsg1(jcr, M_FATAL, 0, _("Bad scan of date/time: %s\n"), jcr->errmsg);
free_memory(level);
return 0;
}
&jcr->VolSessionId, &jcr->VolSessionTime,
&jcr->StartFile, &jcr->EndFile,
&jcr->StartBlock, &jcr->EndBlock) != 7) {
- Jmsg(jcr, M_FATAL, 0, "Bad session command: %s", dir->msg);
+ pm_strcpy(&jcr->errmsg, dir->msg);
+ Jmsg(jcr, M_FATAL, 0, "Bad session command: %s", jcr->errmsg);
return 0;
}
Dmsg1(100, "StorageCmd: %s", dir->msg);
if (sscanf(dir->msg, storaddr, &jcr->stored_addr, &stored_port, &enable_ssl) != 3) {
- Jmsg(jcr, M_FATAL, 0, _("Bad storage command: %s"), dir->msg);
+ pm_strcpy(&jcr->errmsg, dir->msg);
+ Jmsg(jcr, M_FATAL, 0, _("Bad storage command: %s"), jcr->errmsg);
return 0;
}
Dmsg3(110, "Open storage: %s:%d ssl=%d\n", jcr->stored_addr, stored_port, enable_ssl);
if (sscanf(dir->msg, restorecmd, &replace, where) != 2) {
if (sscanf(dir->msg, restorecmd1, &replace) != 1) {
- Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), dir->msg);
+ pm_strcpy(&jcr->errmsg, dir->msg);
+ Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), jcr->errmsg);
return 0;
}
*where = 0;