]> git.sur5r.net Git - bacula/bacula/commitdiff
Finish estimate command
authorKern Sibbald <kern@sibbald.com>
Sat, 21 Jun 2003 18:11:07 +0000 (18:11 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 21 Jun 2003 18:11:07 +0000 (18:11 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@602 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/ua_cmds.c
bacula/src/filed/job.c
bacula/src/gnome2-console/.cvsignore [new file with mode: 0644]

index 7230bf311f11bc7446475e0c4a52bc29bcf8c9e5..9d958763c723e4d85c67cec13cc47c708ce011f6 100644 (file)
@@ -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; 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)) {
@@ -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);
    }
index 6ffa1d7336a5a26c6b33b6ac369249faa7f7c051..da51fed3b9266702eac7d69e65d0c49591011e0b 100644 (file)
@@ -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 (file)
index 0000000..b8893fb
--- /dev/null
@@ -0,0 +1,7 @@
+test-gnome-console.conf
+Makefile
+gnome-console
+gnome-console.conf
+1
+2
+3