]> git.sur5r.net Git - bacula/bacula/commitdiff
Finish Win32 backup add DESTDIR to autostart code
authorKern Sibbald <kern@sibbald.com>
Wed, 21 May 2003 13:58:08 +0000 (13:58 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 21 May 2003 13:58:08 +0000 (13:58 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@525 91ce42f0-d328-0410-95d8-f526ca767f89

14 files changed:
bacula/kernstodo
bacula/platforms/redhat/Makefile.in
bacula/src/console/console.c
bacula/src/dird/verify.c
bacula/src/filed/backup.c
bacula/src/filed/restore.c
bacula/src/filed/win32/winmain.cpp
bacula/src/findlib/bfile.c
bacula/src/findlib/bfile.h
bacula/src/findlib/create_file.c
bacula/src/findlib/find_one.c
bacula/src/stored/bextract.c
bacula/src/stored/bscan.c
bacula/src/stored/record.c

index 2aad564d6dbdb42d99b07b9fd1e99b4ab3716cce..e910991967132f0022dcd8fa9c4dd405ac9a1bd7 100644 (file)
@@ -25,7 +25,10 @@ Testing to do: (painful)
 - Figure out how to use ssh or stunnel to protect Bacula communications.
 
 For 1.31 release:
-- Finish WIN32_DATA stream code (bextract, check if can handle stream)
+- Investigate doing RAW backup of Win32 partition.
+- Add JobName= to VerifyToCatalog so that all verifies can be done at the end.
+- Add thread specific data to hold the jcr -- send error messages from
+  low level routines by accessing it and using Jmsg().
 - Default duration with no qualifier is sec should be 1 day
 - Find a solution for the multiple FileSet problem (when it is changed). Add date?
 - Cancel waiting for Client connect in SD if FD goes away.
@@ -875,4 +878,4 @@ Done: (see kernsdone for more)
 - Count errors during restore and print them in the Job report.
 - Bug: fix access problems on files restored on WinXP.
 - Put system type returned by FD into catalog.
-
+- Finish WIN32_DATA stream code (bextract, check if can handle stream)
index 36975919ccbb4f4123895a1c13bcea031e77494f..e46588fd1b3287bb89759c8a5280acfbeabb576a 100644 (file)
@@ -18,30 +18,36 @@ install-autostart: install-autostart-fd install-autostart-sd install-autostart-d
 
        
 install-autostart-fd:
-       @if test -f $(DESTDIR)/etc/rc.d/init.d/bacula-fd; then \
-           /sbin/chkconfig --del bacula-fd; \
+       @if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-fd; then \
+          /sbin/chkconfig --del bacula-fd; \
        fi
        @$(INSTALL_PROGRAM) -m 744 bacula-fd $(DESTDIR)/etc/rc.d/init.d/bacula-fd
        # set symlinks for script at startup and shutdown
-       @/sbin/chkconfig --add bacula-fd
+       @if test x$(DESTDIR) = x ; then \
+          /sbin/chkconfig --add bacula-fd; \
+       fi
 
 
 install-autostart-sd:
-       @if test -f  $(DESTDIR)/etc/rc.d/init.d/bacula-sd; then \
+       @if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-sd; then \
            /sbin/chkconfig --del bacula-sd; \
        fi
        @$(INSTALL_PROGRAM) -m 744 bacula-sd  $(DESTDIR)/etc/rc.d/init.d/bacula-sd
        # set symlinks for script at startup and shutdown
-       @/sbin/chkconfig --add bacula-sd
+       @if test x$(DESTDIR) = x ; then \
+          /sbin/chkconfig --add bacula-sd; \
+       fi
 
 
 install-autostart-dir:
-       @if test -f  $(DESTDIR)/etc/rc.d/init.d/bacula-dir; then \
+       @if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-dir; then \
            /sbin/chkconfig --del bacula-dir; \
        fi
        @$(INSTALL_PROGRAM) -m 744 bacula-dir  $(DESTDIR)/etc/rc.d/init.d/bacula-dir
        # set symlinks for script at startup and shutdown
-       @/sbin/chkconfig --add bacula-dir
+       @if test x$(DESTDIR) = x ; then \
+          /sbin/chkconfig --add bacula-dir; \
+       fi
 
 
 uninstall: uninstall-autostart
@@ -49,20 +55,20 @@ uninstall: uninstall-autostart
 uninstall-autostart: uninstall-autostart-fd uninstall-autostart-sd uninstall-autostart-dir
 
 uninstall-autostart-fd:
-       @if test -f  $(DESTDIR)/etc/rc.d/init.d/bacula-fd; then \
+       @if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-fd; then \
            /sbin/chkconfig --del bacula-fd; \
        fi
        @rm -f  $(DESTDIR)/etc/rc.d/init.d/bacula-fd
 
 
 uninstall-autostart-sd:
-       @if test -f  $(DESTDIR)/etc/rc.d/init.d/bacula-sd; then \
+       @if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-sd; then \
            /sbin/chkconfig --del bacula-sd; \
        fi
        @rm -f  $(DESTDIR)/etc/rc.d/init.d/bacula-sd
 
 uninstall-autostart-dir:
-       @if test -f  $(DESTDIR)/etc/rc.d/init.d/bacula-dir; then \
+       @if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-dir; then \
            /sbin/chkconfig --del bacula-dir; \
        fi
        @rm -f  $(DESTDIR)/etc/rc.d/init.d/bacula-dir
index 3823180cc8f82bac92a2f0d7736ecba37d4ed9c0..89a81bfb6a976cde84617ae1686df39f5a2c62ba 100644 (file)
@@ -182,6 +182,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
         if (fgets(UA_sock->msg, len, input) == NULL) {
            stat = -1;
         } else {
+            sendit("%s", UA_sock->msg);  /* echo to terminal */
            strip_trailing_junk(UA_sock->msg);
            UA_sock->msglen = strlen(UA_sock->msg);
            stat = 1;
index fbc0726a3f2af04eba997479edfee96086e29869..85b5d245019247e4eeb56a97931a3ce2c542d0ee 100644 (file)
@@ -88,10 +88,15 @@ int do_verify(JCR *jcr)
    if (jcr->JobLevel == L_VERIFY_CATALOG || jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) {
       memcpy(&jr, &(jcr->jr), sizeof(jr));
       if (!db_find_last_jobid(jcr, jcr->db, &jr)) {
-        Jmsg(jcr, M_FATAL, 0, _(
-              "Unable to find JobId of previous InitCatalog Job.\n"
-              "Please run a Verify with Level=InitCatalog before\n"
-              "running the current Job.\n"));
+        if (jcr->JobLevel == L_VERIFY_CATALOG) {
+           Jmsg(jcr, M_FATAL, 0, _(
+                 "Unable to find JobId of previous InitCatalog Job.\n"
+                 "Please run a Verify with Level=InitCatalog before\n"
+                 "running the current Job.\n"));
+         } else {
+           Jmsg(jcr, M_FATAL, 0, _(
+                 "Unable to find JobId of previous Job for this client.\n"));
+        }   
         goto bail_out;
       }
       JobId = jr.JobId;
@@ -120,7 +125,8 @@ int do_verify(JCR *jcr)
       memset(&jr, 0, sizeof(jr));
       jr.JobId = JobId;
       if (!db_get_job_record(jcr, jcr->db, &jr)) {
-         Jmsg(jcr, M_FATAL, 0, _("Could not get job record. %s"), db_strerror(jcr->db));
+         Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), 
+             db_strerror(jcr->db));
         goto bail_out;
       }
       if (jr.JobStatus != 'T') {
@@ -145,7 +151,7 @@ int do_verify(JCR *jcr)
       jcr->VolumeName[0] = 0;
       if (!db_get_job_volume_names(jcr, jcr->db, jr.JobId, &jcr->VolumeName) ||
           jcr->VolumeName[0] == 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume Name for verify JobId=%d. %s"), 
+         Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume Name for verify JobId=%u. ERR=%s"), 
            jr.JobId, db_strerror(jcr->db));
         goto bail_out;
       }
index 2338290b4b156b4eb3c158a72f6abc55b4dc0873..8db9a7ebbbe4462b88cbcaca45df9a41ee076c7a 100644 (file)
@@ -154,14 +154,17 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    case FT_NOACCESS:
       Jmsg(jcr, M_NOTSAVED, -1, _("     Could not access %s: ERR=%s\n"), ff_pkt->fname, 
         strerror(ff_pkt->ff_errno));
+      jcr->Errors++;
       return 1;
    case FT_NOFOLLOW:
       Jmsg(jcr, M_NOTSAVED, -1, _("     Could not follow link %s: ERR=%s\n"), ff_pkt->fname, 
         strerror(ff_pkt->ff_errno));
+      jcr->Errors++;
       return 1;
    case FT_NOSTAT:
       Jmsg(jcr, M_NOTSAVED, -1, _("     Could not stat %s: ERR=%s\n"), ff_pkt->fname, 
         strerror(ff_pkt->ff_errno));
+      jcr->Errors++;
       return 1;
    case FT_DIRNOCHG:
    case FT_NOCHG:
@@ -181,9 +184,11 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    case FT_NOOPEN:
       Jmsg(jcr, M_NOTSAVED, -1, _("     Could not open directory %s: ERR=%s\n"), ff_pkt->fname, 
         strerror(ff_pkt->ff_errno));
+      jcr->Errors++;
       return 1;
    default:
       Jmsg(jcr, M_NOTSAVED, 0,  _("     Unknown file type %d; not saved: %s\n"), ff_pkt->type, ff_pkt->fname);
+      jcr->Errors++;
       return 1;
    }
 
@@ -192,11 +197,8 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    /* Open any file with data that we intend to save */
    if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && 
         ff_pkt->statp.st_size > 0) || 
-        ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO
-#ifdef HAVE_CYGWIN
-        || ff_pkt->type == FT_DIR
-#endif
-      ) {
+        ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO ||
+        (is_win32_backup() && ff_pkt->type == FT_DIR)) {
       btimer_id tid;   
       if (ff_pkt->type == FT_FIFO) {
         tid = start_thread_timer(pthread_self(), 60);
@@ -207,6 +209,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
         ff_pkt->ff_errno = errno;
          Jmsg(jcr, M_NOTSAVED, -1, _("     Cannot open %s: ERR=%s.\n"), ff_pkt->fname, 
              berror(&ff_pkt->bfd));
+        jcr->Errors++;
         stop_thread_timer(tid);
         return 1;
       }
@@ -289,7 +292,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
       Dmsg1(100, "Saving data, type=%d\n", ff_pkt->type);
 
       /* Note, no sparse option for win32_data */
-      if (is_win32_data(&ff_pkt->bfd)) {
+      if (is_win32_backup()) {
         stream = STREAM_WIN32_DATA;
         ff_pkt->flags &= ~FO_SPARSE;
       } else if (ff_pkt->flags & FO_SPARSE) {
index 8f4e21cdf8f9b788db8f0b2079f9fee36df0ef5b..1ec68dad026d2fbfff444dddbe941e2d0d1178d7 100644 (file)
@@ -264,6 +264,9 @@ void do_restore(JCR *jcr)
            }
         }
 
+        P(jcr->mutex);
+        pm_strcpy(&jcr->last_fname, fname);
+        V(jcr->mutex);
         jcr->num_files_examined++;
 
          Dmsg1(30, "Outfile=%s\n", ofile);
@@ -299,6 +302,11 @@ void do_restore(JCR *jcr)
       /* Data stream */
       } else if (stream == STREAM_FILE_DATA || stream == STREAM_SPARSE_DATA ||
                 stream == STREAM_WIN32_DATA) {
+        if (stream == STREAM_WIN32_DATA && !is_win32_backup()) {
+            Jmsg(jcr, M_ERROR, 0, _("Win32 backup data not supported on this Client.\n"));
+           extract = FALSE;
+           continue;
+        }
         if (extract) {
            if (stream == STREAM_SPARSE_DATA) {
               ser_declare;
@@ -314,7 +322,8 @@ void do_restore(JCR *jcr)
                  if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
                      Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
                         edit_uint64(fileAddr, ec1), ofile, berror(&bfd));
-                    goto bail_out;
+                    extract = FALSE;
+                    continue;
                  }
               }
            } else {
@@ -325,8 +334,9 @@ void do_restore(JCR *jcr)
            if ((uint32_t)bwrite(&bfd, wbuf, wsize) != wsize) {
                Dmsg0(0, "===Write error===\n");
                Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: ERR=%s\n"), ofile, berror(&bfd));
-              goto bail_out;
-           }
+              extract = FALSE;
+              continue;
+           } 
            total += wsize;
            jcr->JobBytes += wsize;
            fileAddr += wsize;
@@ -335,6 +345,11 @@ void do_restore(JCR *jcr)
       /* GZIP data stream */
       } else if (stream == STREAM_GZIP_DATA || stream == STREAM_SPARSE_GZIP_DATA ||
                 stream == STREAM_WIN32_GZIP_DATA) {
+        if (stream == STREAM_WIN32_GZIP_DATA && !is_win32_backup()) {
+            Jmsg(jcr, M_ERROR, 0, _("Win32 GZIP backup data not supported on this Client.\n"));
+           extract = FALSE;
+           continue;
+        }
 #ifdef HAVE_LIBZ
         if (extract) {
            ser_declare;
@@ -353,7 +368,8 @@ void do_restore(JCR *jcr)
                  if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
                      Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
                         edit_uint64(fileAddr, ec1), ofile, berror(&bfd));
-                    goto bail_out;
+                    extract = FALSE;
+                    continue;
                  }
               }
            } else {
@@ -365,14 +381,16 @@ void do_restore(JCR *jcr)
            if ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len, 
                  (const Byte *)wbuf, (uLong)wsize)) != Z_OK) {
                Jmsg(jcr, M_ERROR, 0, _("Uncompression error. ERR=%d\n"), stat);
-              goto bail_out;
+              extract = FALSE;
+              continue;
            }
 
             Dmsg2(100, "Write uncompressed %d bytes, total before write=%d\n", compress_len, total);
            if ((uLong)bwrite(&bfd, jcr->compress_buf, compress_len) != compress_len) {
                Dmsg0(0, "===Write error===\n");
                Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), ofile, berror(&bfd));
-              goto bail_out;
+              extract = FALSE;
+              continue;
            }
            total += compress_len;
            jcr->JobBytes += compress_len;
@@ -381,7 +399,8 @@ void do_restore(JCR *jcr)
 #else
         if (extract) {
             Jmsg(jcr, M_ERROR, 0, _("GZIP data stream found, but GZIP not configured!\n"));
-           goto bail_out;
+           extract = FALSE;
+           continue;
         }
 #endif
       /* If extracting, wierd stream (not 1 or 2), close output file anyway */
index ccb1cfff6e2b749e5ef3e93e44d259faa8c22b00..23df92aa289460db3cec67ec6d8e440ef9f72d8c 100755 (executable)
@@ -325,17 +325,25 @@ int BaculaAppMain()
       p_BackupWrite = (t_BackupWrite)
           GetProcAddress(hLib, "BackupWrite");
       FreeLibrary(hLib);
-    }
-    hLib = LoadLibrary("ADVAPI32.DLL");
-    if (hLib) {
-       p_OpenProcessToken = (t_OpenProcessToken)
-          GetProcAddress(hLib, "OpenProcessToken");
-       p_AdjustTokenPrivileges = (t_AdjustTokenPrivileges)
-          GetProcAddress(hLib, "AdjustTokenPrivileges");
-       p_LookupPrivilegeValue = (t_LookupPrivilegeValue)
-          GetProcAddress(hLib, "LookupPrivilegeValueA");
-       FreeLibrary(hLib);
-    }
+   }
+   hLib = LoadLibrary("ADVAPI32.DLL");
+   if (hLib) {
+      p_OpenProcessToken = (t_OpenProcessToken)
+         GetProcAddress(hLib, "OpenProcessToken");
+      p_AdjustTokenPrivileges = (t_AdjustTokenPrivileges)
+         GetProcAddress(hLib, "AdjustTokenPrivileges");
+      p_LookupPrivilegeValue = (t_LookupPrivilegeValue)
+         GetProcAddress(hLib, "LookupPrivilegeValueA");
+      FreeLibrary(hLib);
+   }
+   /*  
+    * Even if these are defined, don't use on old 
+    *  platforms.
+    */
+   if (bacService::IsWin95()) {
+      p_BackupRead = NULL;
+      p_BackupWrite = NULL;
+   }
 
    // Set this process to be the last application to be shut down.
    if (p_SetProcessShutdownParameters) {
index 30378c3d291513d22e622c655d3f9d78c0629d4f..8c15b961c186e0addc7781930a5826c32b99f63c 100644 (file)
@@ -52,7 +52,7 @@ void binit(BFILE *bfd)
  *   Returns 1 if function worked
  *   Returns 0 if failed (i.e. do not have Backup API on this machine)
  */
-int set_win32_data(BFILE *bfd, int enable)
+int set_win32_backup(BFILE *bfd, int enable)
 {
    if (!enable) {
       bfd->use_backup_api = 0;
@@ -63,68 +63,77 @@ int set_win32_data(BFILE *bfd, int enable)
    return bfd->use_backup_api;
 }
 
-int is_win32_data(BFILE *bfd)
+int is_win32_backup(void)
 {
-   return bfd->use_backup_api;
+   return p_BackupRead && p_BackupWrite;
 }
 
 HANDLE bget_handle(BFILE *bfd)
 {
-#ifdef xxx
-   if (!bfd->use_win_api) {
-      return get_osfhandle(bfd->fid);
-   }
-#endif
    return bfd->fh;
 }
 
 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
 {
    POOLMEM *win32_fname;
-
-#ifdef xxx
-   if (!bfd->use_win_api) {
-      bfd->fid = open(fname, flags, mode);
-      if (bfd->fid >= 0) {
-        bfd->mode = BF_READ;         /* not important if BF_READ or BF_WRITE */
-      }
-      return bfd->fid;
-   }
-#endif
+   DWORD dwaccess, dwflags;
 
    /* Convert to Windows path format */
    win32_fname = get_pool_memory(PM_FNAME);
    unix_name_to_win32(&win32_fname, (char *)fname);
 
-   if (flags & O_CREAT) {
+   if (flags & O_CREAT) {            /* Create */
+      if (bfd->use_backup_api) {
+        dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY;                
+        dwflags = FILE_FLAG_BACKUP_SEMANTICS;
+      } else {
+        dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS;
+        dwflags = 0;
+      }
       bfd->fh = CreateFile(win32_fname,
-            GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY,    /* access */
-            0,
-            NULL,                                   /* SecurityAttributes */
-            CREATE_ALWAYS,                          /* CreationDisposition */
-            FILE_FLAG_BACKUP_SEMANTICS,             /* Flags and attributes */
-            NULL);                                  /* TemplateFile */
+            dwaccess,                /* Requested access */
+            0,                       /* Shared mode */
+            NULL,                    /* SecurityAttributes */
+            CREATE_ALWAYS,           /* CreationDisposition */
+            dwflags,                 /* Flags and attributes */
+            NULL);                   /* TemplateFile */
       bfd->mode = BF_WRITE;
-   } else if (flags & O_WRONLY) {           /* creating */
+
+   } else if (flags & O_WRONLY) {     /* Open existing for write */
+      if (bfd->use_backup_api) {
+        dwaccess = FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY;
+        dwflags = FILE_FLAG_BACKUP_SEMANTICS;
+      } else {
+        dwaccess = FILE_ALL_ACCESS;
+        dwflags = 0;
+      }
       bfd->fh = CreateFile(win32_fname,
-            FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY,    /* access */
-            0,
-            NULL,                                   /* SecurityAttributes */
-            OPEN_EXISTING,                          /* CreationDisposition */
-            FILE_FLAG_BACKUP_SEMANTICS,             /* Flags and attributes */
-            NULL);
+            dwaccess,                /* Requested access */
+            0,                       /* Shared mode */
+            NULL,                    /* SecurityAttributes */
+            OPEN_EXISTING,           /* CreationDisposition */
+            dwflags,                 /* Flags and attributes */
+            NULL);                   /* TemplateFile */
       bfd->mode = BF_WRITE;
-   } else {
-      bfd->fh = CreateFile(win32_fname,
-            GENERIC_READ|READ_CONTROL|ACCESS_SYSTEM_SECURITY,       /* access */
-            FILE_SHARE_READ,                         /* shared mode */
-            NULL,                                   /* SecurityAttributes */
-            OPEN_EXISTING,                          /* CreationDisposition */
-            FILE_FLAG_BACKUP_SEMANTICS,  /* Flags and attributes */
-            NULL);                       /* TemplateFile */
 
+   } else {                          /* Read */
+      if (bfd->use_backup_api) {
+        dwaccess = GENERIC_READ|READ_CONTROL|ACCESS_SYSTEM_SECURITY;
+        dwflags = FILE_FLAG_BACKUP_SEMANTICS;
+      } else {
+        dwaccess = GENERIC_READ;
+        dwflags = 0;
+      }
+      bfd->fh = CreateFile(win32_fname,
+            dwaccess,                /* Requested access */
+            FILE_SHARE_READ,         /* Shared mode */
+            NULL,                    /* SecurityAttributes */
+            OPEN_EXISTING,           /* CreationDisposition */
+            dwflags,                 /* Flags and attributes */
+            NULL);                   /* TemplateFile */
       bfd->mode = BF_READ;
    }
+
    if (bfd->fh == INVALID_HANDLE_VALUE) {
       bfd->lerror = GetLastError();
       bfd->mode = BF_CLOSED;
@@ -141,14 +150,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
 int bclose(BFILE *bfd)
 { 
    int stat = 0;
-#ifdef xxx
-   if (!bfd->use_win_api) {
-      int stat = close(bfd->fid);
-      bfd->fid = -1;
-      bfd->mode = BF_CLOSED;
-      return stat;
-   }
-#endif
+
    if (bfd->errmsg) {
       free_pool_memory(bfd->errmsg);
       bfd->errmsg = NULL;
@@ -193,11 +195,7 @@ int bclose(BFILE *bfd)
 char *berror(BFILE *bfd)
 {
    LPTSTR msg;
-#ifdef xxx
-   if (!bfd->use_win_api) {
-      return strerror(errno);
-   }
-#endif
+
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
                 FORMAT_MESSAGE_FROM_SYSTEM,
                 NULL,
@@ -221,11 +219,6 @@ char *berror(BFILE *bfd)
  */
 ssize_t bread(BFILE *bfd, void *buf, size_t count)
 {
-#ifdef xxx
-   if (!bfd->use_win_api) {
-      return read(bfd->fid, buf, count);
-   }
-#endif
    bfd->rw_bytes = 0;
 
    if (bfd->use_backup_api) {
@@ -255,11 +248,6 @@ ssize_t bread(BFILE *bfd, void *buf, size_t count)
 
 ssize_t bwrite(BFILE *bfd, void *buf, size_t count)
 {
-#ifdef xxx
-   if (!bfd->use_win_api) {
-      return write(bfd->fid, buf, count);
-   }
-#endif
    bfd->rw_bytes = 0;
 
    if (bfd->use_backup_api) {
@@ -293,11 +281,6 @@ int is_bopen(BFILE *bfd)
 
 off_t blseek(BFILE *bfd, off_t offset, int whence)
 {
-#ifdef xxx
-   if (!bfd->use_win_api) {
-      return lseek(bfd->fid, offset, whence);
-   }
-#endif
    /* ****FIXME**** this is needed if we want to read Win32 Archives */
    return -1;
 }
@@ -315,7 +298,12 @@ void binit(BFILE *bfd)
    bfd->fid = -1;
 }
 
-int is_win32_data(BFILE *bfd)
+int set_win32_backup(BFILE *bfd, int enable)
+{
+   return 0;
+}
+
+int is_win32_backup(void)
 {
    return 0;
 }
index 1b917fa54b5c37fe9e2c25bb783a099ed86955d2..a666072e3ea30cdcef072eaf0aeb5774d478a79a 100644 (file)
 #include "winapi.h"
 
 #define BF_CLOSED 0
-#define BF_READ   1                  /* BackupRead */
-#define BF_WRITE  2                  /* BackupWrite */
+#define BF_READ   1                   /* BackupRead */
+#define BF_WRITE  2                   /* BackupWrite */
 
 /* In bfile.c */
 
 /* Basic low level I/O file packet */
 typedef struct s_bfile {
 #ifdef xxx
-   int use_win_api;                  /* set if using WinAPI */
+   int use_win_api;                   /* set if using WinAPI */
 #endif
-   int use_backup_api;               /* set if using BackupRead/Write */
-   int mode;                         /* set if file is open */
-   HANDLE fh;                        /* Win32 file handle */
-   int fid;                          /* fd if doing Unix style */
-   LPVOID lpContext;                 /* BackupRead/Write context */
-   POOLMEM *errmsg;                  /* error message buffer */
-   DWORD rw_bytes;                   /* Bytes read or written */
-   DWORD lerror;                     /* Last error code */
+   int use_backup_api;                /* set if using BackupRead/Write */
+   int mode;                          /* set if file is open */
+   HANDLE fh;                         /* Win32 file handle */
+   int fid;                           /* fd if doing Unix style */
+   LPVOID lpContext;                  /* BackupRead/Write context */
+   POOLMEM *errmsg;                   /* error message buffer */
+   DWORD rw_bytes;                    /* Bytes read or written */
+   DWORD lerror;                      /* Last error code */
 } BFILE;
 
 HANDLE bget_handle(BFILE *bfd);
 
-#else  /* Linux/Unix systems */
+#else   /* Linux/Unix systems */
 
 /* Basic low level I/O file packet */
 typedef struct s_bfile {
-   int fid;                          /* file id on Unix */
+   int fid;                           /* file id on Unix */
    int berrno;
 } BFILE;
 
@@ -68,7 +68,8 @@ typedef struct s_bfile {
 
 void binit(BFILE *bfd);
 int is_bopen(BFILE *bfd);
-int is_win32_data(BFILE *bfd);
+int set_win32_backup(BFILE *bfd, int enable);
+int is_win32_backup();
 char *berror(BFILE *bfd);
 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
 int bclose(BFILE *bfd);
index bf31722815d7e6fcf1c227e1117d4cd75fcb3dd6..88ec8ee1c33c55572d611b5c401e53c13e5cc0b8 100644 (file)
@@ -226,16 +226,21 @@ int create_file(void *jcr, char *fname, char *ofile, char *lname,
       if (make_path(jcr, ofile, new_mode, parent_mode, uid, gid, 0, NULL) != 0) {
         return CF_ERROR;
       }
-#ifdef HAVE_CYGWIN
-      if ((bopen(ofd, ofile, O_WRONLY|O_BINARY, 0)) < 0) {
-         Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), 
-              ofile, berror(ofd));
-        return CF_ERROR;
+      /*
+       * If we are using the Win32 Backup API, we open the
+       *   directory so that the security info will be read
+       *   and saved.
+       */
+      if (is_win32_backup()) {
+        if ((bopen(ofd, ofile, O_WRONLY|O_BINARY, 0)) < 0) {
+            Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"), 
+                 ofile, berror(ofd));
+           return CF_ERROR;
+        }
+        return CF_EXTRACT;
+      } else {
+        return CF_CREATED;
       }
-      return CF_EXTRACT;
-#else
-      return CF_CREATED;
-#endif
 
    /* The following should not occur */
    case FT_NOACCESS:
index f95c6d3ce85612278c6c097826ede6893db8e761..35f5624023a4a780533fad4a1aa92bc4104fc560 100755 (executable)
@@ -197,18 +197,23 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       int status;
       dev_t our_device = ff_pkt->statp.st_dev;
 
-#ifndef HAVE_CYGWIN
-      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(ff_pkt, pkt);
-        if (ff_pkt->linked) {
-           ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
+      /*  
+       * If we are using Win32 backup API, don't check
+       *  access as everything is more complicated, and
+       *  in principle, we should be able to access everything.
+       */
+      if (!is_win32_backup()) {
+        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(ff_pkt, pkt);
+           if (ff_pkt->linked) {
+              ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
+           }
+           return rtn_stat;
         }
-        return rtn_stat;
       }
-#endif
 
       /* Build a canonical directory name with a trailing slash in link var */
       len = strlen(fname);
index ad2e7ad65ae759cb17229c07efd501763918071c..5e507ebe0921360e4edff133076966aed11f44cb 100644 (file)
@@ -63,6 +63,7 @@ static POOLMEM *compress_buf;
 static int type;
 static int stream;
 static int prog_name_msg = 0;
+static int win32_data_msg = 0;
 static char *VolumeName = NULL;
 
 static char *wbuf;                   /* write buffer address */
@@ -187,6 +188,14 @@ int main (int argc, char *argv[])
    if (bsr) {
       free_bsr(bsr);
    }
+   if (prog_name_msg) {
+      Pmsg1(000, "%d Program Name and/or Program Data Stream records ignored.\n",
+        prog_name_msg);
+   }
+   if (win32_data_msg) {
+      Pmsg1(000, "%d Win32 data or Win32 gzip data stream records. Ignored.\n",
+        win32_data_msg);
+   }
    return 0;
 }
 
@@ -480,7 +489,12 @@ static void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
    } else if (rec->Stream == STREAM_PROGRAM_NAMES || rec->Stream == STREAM_PROGRAM_DATA) {
       if (!prog_name_msg) {
          Pmsg0(000, "Got Program Name or Data Stream. Ignored.\n");
-        prog_name_msg = 1;
+        prog_name_msg++;
+      }
+   } else if (rec->Stream == STREAM_WIN32_DATA || rec->Stream == STREAM_WIN32_GZIP_DATA) {
+      if (!win32_data_msg) {
+         Pmsg0(000, "Got Win32 data or Win32 gzip data stream. Ignored.\n");
+        win32_data_msg++;
       }
    } else if (!(rec->Stream == STREAM_MD5_SIGNATURE ||
                rec->Stream == STREAM_SHA1_SIGNATURE)) {
index a606979e3070b28d75455cc8c47fec955a8e72ff..99b9f23be93fe32e156956e84fefbf19628665a5 100644 (file)
@@ -626,6 +626,35 @@ static void record_cb(JCR *bjcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
       mjcr->JobBytes += rec->data_len - sizeof(uint64_t); /* No correct, we should expand it */
       free_jcr(mjcr);                /* done using JCR */
 
+   /* Win32 Data stream */
+   } else if (rec->Stream == STREAM_WIN32_DATA) {
+      mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime);
+      if (!mjcr) {
+        if (mr.VolJobs > 0) {
+            Pmsg2(000, _("Could not find Job SessId=%d SessTime=%d for Win32 Data record.\n"),
+                        rec->VolSessionId, rec->VolSessionTime);
+        } else {
+           ignored_msgs++;
+        }
+        return;
+      }
+      mjcr->JobBytes += rec->data_len;
+      free_jcr(mjcr);                /* done using JCR */
+
+   /* Win32 GZIP stream */
+   } else if (rec->Stream == STREAM_WIN32_GZIP_DATA) {
+      mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime);
+      if (!mjcr) {
+        if (mr.VolJobs > 0) {
+            Pmsg2(000, _("Could not find Job SessId=%d SessTime=%d for Win32 GZIP Data record.\n"),
+                        rec->VolSessionId, rec->VolSessionTime);
+        } else {
+           ignored_msgs++;
+        }
+        return;
+      }
+      mjcr->JobBytes += rec->data_len;
+      free_jcr(mjcr);                /* done using JCR */
 
    } else if (rec->Stream == STREAM_MD5_SIGNATURE) {
       char MD5buf[50];
index 2257a1b63ef83f2654daa8feb72c49cd89592ea9..22b3c4ebdf19b2e07e98e5cecea8480e242e854b 100644 (file)
@@ -92,6 +92,10 @@ char *stream_to_ascii(int stream, int fi)
        return "UATTR";
     case STREAM_FILE_DATA:
        return "DATA";
+    case STREAM_WIN32_DATA:
+       return "WIN32-DATA";
+    case STREAM_WIN32_GZIP_DATA:
+       return "WIN32-GZIP";
     case STREAM_MD5_SIGNATURE:
        return "MD5";
     case STREAM_SHA1_SIGNATURE:
@@ -112,6 +116,10 @@ char *stream_to_ascii(int stream, int fi)
        return "contUATTR";
     case -STREAM_FILE_DATA:
        return "contDATA";
+    case -STREAM_WIN32_DATA:
+       return "contWIN32-DATA";
+    case -STREAM_WIN32_GZIP_DATA:
+       return "contWIN32-GZIP";
     case -STREAM_MD5_SIGNATURE:
        return "contMD5";
     case -STREAM_SHA1_SIGNATURE: