]> git.sur5r.net Git - bacula/bacula/commitdiff
First cut of estimate command
authorKern Sibbald <kern@sibbald.com>
Sat, 21 Jun 2003 16:45:53 +0000 (16:45 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 21 Jun 2003 16:45:53 +0000 (16:45 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@601 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/ReleaseNotes
bacula/src/dird/fd_cmds.c
bacula/src/dird/ua_cmds.c
bacula/src/filed/estimate.c
bacula/src/filed/job.c
bacula/src/jcr.h

index a2bfbb5e4d164433d37fe0e28ebd375f5bb90a8e..cf010afc9c05ee24d779f126b3b603298ed672dc 100644 (file)
@@ -1,7 +1,7 @@
 
           Release Notes for Bacula 1.31
 
-  Bacula code: Total files = 250 Total lines = 74,376 (*.h *.c *.in)
+  Bacula code: Total files = 251 Total lines = 74,587 (*.h *.c *.in)
 
 Major Changes this Release:
 - The database format has changed. Please see below.
index 0aa9e4ae9bae1b374fbfe7d4f2094ac399c161cb..8f57fe1a4622e83ce6e63b1600a3a9cdd99c90fa 100644 (file)
@@ -100,7 +100,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
             jcr->client->hdr.name, fd->msg);
          set_jcr_job_status(jcr, JS_ErrorTerminated);
          return 0;
-       } else {
+       } else if (jcr->db) {
          CLIENT_DBR cr;
          memset(&cr, 0, sizeof(cr));
          bstrncpy(cr.Name, jcr->client->hdr.name, sizeof(cr.Name));
index acd33b5d37ea5270e5621d32575b83190c4a3f45..7230bf311f11bc7446475e0c4a52bc29bcf8c9e5 100644 (file)
@@ -1179,7 +1179,45 @@ static int var_cmd(UAContext *ua, char *cmd)
 
 static int estimate_cmd(UAContext *ua, char *cmd)
 {
-   bsendmsg(ua, "Not yet implemented\n");
+   JOB *job;
+   BSOCK *fd;
+   if (ua->argc < 2) {
+      return 1;
+   }
+   job = (JOB *)GetResWithName(R_JOB, ua->argk[1]);
+   ua->jcr->client = job->client;
+   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, _("Failed to connect to Client.\n"));
+      return 1;
+   }
+   fd = ua->jcr->file_bsock;
+
+   if (!send_include_list(ua->jcr)) {
+      bsendmsg(ua, _("Error sending include list.\n"));
+      return 1;
+   }
+
+   if (!send_exclude_list(ua->jcr)) {
+      bsendmsg(ua, _("Error sending exclude list.\n"));
+      return 1;
+   }
+
+   bnet_fsend(fd, "level = full mtime_only=0\n");
+   if (bnet_recv(fd) >= 0) {
+      bsendmsg(ua, "%s", fd->msg);
+   }
+
+   bnet_fsend(fd, "estimate list=1\n");
+   while (bnet_recv(fd) >= 0) {
+      bsendmsg(ua, "%s", fd->msg);
+   }
+
+   bnet_sig(fd, BNET_TERMINATE);
+   bnet_close(fd);
+   ua->jcr->file_bsock = NULL;
+
    return 1;
 }
 
index 24d047171711bbd5871a60458a3c92fbaf9dd9f3..b25bda0b9bdaf223a09df1b36e0e2da2cdcd62de 100644 (file)
@@ -42,7 +42,6 @@ int make_estimate(JCR *jcr)
    jcr->JobStatus = JS_Running;
 
    set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime, jcr->mtime_only);
-
    stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file, (void *)jcr);
 
    return stat;
@@ -54,11 +53,11 @@ int make_estimate(JCR *jcr)
  */
 static int tally_file(FF_PKT *ff_pkt, void *ijcr)
 {
-   JCR *jcr = (JCR *) ijcr;
+   JCR *jcr = (JCR *)ijcr;
+   ATTR attr;
 
    switch (ff_pkt->type) {
    case FT_LNKSAVED:                 /* Hard linked, file already saved */
-      break;
    case FT_REGE:
    case FT_REG:
    case FT_LNK:
@@ -84,7 +83,14 @@ static int tally_file(FF_PKT *ff_pkt, void *ijcr)
         ff_pkt->statp.st_size > 0) {
       jcr->JobBytes += ff_pkt->statp.st_size;
    }
-
-   jcr->JobFiles++;                 /* increment number of files sent */
+   jcr->num_files_examined++;
+   jcr->JobFiles++;                 /* increment number of files seen */
+   if (jcr->listing) {
+      memcpy(&attr.statp, &ff_pkt->statp, sizeof(struct stat));
+      attr.type = ff_pkt->type;
+      attr.ofname = (POOLMEM *)ff_pkt->fname;
+      attr.olname = (POOLMEM *)ff_pkt->link;
+      print_ls_output(jcr, &attr);
+   }
    return 1;
 }
index b4fdf052e331aad7dcf26a8836c8e550f6641e13..6ffa1d7336a5a26c6b33b6ac369249faa7f7c051 100644 (file)
@@ -98,7 +98,7 @@ static char verifycmd[]   = "verify level=%30s\n";
 static char errmsg[]      = "2999 Invalid command\n";
 static char no_auth[]     = "2998 No Authorization\n";
 static char OKinc[]       = "2000 OK include\n";
-static char OKest[]       = "2000 OK estimate files=%ld bytes=%ld\n";
+static char OKest[]       = "2000 OK estimate files=%u bytes=%s\n";
 static char OKexc[]       = "2000 OK exclude\n";
 static char OKlevel[]     = "2000 OK level\n";
 static char OKbackup[]    = "2000 OK backup\n";
@@ -283,8 +283,14 @@ static int setdebug_cmd(JCR *jcr)
 static int estimate_cmd(JCR *jcr)
 {
    BSOCK *dir = jcr->dir_bsock;
+   char ed2[50];
+
+   jcr->listing = 1;
    make_estimate(jcr);
-   return bnet_fsend(dir, OKest, jcr->num_files_examined, jcr->JobBytes);
+   bnet_fsend(dir, OKest, jcr->num_files_examined, 
+      edit_uint64(jcr->JobBytes, ed2));
+   bnet_sig(dir, BNET_EOD);
+   return 1;
 }
 
 /*
index 2add1749c98c51b50e5abc9966ad52607e0911e2..e8b293d1ed42f2f2b089b0e94f48790da10d4b13 100644 (file)
@@ -168,7 +168,7 @@ struct JCR {
    int incremental;                   /* set if incremental for SINCE */
    time_t mtime;                      /* begin time for SINCE */
    int mtime_only;                    /* compare only mtime and not ctime as well */
-   int status;                        /* job status */
+   int listing;                       /* job listing in estimate */
    long Ticket;                       /* Ticket */
    int save_level;                    /* save level */
    char *big_buf;                     /* I/O buffer */