From: Kern Sibbald Date: Sun, 26 Jun 2005 11:32:41 +0000 (+0000) Subject: - Add set_mode method in DEVICE. X-Git-Tag: Release-7.0.0~8666 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=07ba2d0169a59a315bf208ef6c90a44295fb6efd;p=bacula%2Fbacula - Add set_mode method in DEVICE. - 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 --- diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 380bf46299..d180aec85a 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -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: diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 2bf9725f72..967c24b4b4 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -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; diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index a28a0a2edc..c3f5bfb50e 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -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")); } } diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 1d064ee144..b9380f2a72 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -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 };