]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/restore.c
- Add a kludge to detect bad date/times, which cause a seg fault in
[bacula/bacula] / bacula / src / filed / restore.c
index 1ad10c0179a638cc70fcddf769928376c5a0dd95..3ad0006cf8922ed92d8234d001e2e85897c62fff 100644 (file)
@@ -7,7 +7,7 @@
  *
  */
 /*
-   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -135,7 +135,6 @@ void do_restore(JCR *jcr)
       switch (stream) {
       case STREAM_UNIX_ATTRIBUTES:
       case STREAM_UNIX_ATTRIBUTES_EX:
-
          Dmsg1(30, "Stream=Unix Attributes. extract=%d\n", extract);
         /* If extracting, it was from previous stream, so
          * close the output file.
@@ -186,7 +185,7 @@ void do_restore(JCR *jcr)
         case CF_EXTRACT:
            extract = true;
            P(jcr->mutex);
-           pm_strcpy(&jcr->last_fname, attr->ofname);
+           pm_strcpy(jcr->last_fname, attr->ofname);
            V(jcr->mutex);
            jcr->JobFiles++;
            fileAddr = 0;
@@ -195,7 +194,7 @@ void do_restore(JCR *jcr)
            break;
         case CF_CREATED:
            P(jcr->mutex);
-           pm_strcpy(&jcr->last_fname, attr->ofname);
+           pm_strcpy(jcr->last_fname, attr->ofname);
            V(jcr->mutex);
            jcr->JobFiles++;
            fileAddr = 0;
@@ -210,7 +209,6 @@ void do_restore(JCR *jcr)
       case STREAM_FILE_DATA:
       case STREAM_SPARSE_DATA: 
       case STREAM_WIN32_DATA:  
-
         if (extract) {
            if (stream == STREAM_SPARSE_DATA) {
               ser_declare;
@@ -224,8 +222,10 @@ void do_restore(JCR *jcr)
               if (fileAddr != faddr) {
                  fileAddr = faddr;
                  if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
+                    berrno be;
+                    be.set_errno(bfd.berrno);
                      Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
-                        edit_uint64(fileAddr, ec1), attr->ofname, berror(&bfd));
+                        edit_uint64(fileAddr, ec1), attr->ofname, be.strerror());
                     extract = false;
                     bclose(&bfd);
                     continue;
@@ -238,7 +238,10 @@ void do_restore(JCR *jcr)
             Dmsg2(30, "Write %u bytes, total before write=%u\n", wsize, total);
            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"), attr->ofname, berror(&bfd));
+              berrno be;
+              be.set_errno(bfd.berrno);
+               Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: ERR=%s\n"), attr->ofname, 
+                    be.strerror());
               extract = false;
               bclose(&bfd);
               continue;
@@ -270,8 +273,10 @@ void do_restore(JCR *jcr)
               if (fileAddr != faddr) {
                  fileAddr = faddr;
                  if (blseek(&bfd, (off_t)fileAddr, SEEK_SET) < 0) {
+                    berrno be;
+                    be.set_errno(bfd.berrno);
                      Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"),
-                        edit_uint64(fileAddr, ec1), attr->ofname, berror(&bfd));
+                        edit_uint64(fileAddr, ec1), attr->ofname, be.strerror());
                     extract = false;
                     bclose(&bfd);
                     continue;
@@ -295,7 +300,9 @@ void do_restore(JCR *jcr)
             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"), attr->ofname, berror(&bfd));
+              berrno be;
+              be.set_errno(bfd.berrno);
+               Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), attr->ofname, be.strerror());
               extract = false;
               bclose(&bfd);
               continue;
@@ -315,34 +322,30 @@ void do_restore(JCR *jcr)
 #endif
         break;
 
-#ifdef HAVE_ACL
       case STREAM_UNIX_ATTRIBUTES_ACL:  
+#ifdef HAVE_ACL
         /* Recover ACL from stream and check it */
         acl = acl_from_text(sd->msg);
-        if(acl_valid(acl) != 0) {
-            Emsg1(M_WARNING, 0, "Failure in the ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
+        if (acl_valid(acl) != 0) {
+            Jmsg1(jcr, M_WARNING, 0, "Failure in the ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
            acl_free(acl);
         }
         
         /* Try to restore ACL */
-        if(attr->type == FT_DIREND) {
+        if (attr->type == FT_DIREND) {
            /* Directory */
-           if(acl_set_file(jcr->last_fname, ACL_TYPE_DEFAULT, acl) != 0) {
-              if(acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
-                  Emsg1(M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
-              }
-           }
-        } else {
-           /* File or Link */
-           if(acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
-               Emsg1(M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
+           if (acl_set_file(jcr->last_fname, ACL_TYPE_DEFAULT, acl) != 0 &&
+               acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
+               Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
            }
+        /* File or Link */
+        } else if (acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
+            Jmsg1(jcr, M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
         }
         acl_free(acl);
          Dmsg1(200, "ACL of file: %s successfully restored!", jcr->last_fname);
         break;
 #else 
-      case STREAM_UNIX_ATTRIBUTES_ACL:  
         non_support_acl++;
         break;                       /* unconfigured, ignore */
 #endif