]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/plugins/fd/test-deltaseq-fd.c
Backport from BEE
[bacula/bacula] / bacula / src / plugins / fd / test-deltaseq-fd.c
index b3657119019f416ee0bc859cf849161367dae480..71bbc8df8b57c5e186b2e6ecf25a111a63a688c2 100644 (file)
@@ -1,29 +1,17 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2011 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
-   The main author of Bacula is Kern Sibbald, with contributions from
-   many others, a complete list can be found in the file AUTHORS.
-   This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version three of the GNU Affero General Public
-   License as published by the Free Software Foundation, which is 
-   listed in the file LICENSE.
+   The main author of Bacula is Kern Sibbald, with contributions from many
+   others, a complete list can be found in the file AUTHORS.
 
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU Affero General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
 
    Bacula® is a registered trademark of Kern Sibbald.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
 */
 /*
  * A simple delta plugin for the Bacula File Daemon
@@ -117,7 +105,7 @@ public:
    bool done;
    int level;
 
-   delta_test(bpContext *bpc) { 
+   delta_test(bpContext *bpc) {
       fd = NULL;
       ctx = bpc;
       done = false;
@@ -154,16 +142,16 @@ bRC loadPlugin(bInfo *lbinfo, bFuncs *lbfuncs, pInfo **pinfo, pFuncs **pfuncs)
 }
 
 /*
- * External entry point to unload the plugin 
+ * External entry point to unload the plugin
  */
-bRC unloadPlugin() 
+bRC unloadPlugin()
 {
 // Dmsg(NULL, dbglvl, "delta-test-fd: Unloaded\n");
    return bRC_OK;
 }
 
 /*
- * The following entry points are accessed through the function 
+ * The following entry points are accessed through the function
  *   pointers we supplied to Bacula. Each plugin type (dir, fd, sd)
  *   has its own set of entry points that the plugin must define.
  */
@@ -196,7 +184,7 @@ static bRC freePlugin(bpContext *ctx)
 /*
  * Return some plugin value (none defined)
  */
-static bRC getPluginValue(bpContext *ctx, pVariable var, void *value) 
+static bRC getPluginValue(bpContext *ctx, pVariable var, void *value)
 {
    return bRC_OK;
 }
@@ -204,7 +192,7 @@ static bRC getPluginValue(bpContext *ctx, pVariable var, void *value)
 /*
  * Set a plugin value (none defined)
  */
-static bRC setPluginValue(bpContext *ctx, pVariable var, void *value) 
+static bRC setPluginValue(bpContext *ctx, pVariable var, void *value)
 {
    return bRC_OK;
 }
@@ -230,7 +218,7 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
     */
    switch (event->eventType) {
    case bEventPluginCommand:
-//    Dmsg(ctx, dbglvl, 
+//    Dmsg(ctx, dbglvl,
 //         "delta-test-fd: PluginCommand=%s\n", (char *)value);
       break;
    case bEventJobStart:
@@ -271,7 +259,7 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
       if (self->level == 'I' || self->level == 'D') {
          bfuncs->getBaculaValue(ctx, bVarAccurate, (void *)&accurate);
          if (!accurate) {       /* can be changed to FATAL */
-            Jmsg(ctx, M_FATAL, 
+            Jmsg(ctx, M_FATAL,
                  "Accurate mode should be turned on when using the "
                  "delta-test plugin\n");
             return bRC_Error;
@@ -294,7 +282,7 @@ static const char *files[] = {
 };
 static int nb_files = 4;
 
-/* 
+/*
  * Start the backup of a specific file
  */
 static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp)
@@ -321,7 +309,7 @@ static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp)
       self->delta = sp->delta_seq + 1;
    }
    pm_strcpy(self->fname, files[self->delta % nb_files]);
-   Dmsg(ctx, dbglvl, "delta-test-fd: delta_seq=%i delta=%i fname=%s\n", 
+   Dmsg(ctx, dbglvl, "delta-test-fd: delta_seq=%i delta=%i fname=%s\n",
         sp->delta_seq, self->delta, self->fname);
 // Dmsg(ctx, dbglvl, "delta-test-fd: startBackupFile\n");
    return bRC_OK;
@@ -350,7 +338,7 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
    if (!self) {
       return bRC_Error;
    }
-    
+
    io->status = 0;
    io->io_errno = 0;
    switch(io->func) {
@@ -365,7 +353,7 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
          }
          if (!self->fd) {
             io->io_errno = errno;
-            Jmsg(ctx, M_FATAL, 
+            Jmsg(ctx, M_FATAL,
                  "Open failed: ERR=%s\n", strerror(errno));
             return bRC_Error;
          }
@@ -374,7 +362,7 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
          self->fd = fopen(self->fname, "r");
          if (!self->fd) {
             io->io_errno = errno;
-            Jmsg(ctx, M_FATAL, 
+            Jmsg(ctx, M_FATAL,
                "Open failed: ERR=%s\n", strerror(errno));
             return bRC_Error;
          }
@@ -391,7 +379,7 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
       } else {
          /* first time, read 300, then replace 50-250 by other data */
          if (self->delta == 0) {
-            io->status = fread(io->buf, 1, 400, self->fd);            
+            io->status = fread(io->buf, 1, 400, self->fd);
          } else {
             io->offset = self->delta * 100 / 2; /* chunks are melted */
             io->status = fread(io->buf, 1, 100, self->fd);
@@ -400,9 +388,9 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
          self->done = true;
       }
       if (io->status == 0 && ferror(self->fd)) {
-         Jmsg(ctx, M_FATAL, 
+         Jmsg(ctx, M_FATAL,
             "Pipe read error: ERR=%s\n", strerror(errno));
-         Dmsg(ctx, dbglvl, 
+         Dmsg(ctx, dbglvl,
             "Pipe read error: ERR=%s\n", strerror(errno));
          return bRC_Error;
       }
@@ -417,9 +405,9 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
       Dmsg(ctx, dbglvl, "delta-test-fd: WRITE count=%lld\n", (int64_t)io->count);
       io->status = fwrite(io->buf, 1, io->count, self->fd);
       if (io->status == 0 && ferror(self->fd)) {
-         Jmsg(ctx, M_FATAL, 
+         Jmsg(ctx, M_FATAL,
             "Pipe write error\n");
-         Dmsg(ctx, dbglvl, 
+         Dmsg(ctx, dbglvl,
             "Pipe read error: ERR=%s\n", strerror(errno));
          return bRC_Error;
       }
@@ -469,7 +457,7 @@ static bRC endRestoreFile(bpContext *ctx)
 /*
  * This is called during restore to create the file (if necessary)
  * We must return in rp->create_status:
- *   
+ *
  *  CF_ERROR    -- error
  *  CF_SKIP     -- skip processing this file
  *  CF_EXTRACT  -- extract the file (i.e.call i/o routines)