From: Kern Sibbald Date: Sat, 21 Jun 2003 18:11:07 +0000 (+0000) Subject: Finish estimate command X-Git-Tag: Release-1.31~54 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f29851fb54cd09b109dae913486073d26c047eae;p=bacula%2Fbacula Finish estimate command git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@602 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 7230bf311f..9d958763c7 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1179,13 +1179,51 @@ static int var_cmd(UAContext *ua, char *cmd) 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; iargc; 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)) { @@ -1209,7 +1247,7 @@ static int estimate_cmd(UAContext *ua, char *cmd) 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); } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 6ffa1d7336..da51fed3b9 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -93,6 +93,7 @@ static char sessioncmd[] = "session %127s %ld %ld %ld %ld %ld %ld\n"; 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"; @@ -272,7 +273,8 @@ static int setdebug_cmd(JCR *jcr) 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; @@ -285,7 +287,12 @@ static int estimate_cmd(JCR *jcr) 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)); @@ -305,8 +312,9 @@ static int job_cmd(JCR *jcr) 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; } @@ -429,7 +437,8 @@ static int level_cmd(JCR *jcr) 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; } @@ -448,7 +457,8 @@ static int level_cmd(JCR *jcr) 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; } @@ -482,7 +492,8 @@ static int session_cmd(JCR *jcr) &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; } @@ -502,7 +513,8 @@ static int storage_cmd(JCR *jcr) 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); @@ -742,7 +754,8 @@ static int restore_cmd(JCR *jcr) 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; diff --git a/bacula/src/gnome2-console/.cvsignore b/bacula/src/gnome2-console/.cvsignore new file mode 100644 index 0000000000..b8893fbd69 --- /dev/null +++ b/bacula/src/gnome2-console/.cvsignore @@ -0,0 +1,7 @@ +test-gnome-console.conf +Makefile +gnome-console +gnome-console.conf +1 +2 +3