LCOV - code coverage report
Current view: top level - src/server - backup_phase1.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 34 0.0 %
Date: 2016-11-07 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "../burp.h"
       2             : #include "../alloc.h"
       3             : #include "../asfd.h"
       4             : #include "../async.h"
       5             : #include "../cmd.h"
       6             : #include "../cntr.h"
       7             : #include "../fsops.h"
       8             : #include "../handy.h"
       9             : #include "../log.h"
      10             : #include "../msg.h"
      11             : #include "../sbuf.h"
      12             : #include "child.h"
      13             : #include "compress.h"
      14             : #include "manio.h"
      15             : #include "quota.h"
      16             : #include "sdirs.h"
      17             : #include "backup_phase1.h"
      18             : 
      19           0 : int backup_phase1_server_all(struct async *as,
      20             :         struct sdirs *sdirs, struct conf **confs)
      21             : {
      22           0 :         int ret=-1;
      23           0 :         struct sbuf *sb=NULL;
      24           0 :         char *phase1tmp=NULL;
      25           0 :         struct asfd *asfd=as->asfd;
      26           0 :         struct manio *manio=NULL;
      27           0 :         enum protocol protocol=get_protocol(confs);
      28           0 :         struct cntr *cntr=get_cntr(confs);
      29             : 
      30           0 :         logp("Begin phase1 (file system scan)\n");
      31             : 
      32           0 :         if(!(phase1tmp=get_tmp_filename(sdirs->phase1data))
      33           0 :           || !(manio=manio_open_phase1(phase1tmp,
      34           0 :                 comp_level(get_int(confs[OPT_COMPRESSION])), protocol))
      35           0 :           || !(sb=sbuf_alloc(protocol)))
      36             :                 goto error;
      37             : 
      38             :         while(1)
      39             :         {
      40           0 :                 sbuf_free_content(sb);
      41           0 :                 switch(sbuf_fill_from_net(sb, asfd, NULL, cntr))
      42             :                 {
      43             :                         case 0: break;
      44             :                         case 1: // Last thing the client sends is
      45             :                                 // 'backupphase2', and it wants an 'ok' reply.
      46           0 :                                 if(asfd->write_str(asfd, CMD_GEN, "ok")
      47           0 :                                   || send_msg_fzp(manio->fzp, CMD_GEN,
      48             :                                         "phase1end", strlen("phase1end")))
      49             :                                                 goto error;
      50             :                                 goto end;
      51             :                         case -1:
      52             :                         default: goto error;
      53             :                 }
      54           0 :                 if(write_status(CNTR_STATUS_SCANNING, sb->path.buf, cntr)
      55           0 :                   || manio_write_sbuf(manio, sb))
      56             :                         goto error;
      57           0 :                 cntr_add_phase1(cntr, sb->path.cmd, 0);
      58             : 
      59           0 :                 if(sbuf_is_estimatable(sb))
      60             :                 {
      61           0 :                         cntr_add_val(cntr, CMD_BYTES_ESTIMATED,
      62           0 :                                 (uint64_t)sb->statp.st_size);
      63             :                 }
      64             :         }
      65             : 
      66             : end:
      67           0 :         if(manio_close(&manio))
      68             :         {
      69           0 :                 logp("error closing %s in backup_phase1_server\n", phase1tmp);
      70           0 :                 goto error;
      71             :         }
      72             : 
      73           0 :         if(check_quota(as, cntr,
      74             :                 get_uint64_t(confs[OPT_HARD_QUOTA]),
      75             :                 get_uint64_t(confs[OPT_SOFT_QUOTA])))
      76             :                         goto error;
      77             : 
      78             :         // Possible rename race condition is of no consequence here, because
      79             :         // the working directory will always get deleted if phase1 is not
      80             :         // complete.
      81           0 :         if(do_rename(phase1tmp, sdirs->phase1data))
      82             :                 goto error;
      83             : 
      84             :         //cntr_print(p1cntr, cntr, ACTION_BACKUP);
      85             : 
      86           0 :         logp("End phase1 (file system scan)\n");
      87           0 :         ret=0;
      88             : error:
      89           0 :         free_w(&phase1tmp);
      90           0 :         manio_close(&manio);
      91           0 :         sbuf_free(&sb);
      92           0 :         return ret;
      93             : }

Generated by: LCOV version 1.10