Imported Upstream version 3.3.3
[debian/amanda] / server-src / diskfile.c
index 544346a66e7d307d461cf005fe1fe908a834fd46..d8e11dce165c1669eb061945be621eda64deb5e6 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
  * Copyright (c) 1991-1998 University of Maryland at College Park
+ * Copyright (c) 2007-2012 Zmanda, Inc.  All Rights Reserved.
  * All Rights Reserved.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -513,7 +514,7 @@ parse_diskline(
            amfree(hostname);
            return (-1);
        }
-       if ((dtype = lookup_dumptype(dumptype)) == NULL) {
+       if (lookup_dumptype(dumptype) == NULL) {
            diskdevice = dumptype;
            skip_whitespace(s, ch);
            if(ch == '\0' || ch == '#') {
@@ -1851,6 +1852,7 @@ disable_skip_disk(
 char *
 match_disklist(
     disklist_t *origqp,
+    gboolean    exact_match,
     int                sargc,
     char **    sargv)
 {
@@ -1862,10 +1864,24 @@ match_disklist(
     int prev_match;
     disk_t *dp_skip;
     disk_t *dp;
+    char **new_sargv = NULL;
 
     if(sargc <= 0)
        return NULL;
 
+    if (exact_match) {
+       new_sargv = g_new0(char *, sargc+1);
+       for (i=0; i<sargc; i++) {
+           if (*sargv[i] == '=') {
+               new_sargv[i] = g_strdup(sargv[i]);
+           } else {
+               new_sargv[i] = g_strconcat("=", sargv[i], NULL);
+           }
+       }
+       sargv = new_sargv;
+    }
+
+
     for(dp = origqp->head; dp != NULL; dp = dp->next) {
        if(dp->todo == 1)
            dp->todo = -1;
@@ -1971,12 +1987,18 @@ match_disklist(
            dp->todo = 0;
     }
 
+    if (new_sargv) {
+       for (i=0; i<sargc; i++)
+           g_free(new_sargv[i]);
+       g_free(new_sargv);
+    }
     return errstr;
 }
 
 gboolean
 match_dumpfile(
     dumpfile_t  *file,
+    gboolean   exact_match,
     int                sargc,
     char **    sargv)
 {
@@ -2001,7 +2023,7 @@ match_dumpfile(
 
     dl.head = dl.tail = &d;
 
-    (void)match_disklist(&dl, sargc, sargv);
+    (void)match_disklist(&dl, exact_match, sargc, sargv);
     return d.todo;
 }