]> git.sur5r.net Git - bacula/bacula/commitdiff
- Add set_mode method in DEVICE.
authorKern Sibbald <kern@sibbald.com>
Sun, 26 Jun 2005 11:32:41 +0000 (11:32 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 26 Jun 2005 11:32:41 +0000 (11:32 +0000)
- Correct set_mode method in DEVICE
- Add more DVD debug info

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2165 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kes-1.37
bacula/src/findlib/create_file.c
bacula/src/stored/dev.c
bacula/src/stored/dev.h

index 380bf4629995918ee43023f1c559c00b0e9e44b3..d180aec85a74e8efdea0114a816fb95c3b4a83e6 100644 (file)
@@ -4,6 +4,10 @@
 General:
 
 Changes to 1.37.26:
+26Jun05
+- Add set_mode method in DEVICE.
+- Correct set_mode method in DEVICE
+- Add more DVD debug info 
 23Jun05
 - Check for incorrect duration and size modifiers in conf files.
 22Jun05:
index 2bf9725f72c97a8da41a6f4bee16c243ca541d72..967c24b4b42ec1ed7d5e6207090f88be24c69c9d 100644 (file)
@@ -179,11 +179,11 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
          if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
             berrno be;
             int stat;
-            be.set_errno(bfd->berrno);
             Dmsg2(000, "bopen failed errno=%d: ERR=%s\n", bfd->berrno,  
                be.strerror(bfd->berrno));
-            if (pnl > 0) {
+            if (strlen(attr->ofname) > 250) {   /* Microsoft limitation */
                char savechr;
+               char *p, *e;
                struct saved_cwd cwd;
                savechr = attr->ofname[pnl];
                attr->ofname[pnl] = 0;                 /* terminate path */
@@ -193,7 +193,24 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
                   attr->ofname[pnl] = savechr;
                   return CF_ERROR;
                }
-               if (chdir(attr->ofname) < 0) {
+               p = attr->ofname;
+               while ((e = strchr(p, '/'))) {
+                  *e = 0;
+                  if (chdir(p) < 0) {
+                     berrno be;
+                     Jmsg2(jcr, M_ERROR, 0, _("Could not chdir to %s: ERR=%s\n"),
+                           attr->ofname, be.strerror());
+                     restore_cwd(&cwd, NULL, NULL);
+                     free_cwd(&cwd);
+                     attr->ofname[pnl] = savechr;
+                     *e = '/';
+                     return CF_ERROR;
+                  }
+                  *e = '/';
+                  p = e + 1;
+               }
+               if (chdir(p) < 0) {
+                  berrno be;
                   Jmsg2(jcr, M_ERROR, 0, _("Could not chdir to %s: ERR=%s\n"),
                         attr->ofname, be.strerror());
                   restore_cwd(&cwd, NULL, NULL);
@@ -215,7 +232,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
                }
             }
             Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
-                  attr->ofname, be.strerror());
+                  attr->ofname, be.strerror(bfd->berrno));
             return CF_ERROR;
          }
          return CF_EXTRACT;
index a28a0a2edcd60da181539fd557e139264907c671..c3f5bfb50e59d1a0acecd603a34e5c05e713492a 100644 (file)
@@ -297,13 +297,24 @@ DEVICE::open(char *VolName, int mode)
 
 void DEVICE::set_mode(int new_mode) 
 {
-   if (new_mode == OPEN_READ_WRITE) {
-      mode = O_RDWR | O_BINARY;
-   } else if (new_mode == OPEN_READ_ONLY) {
+   switch (new_mode) {
+   case CREATE_READ_WRITE:
+      mode = O_CREAT | O_RDWR | O_BINARY;
+      break;
+   case OPEN_READ_WRITE:
+      if (is_dvd() || is_file()) {
+         mode = O_CREAT | O_RDWR | O_BINARY;
+      } else {
+         mode = O_RDWR | O_BINARY;
+      }
+      break;
+   case OPEN_READ_ONLY:
       mode = O_RDONLY | O_BINARY;
-   } else if (new_mode == OPEN_WRITE_ONLY) {
+      break;
+   case OPEN_WRITE_ONLY:
       mode = O_WRONLY | O_BINARY;
-   } else {
+      break;
+   default:
       Emsg0(M_ABORT, 0, _("Illegal mode given to open dev.\n"));
    }
 }
index 1d064ee1449137b30fca6de2a1635b220b0c4431..b9380f2a728fbae51e4c4c86efe97aa20d835823 100644 (file)
@@ -43,7 +43,8 @@
 
 /* Arguments to open_dev() */
 enum {
-   OPEN_READ_WRITE = 1,
+   CREATE_READ_WRITE = 1,
+   OPEN_READ_WRITE,
    OPEN_READ_ONLY,
    OPEN_WRITE_ONLY
 };