Imported Upstream version 2.5.1
[debian/amanda] / client-src / sendbackup-dump.c
index 470aff819788f3f2c57cb24a91779e8706582bf2..c76239415e75fcd583aa7e99708018aef1c1beca 100644 (file)
  * file named AUTHORS, in the root directory of this distribution.
  */
 /* 
- * $Id: sendbackup-dump.c,v 1.88 2006/03/09 20:06:11 johnfranks Exp $
+ * $Id: sendbackup-dump.c,v 1.90 2006/07/25 18:10:07 martinea Exp $
  *
  * send backup data using BSD dump
  */
 
+#include "amanda.h"
 #include "sendbackup.h"
 #include "getfsent.h"
 #include "clock.h"
@@ -36,7 +37,7 @@
 
 #define LEAF_AND_DIRS "sed -e \'\ns/^leaf[ \t]*[0-9]*[ \t]*\\.//\nt\n/^dir[ \t]/ {\ns/^dir[ \t]*[0-9]*[ \t]*\\.//\ns%$%/%\nt\n}\nd\n\'"
 
-static regex_t re_table[] = {
+static amregex_t re_table[] = {
   /* the various encodings of dump size */
   /* this should also match BSDI pre-3.0's buggy dump program, that
      produced doubled DUMP: DUMP: messages */
@@ -111,15 +112,24 @@ static regex_t re_table[] = {
   AM_STRANGE_RE(NULL)
 };
 
+static void start_backup(char *host, char *disk, char *amdevice, int level,
+               char *dumpdate, int dataf, int mesgf, int indexf);
+static void end_backup(int status);
+
 /*
  *  doing similar to $ dump | compression | encryption
  */
 
-static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf)
-    char *host;
-    char *disk, *amdevice;
-    int level, dataf, mesgf, indexf;
-    char *dumpdate;
+static void
+start_backup(
+    char *     host,
+    char *     disk,
+    char *     amdevice,
+    int                level,
+    char *     dumpdate,
+    int                dataf,
+    int                mesgf,
+    int                indexf)
 {
     int dumpin, dumpout, compout;
     char *dumpkeys = NULL;
@@ -130,25 +140,33 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
     char level_str[NUM_STR_SIZE];
     char *compopt  = NULL;
     char *encryptopt = skip_argument;
+    char *qdisk;
+    char *config;
+
+    (void)dumpdate;    /* Quiet unused parameter warning */
 
+    snprintf(level_str, SIZEOF(level_str), "%d", level);
 
-    snprintf(level_str, sizeof(level_str), "%d", level);
+    qdisk = quote_string(disk);
+    dbprintf(("%s: start: %s:%s lev %d\n",
+             get_pname(), host, qdisk, level));
 
     fprintf(stderr, "%s: start [%s:%s level %d]\n",
-           get_pname(), host, disk, level);
+           get_pname(), host, qdisk, level);
+    amfree(qdisk);
 
-      /*  apply client-side encryption here */
-      if ( options->encrypt == ENCRYPT_CUST ) {
-       encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE,
+    /*  apply client-side encryption here */
+    if ( options->encrypt == ENCRYPT_CUST ) {
+        encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE,
                        &compout, &dataf, &mesgf,
                        options->clnt_encrypt, encryptopt, NULL);
-       dbprintf(("%s: pid %ld: %s\n",
+        dbprintf(("%s: pid %ld: %s\n",
                  debug_prefix_time("-gnutar"), (long)encpid, options->clnt_encrypt));
-     } else {
+    } else {
         compout = dataf;
         encpid = -1;
-     }
-      /*  now do the client-side compression */
+    }
+    /*  now do the client-side compression */
 
 
     if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) {
@@ -195,8 +213,13 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
 
 #if defined(USE_RUNDUMP) || !defined(DUMP)
     cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL);
+    if (g_options->config)
+       config = g_options->config;
+    else
+       config = "NOCONFIG";
 #else
     cmd = stralloc(DUMP);
+    config = skip_argument;
 #endif
 
 #ifndef AIX_BACKUP                                     /* { */
@@ -210,6 +233,11 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
     {
         char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
                                            versionsuffix(), NULL);
+       if (g_options->config)
+           config = g_options->config;
+       else
+           config = "NOCONFIG";
+
        program->backup_name  = XFSDUMP;
        program->restore_name = XFSRESTORE;
 
@@ -228,6 +256,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
        dumpkeys = stralloc(level_str);
        dumppid = pipespawn(progname, STDIN_PIPE,
                            &dumpin, &dumpout, &mesgf,
+                           config, /* JLM */
                            "xfsdump",
                            options->no_record ? "-J" : skip_argument,
                            "-F",
@@ -248,8 +277,13 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
 #ifdef USE_RUNDUMP
         char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
                                            versionsuffix(), NULL);
+       if (g_options->config)
+           config = g_options->config;
+       else
+           config = "NOCONFIG";
 #else
        char *progname = cmd = newvstralloc(cmd, VXDUMP, NULL);
+       config = skip_argument;
 #endif
        program->backup_name  = VXDUMP;
        program->restore_name = VXRESTORE;
@@ -272,6 +306,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
 
        dumppid = pipespawn(progname, STDIN_PIPE,
                            &dumpin, &dumpout, &mesgf, 
+                           progname, config, /* JLM */
                            "vxdump",
                            dumpkeys,
                            "1048576",
@@ -291,6 +326,10 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
     {
         char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
                                            versionsuffix(), NULL);
+       if (g_options->config)
+           config = g_options->config;
+       else
+           config = "NOCONFIG";
        device = newstralloc(device, amname_to_dirname(amdevice));
        program->backup_name  = VDUMP;
        program->restore_name = VRESTORE;
@@ -313,6 +352,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
 
        dumppid = pipespawn(cmd, STDIN_PIPE,
                            &dumpin, &dumpout, &mesgf, 
+                           cmd, config,
                            "vdump",
                            dumpkeys,
                            "60",
@@ -350,6 +390,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
 
        dumppid = pipespawn(cmd, STDIN_PIPE,
                            &dumpin, &dumpout, &mesgf, 
+                           cmd, config,
                            "dump",
                            dumpkeys,
                            "1048576",
@@ -381,6 +422,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
 
     dumppid = pipespawn(cmd, STDIN_PIPE,
                        &dumpin, &dumpout, &mesgf, 
+                       cmd, config,
                        "backup",
                        dumpkeys,
                        "-",
@@ -405,9 +447,12 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in
        aclose(indexf);
 }
 
-static void end_backup(status)
-int status;
+static void
+end_backup(
+    int                status)
 {
+    (void)status;      /* Quiet unused parameter warning */
+
     /* don't need to do anything for dump */
 }