General:
Changes to 1.37.26:
+22Jun05:
+- Add Version, ConfigDir, and WorkingDir as Python attributes
+ in the Director.
+- Implement code (principally for Win32) that on failure to
+ create a file, it will cd into the directory and attempt
+ to create the file using a relative path. This avoids creating
+ files with paths which fail on Win32.
+- Fix parsing of times and sizes with decimal numbers.
+- Make free_volume_list() in SD work if vol list is not
+ initialized (./bacula-sd -t).
21Jun05:
- Add debug error printout when open() fails.
- If open() of DVD fails in mount.c, return false.
void store_replace(LEX *lc, RES_ITEM *item, int index, int pass);
void init_device_resources();
-static char *configfile = NULL;
static char *runjob = NULL;
static int background = 1;
static void init_reload(void);
DIRRES *director; /* Director resource */
int FDConnectTimeout;
int SDConnectTimeout;
+char *configfile = NULL;
/* Globals Imported */
extern int r_first, r_last; /* first and last resources */
#undef _POSIX_C_SOURCE
#include <Python.h>
+extern char *configfile;
extern JCR *get_jcr_from_PyObject(PyObject *self);
extern PyObject *find_method(PyObject *eventsObject, PyObject *method,
const char *name);
{ N_("JobName"), "s"},
{ N_("JobStatus"), "s"},
{ N_("Priority"), "i"},
+ { N_("Version"), "s"},
+ { N_("ConfigFile"), "s"},
+ { N_("WorkingDir"), "s"},
{ NULL, NULL}
};
return Py_BuildValue(getvars[i].fmt, buf);
case 13: /* Priority */
return Py_BuildValue(getvars[i].fmt, jcr->JobPriority);
+ case 14: /* Version */
+ return Py_BuildValue(getvars[i].fmt, VERSION);
+ case 15: /* Config Dir */
+ return Py_BuildValue(getvars[i].fmt, configfile);
+ case 16: /* Working Dir */
+ return Py_BuildValue(getvars[i].fmt, director->working_directory);
}
bsnprintf(errmsg, sizeof(errmsg), "Attribute %s not found.", attrname);
bail_out:
attr->ofname[pnl] = 0; /* terminate path */
if (!path_already_seen(jcr, attr->ofname, pnl)) {
- Dmsg1(50, "Make path %s\n", attr->ofname);
+ Dmsg1(100, "Make path %s\n", attr->ofname);
/*
* If we need to make the directory, ensure that it is with
* execute bit set (i.e. parent_mode), and preserve what already
Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
bclose(bfd);
}
+ /*
+ * If the open fails, we attempt to cd into the directory
+ * and create the file with a relative path rather than
+ * the full absolute path. This is for Win32 where
+ * path names may be too long to create.
+ */
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) {
+ char savechr;
+ struct saved_cwd cwd;
+ savechr = attr->ofname[pnl];
+ attr->ofname[pnl] = 0; /* terminate path */
+ Dmsg1(000, "Do chdir %s\n", attr->ofname);
+ if (save_cwd(&cwd) != 0) {
+ Jmsg0(jcr, M_ERROR, 0, _("Could not save_dirn"));
+ attr->ofname[pnl] = savechr;
+ return CF_ERROR;
+ }
+ if (chdir(attr->ofname) < 0) {
+ 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;
+ return CF_ERROR;
+ }
+ attr->ofname[pnl] = savechr;
+ Dmsg1(000, "Do open %s\n", &attr->ofname[pnl+1]);
+ if ((bopen(bfd, &attr->ofname[pnl+1], mode, S_IRUSR | S_IWUSR)) < 0) {
+ stat = CF_ERROR;
+ } else {
+ stat = CF_EXTRACT;
+ }
+ restore_cwd(&cwd, NULL, NULL);
+ free_cwd(&cwd);
+ if (stat == CF_EXTRACT) {
+ return CF_EXTRACT;
+ }
+ }
Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
attr->ofname, be.strerror());
return CF_ERROR;
/*
- * Given a string "str", separate the integer part into
+ * Given a string "str", separate the numeric part into
* str, and the modifier into mod.
*/
static bool get_modifier(char *str, char *num, int num_len, char *mod, int mod_len)
{
int i, len, num_begin, num_end, mod_begin, mod_end;
- /*
- * Look for modifier by walking back looking for the first
- * space or digit.
- */
strip_trailing_junk(str);
len = strlen(str);
/* Walk through integer part */
for ( ; i<len; i++) {
- if (!B_ISDIGIT(str[i])) {
+ if (!B_ISDIGIT(str[i]) && str[i] != '.') {
break;
}
}
if (num_len == 0) {
return false;
}
+ /* Eat any spaces in front of modifier */
for ( ; i<len; i++) {
if (!B_ISSPACE(str[i])) {
break;
return false;
}
bstrncpy(str, &str[mod_end], len);
+ Dmsg2(900, "num=%s mod=%s\n", num, mod);
return true;
}
*
* Version $Id$
*/
-
/*
Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as ammended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
{
int token;
uint64_t uvalue;
+ char bsize[500];
Dmsg0(900, "Enter store_size\n");
token = lex_get_token(lc, T_SKIP_EOL);
case T_NUMBER:
case T_IDENTIFIER:
case T_UNQUOTED_STRING:
- if (!size_to_uint64(lc->str, lc->str_len, &uvalue)) {
+ bstrncpy(bsize, lc->str, sizeof(bsize)); /* save first part */
+ /* if terminated by space, scan and get modifier */
+ if (lc->ch == ' ') {
+ token = lex_get_token(lc, T_ALL);
+ switch (token) {
+ case T_IDENTIFIER:
+ case T_UNQUOTED_STRING:
+ bstrncat(bsize, lc->str, sizeof(bsize));
+ break;
+ }
+ }
+ if (!size_to_uint64(bsize, strlen(bsize), &uvalue)) {
scan_err1(lc, _("expected a size number, got: %s"), lc->str);
}
*(uint64_t *)(item->value) = uvalue;
case T_NUMBER:
case T_IDENTIFIER:
case T_UNQUOTED_STRING:
- bstrncpy(period, lc->str, sizeof(period));
+ bstrncpy(period, lc->str, sizeof(period)); /* get first part */
+ /* if terminated by space, scan and get modifier */
if (lc->ch == ' ') {
token = lex_get_token(lc, T_ALL);
switch (token) {
void free_volume_list()
{
VOLRES *vol;
+ if (!vol_list) {
+ return;
+ }
for (vol=(VOLRES *)vol_list->first(); vol; vol=(VOLRES *)vol_list->next(vol)) {
Dmsg1(000, "Unreleased Volume=%s\n", vol->vol_name);
}
/* */
#undef VERSION
#define VERSION "1.37.26"
-#define BDATE "21 June 2005"
-#define LSMDATE "21Jun05"
+#define BDATE "22 June 2005"
+#define LSMDATE "22Jun05"
/* Debug flags */
#undef DEBUG