]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/findlib/find_one.c
Merge branch 'master' into basejobv3
[bacula/bacula] / bacula / src / findlib / find_one.c
index bc525b1f5535bbbdee743047a2256f55e1026ea7..4d23539eefafcbef7c4426974f6cb713b2df8e9f 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2009 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.
@@ -20,7 +20,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   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.
@@ -211,6 +211,22 @@ static bool volume_has_attrlist(const char *fname)
    return false;
 }
 
+/*
+ * check for BSD nodump flag
+ */
+static bool no_dump(JCR *jcr, FF_PKT *ff_pkt)
+{
+#if defined(HAVE_CHFLAGS) && defined(UF_NODUMP)
+   if ( (ff_pkt->flags & FO_HONOR_NODUMP) &&
+        (ff_pkt->statp.st_flags & UF_NODUMP) ) {
+      Jmsg(jcr, M_INFO, 1, _("     NODUMP flag set - will not process %s\n"),
+           ff_pkt->fname);
+      return true;                    /* do not backup this file */
+   }
+#endif
+   return false;                      /* do backup */
+}
+
 /* check if a file have changed during backup and display an error */
 bool has_file_changed(JCR *jcr, FF_PKT *ff_pkt)
 {
@@ -257,19 +273,19 @@ bool has_file_changed(JCR *jcr, FF_PKT *ff_pkt)
 }
 
 /*
- * In incremental/diffential or accurate backup, we
- * say if the current file has changed.
+ * For incremental/diffential or accurate backups, we
+ *   determine if the current file has changed.
  */
 static bool check_changes(JCR *jcr, FF_PKT *ff_pkt)
 {
-   /* in special mode (like accurate backup), user can 
+   /* in special mode (like accurate backup), the programmer can 
     * choose his comparison function.
     */
    if (ff_pkt->check_fct) {
       return ff_pkt->check_fct(jcr, ff_pkt);
    }
 
-   /* in normal modes (incr/diff), we use this default
+   /* For normal backups (incr/diff), we use this default
     * behaviour
     */
    if (ff_pkt->incremental &&
@@ -283,6 +299,35 @@ static bool check_changes(JCR *jcr, FF_PKT *ff_pkt)
    return true;
 }
 
+static bool have_ignoredir(FF_PKT *ff_pkt)
+{
+   struct stat sb;
+   char tmp_name[MAXPATHLEN];
+   char *ignoredir;
+
+   /* Ensure that pointers are defined */
+   if (!ff_pkt->fileset || !ff_pkt->fileset->incexe) {
+      return false;
+   }
+   ignoredir = ff_pkt->fileset->incexe->ignoredir;
+   
+   if (ignoredir) {
+      if (strlen(ff_pkt->fname) + strlen(ignoredir) + 2 > MAXPATHLEN) {
+         return false;
+      }
+
+      strcpy(tmp_name, ff_pkt->fname);
+      strcat(tmp_name, "/");
+      strcat(tmp_name, ignoredir);
+      if (stat(tmp_name, &sb) == 0) {
+         Dmsg2(100, "Directory '%s' ignored (found %s)\n",
+               ff_pkt->fname, ignoredir);
+         return true;      /* Just ignore this directory */
+      } 
+   }
+   return false;
+}
+
 /*
  * Find a single file.
  * handle_file is the callback for handling the file.
@@ -353,13 +398,22 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt,
       }
       ff_pkt->volhas_attrlist = volume_has_attrlist(fname);
    }
+
+   /*
+    * Ignore this entry if no_dump() returns true
+    */
+   if (no_dump(jcr, ff_pkt)) {
+           Dmsg1(100, "'%s' ignored (NODUMP flag set)\n",
+                 ff_pkt->fname);
+           return 1;
+   }
+
    /*
     * If this is an Incremental backup, see if file was modified
     * since our last "save_time", presumably the last Full save
     * or Incremental.
     */
-   if (   ff_pkt->incremental 
-       && !S_ISDIR(ff_pkt->statp.st_mode) 
+   if (   !S_ISDIR(ff_pkt->statp.st_mode) 
        && !check_changes(jcr, ff_pkt)) 
    {
       Dmsg1(500, "Non-directory incremental: %s\n", ff_pkt->fname);
@@ -503,44 +557,12 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt,
       bool recurse = true;
       bool volhas_attrlist = ff_pkt->volhas_attrlist;    /* Remember this if we recurse */
 
-      /*
-       * If we are using Win32 (non-portable) backup API, don't check
-       *  access as everything is more complicated, and
-       *  in principle, we should be able to access everything.
-       */
-      if (!have_win32_api() || (ff_pkt->flags & FO_PORTABLE)) {
-         if (access(fname, R_OK) == -1 && geteuid() != 0) {
-            /* Could not access() directory */
-            ff_pkt->type = FT_NOACCESS;
-            ff_pkt->ff_errno = errno;
-            rtn_stat = handle_file(jcr, ff_pkt, top_level);
-            if (ff_pkt->linked) {
-               ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
-            }
-            return rtn_stat;
-         }
-      }
-
       /*
        * Ignore this directory and everything below if the file .nobackup
        * (or what is defined for IgnoreDir in this fileset) exists
        */
-      if (ff_pkt->ignoredir != NULL) {
-         struct stat sb;
-         char fname[MAXPATHLEN];
-
-         if (strlen(ff_pkt->fname) + strlen("/") +
-            strlen(ff_pkt->ignoredir) + 1 > MAXPATHLEN)
-            return 1;   /* Is this wisdom? */
-
-         strcpy(fname, ff_pkt->fname);
-         strcat(fname, "/");
-         strcat(fname, ff_pkt->ignoredir);
-         if (stat(fname, &sb) == 0) {
-            Dmsg2(100, "Directory '%s' ignored (found %s)\n",
-               ff_pkt->fname, ff_pkt->ignoredir);
-            return 1;      /* Just ignore this directory */
-         }
+      if (have_ignoredir(ff_pkt)) {
+         return 1; /* Just ignore this directory */
       }
 
       /* Build a canonical directory name with a trailing slash in link var */
@@ -555,8 +577,8 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt,
       link[len] = 0;
 
       ff_pkt->link = link;
-      if (ff_pkt->incremental && !check_changes(jcr, ff_pkt)) {
-         /* Incremental option, directory entry not changed */
+      if (!check_changes(jcr, ff_pkt)) {
+         /* Incremental/Full+Base option, directory entry not changed */
          ff_pkt->type = FT_DIRNOCHG;
       } else {
          ff_pkt->type = FT_DIRBEGIN;