From: Kern Sibbald Date: Sat, 12 Jun 2004 07:51:27 +0000 (+0000) Subject: Misc see kes-1.34 X-Git-Tag: Release-1.34.4~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=48091ff92c6a2bbc0e78722ffe596fb162b642d0;p=bacula%2Fbacula Misc see kes-1.34 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1409 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index b67fe87926..9cc129afae 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -13,6 +13,9 @@ The error I when I installed 1.34.2 clients: The BACULA-FD file is linked to missing export KERNEL32.DLL:GetFileAttributesExA. +- Mark a non-removable disk Volume in error rather than asking sys op to + mount it. +- Implement Fixed storage LabelFormat test. Documentation from Christopher Hull on new client job requests: === @@ -1091,4 +1094,3 @@ Block Position: 0 - Add regression of btape "fill" ==== Done in 1.34.4 - Implement "label slots=1,2... pool=yyy barcodes" - diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 38fea5666f..0d0c80d11c 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -180,6 +180,9 @@ #define B_ISUPPER(c) (isascii((int)(c)) && isupper((int)(c))) #define B_ISDIGIT(c) (isascii((int)(c)) && isdigit((int)(c))) +/* For multiplying by 10 with shift and addition */ +#define B_TIMES10(d) ((d<<3)+(d<<1)) + typedef void (HANDLER)(); typedef int (INTHANDLER)(); @@ -415,6 +418,9 @@ int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...); #undef fgets #define fgets(x,y,z) bfgets((x), (y), (z)) +/* Use our sscanf, which is safer and works with known sizes */ +// #define sscanf bsscanf + #ifdef DEBUG #define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str)) #else diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c index 41127d2705..ca8ca4a19b 100755 --- a/bacula/src/console/conio.c +++ b/bacula/src/console/conio.c @@ -723,9 +723,9 @@ putline(char *newl, int newlen) nptr = (struct lstr *)((char *)lptr + newlen + PHDRL); /* Appropriate byte alignment - normally 2 byte, but on sparc we need 4 byte alignment, so we always do 4 */ - if (((unsigned)nptr & 3) != 0) { /* test four byte alignment */ + if (((long unsigned)nptr & 3) != 0) { /* test four byte alignment */ p = (char *)nptr; - nptr = (struct lstr *)((((unsigned) p) & ~3) + 4); + nptr = (struct lstr *)((((long unsigned) p) & ~3) + 4); } nptr->len = lptr->len - ((char *)nptr - (char *)lptr); lptr->len -= nptr->len; diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index c616b58736..88f89d1627 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -112,7 +112,7 @@ static bool is_volume_selected(RBSR_FINDEX *fi, static void print_findex(UAContext *ua, RBSR_FINDEX *fi) { - bsendmsg(ua, "fi=0x%x\n", (unsigned)fi); + bsendmsg(ua, "fi=0x%lx\n", fi); for ( ; fi; fi=fi->next) { if (fi->findex == fi->findex2) { bsendmsg(ua, "FileIndex=%d\n", fi->findex); diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 2e3843a2b3..326999d84d 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -494,7 +494,7 @@ Without that I don't know who I am :-(\n"), configfile); job->hdr.name, job_items[i].name, *def_svalue, i, offset); svalue = (char **)((char *)job + offset); if (*svalue) { - Dmsg1(000, "Hey something is wrong. p=0x%u\n", (unsigned)*svalue); + Dmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue); } *svalue = bstrdup(*def_svalue); set_bit(i, job->hdr.item_present); @@ -504,7 +504,7 @@ Without that I don't know who I am :-(\n"), configfile); job->hdr.name, job_items[i].name, i, offset); svalue = (char **)((char *)job + offset); if (*svalue) { - Dmsg1(000, "Hey something is wrong. p=0x%u\n", (unsigned)*svalue); + Dmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue); } *svalue = *def_svalue; set_bit(i, job->hdr.item_present); diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index ff76230b9c..1dd970381e 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -77,6 +77,8 @@ static RES_ITEM options_items[] = { {"readfifo", store_opts, NULL, 0, 0, 0}, {"replace", store_opts, NULL, 0, 0, 0}, {"portable", store_opts, NULL, 0, 0, 0}, + {"mtimeonly", store_opts, NULL, 0, 0, 0}, + {"keepatime", store_opts, NULL, 0, 0, 0}, {"regex", store_regex, NULL, 0, 0, 0}, {"base", store_base, NULL, 0, 0, 0}, {"wild", store_wild, NULL, 0, 0, 0}, diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index f29491699f..e095f2b5e7 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -612,6 +612,61 @@ static findFOPTS *start_options(FF_PKT *ff) } +/* + * Add fname to include/exclude fileset list. First check for + * | and < and if necessary perform command. + */ +static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *fileset) +{ + char *p; + BPIPE *bpipe; + POOLMEM *fn; + FILE *ffd; + char buf[1000]; + int stat; + + p = (char *)fname; + switch (*p) { + case '|': + p++; /* skip over | */ + fn = get_pool_memory(PM_FNAME); + fn = edit_job_codes(jcr, fn, p, ""); + bpipe = open_bpipe(fn, 0, "r"); + free_pool_memory(fn); + if (!bpipe) { + Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), + p, strerror(errno)); + return; + } + while (fgets(buf, sizeof(buf), bpipe->rfd)) { + strip_trailing_junk(buf); + fileset->incexe->name_list.append(bstrdup(buf)); + } + if ((stat=close_bpipe(bpipe)) != 0) { + Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), + p, stat, strerror(errno)); + return; + } + break; + case '<': + p++; /* skip over < */ + if ((ffd = fopen(p, "r")) == NULL) { + Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), + p, strerror(errno)); + return; + } + while (fgets(buf, sizeof(buf), ffd)) { + strip_trailing_junk(buf); + fileset->incexe->name_list.append(bstrdup(buf)); + } + fclose(ffd); + break; + default: + fileset->incexe->name_list.append(bstrdup(fname)); + break; + } +} + static void add_fileset(JCR *jcr, const char *item) { @@ -620,6 +675,7 @@ static void add_fileset(JCR *jcr, const char *item) int state = fileset->state; findFOPTS *current_opts; + Dmsg1(100, "%s\n", item); int code = item[0]; if (item[1] == ' ') { /* If string follows */ item += 2; /* point to string */ @@ -649,9 +705,9 @@ static void add_fileset(JCR *jcr, const char *item) state = state_none; break; case 'F': - /* File item */ + /* File item to either include/include list */ state = state_include; - fileset->incexe->name_list.append(bstrdup(item)); + add_file_to_fileset(jcr, item, fileset); break; case 'R': current_opts = start_options(ff); @@ -1043,6 +1099,8 @@ static int storage_cmd(JCR *jcr) if (sd == NULL) { Jmsg(jcr, M_FATAL, 0, _("Failed to connect to Storage daemon: %s:%d\n"), jcr->stored_addr, stored_port); + Dmsg2(100, "Failed to connect to Storage daemon: %s:%d\n", + jcr->stored_addr, stored_port); return 0; } diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 1455ce11bd..7f06d8bdcd 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -172,6 +172,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) Dmsg1(50, "Create file: %s\n", attr->ofname); if (is_bopen(bfd)) { Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid); + bclose(bfd); } if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) { Jmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"), diff --git a/bacula/src/lib/cram-md5.c b/bacula/src/lib/cram-md5.c index c567e8621b..1be399bba0 100644 --- a/bacula/src/lib/cram-md5.c +++ b/bacula/src/lib/cram-md5.c @@ -49,15 +49,15 @@ int cram_md5_auth(BSOCK *bs, char *password, int ssl_need) bstrncpy(host, my_name, sizeof(host)); } bsnprintf(chal, sizeof(chal), "<%u.%u@%s>", (uint32_t)random(), (uint32_t)time(NULL), host); + Dmsg2(100, "send: auth cram-md5 %s ssl=%d\n", chal, ssl_need); if (!bnet_fsend(bs, "auth cram-md5 %s ssl=%d\n", chal, ssl_need)) { + Dmsg0(100, "Send challenge error.\n"); return 0; } if (!bnet_ssl_client(bs, password, ssl_need)) { return 0; } - - Dmsg1(99, "sent challenge: %s", bs->msg); if (bnet_wait_data(bs, 180) <= 0 || bnet_recv(bs) <= 0) { bmicrosleep(5, 0); return 0; @@ -65,8 +65,11 @@ int cram_md5_auth(BSOCK *bs, char *password, int ssl_need) hmac_md5((uint8_t *)chal, strlen(chal), (uint8_t *)password, strlen(password), hmac); bin_to_base64(host, (char *)hmac, 16); ok = strcmp(mp_chr(bs->msg), host) == 0; - Dmsg3(99, "Authenticate %s: wanted %s, got %s\n", - ok ? "OK" : "NOT OK", host, bs->msg); + if (ok) { + Dmsg0(99, "Authenticate OK\n"); + } else { + Dmsg2(99, "Authenticate NOT OK: wanted %s, got %s\n", host, bs->msg); + } if (ok) { bnet_fsend(bs, "1000 OK auth\n"); } else { @@ -93,11 +96,12 @@ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need) bmicrosleep(5, 0); return 0; } - if (sscanf(mp_chr(bs->msg), "auth cram-md5 %s ssl=%d\n", chal, &ssl_has) != 2) { + Dmsg1(100, "cram-get: %s", bs->msg); + if (sscanf(bs->msg, "auth cram-md5 %s ssl=%d\n", chal, &ssl_has) != 2) { ssl_has = BNET_SSL_NONE; - if (sscanf(mp_chr(bs->msg), "auth cram-md5 %s\n", chal) != 1) { + if (sscanf(bs->msg, "auth cram-md5 %s\n", chal) != 1) { + Dmsg1(100, "Cannot scan challenge: %s", bs->msg); bnet_fsend(bs, "1999 Authorization failed.\n"); - Dmsg1(100, "Cannot scan challenge: %s\n", bs->msg); bmicrosleep(5, 0); return 0; } diff --git a/bacula/src/lib/daemon.c b/bacula/src/lib/daemon.c index 38b029987c..678a5e07f3 100644 --- a/bacula/src/lib/daemon.c +++ b/bacula/src/lib/daemon.c @@ -79,5 +79,23 @@ daemon_start() umask(oldmask); Dmsg0(200, "Exit daemon_start\n"); + + /* + * Make sure we have fd's 0, 1, 2 open + * If we don't do this one of our sockets may open + * there and if we then use stdout, it could + * send total garbage to our socket. + * + */ + int fd; + fd = open("/dev/null", O_RDONLY, 0644); + if (fd > 2) { + close(fd); + } else { + for(i=1; fd + i <= 2; i++) { + dup2(fd, fd+i); + } + } + #endif /* HAVE_CYGWIN */ } diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 3fa47ecede..931659b865 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -185,6 +185,8 @@ int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, char **argk, char **argv, int max_args); void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl, POOLMEM **file, int *fnl); +int bsscanf(const char *buf, const char *fmt, ...); + /* util.c */ int is_buf_zero (char *buf, int len); diff --git a/bacula/src/lib/scan.c b/bacula/src/lib/scan.c index c77917b586..3c42135e2c 100644 --- a/bacula/src/lib/scan.c +++ b/bacula/src/lib/scan.c @@ -291,3 +291,196 @@ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl, Dmsg2(200, "pnl=%d fnl=%d\n", *pnl, *fnl); Dmsg3(200, "split fname=%s path=%s file=%s\n", fname, *path, *file); } + +/* + * Extremely simple sscanf. Handles only %(u,d,ld,lu,lld,llu,c,nns) + */ +const int BIG = 1000; +int bsscanf(const char *buf, const char *fmt, ...) +{ + va_list ap; + int count = 0; + void *vp; + char *cp; + int l = 0; + int max_len = BIG; + uint64_t value; + bool error = false; + + va_start(ap, fmt); + while (*fmt && !error) { +// Dmsg1(000, "fmt=%c\n", *fmt); + if (*fmt == '%') { + fmt++; +// Dmsg1(000, "Got %% nxt=%c\n", *fmt); +switch_top: + switch (*fmt++) { + case 'u': + case 'd': + value = 0; + while (B_ISDIGIT(*buf)) { + value = B_TIMES10(value) + *buf++ - '0'; + } + vp = (void *)va_arg(ap, void *); +// Dmsg2(000, "val=%lld at 0x%lx\n", value, (long unsigned)vp); + if (l < 2) { + *((uint32_t *)vp) = (uint32_t)value; +// Dmsg0(000, "Store 32 bit int\n"); + } else { + *((uint64_t *)vp) = (uint64_t)value; +// Dmsg0(000, "Store 64 bit int\n"); + } + count++; + l = 0; + break; + case 'l': +// Dmsg0(000, "got l\n"); + l = 1; + if (*fmt == 'l') { + l++; + fmt++; + } + if (*fmt == 'd' || *fmt == 'u') { + goto switch_top; + } +// Dmsg1(000, "fmt=%c !=d,u\n", *fmt); + error = true; + break; + case 'q': + l = 2; + if (*fmt == 'd' || *fmt == 'u') { + goto switch_top; + } +// Dmsg1(000, "fmt=%c !=d,u\n", *fmt); + error = true; + break; + case 's': +// Dmsg1(000, "Store string max_len=%d\n", max_len); + cp = (char *)va_arg(ap, char *); + while (*buf && !B_ISSPACE(*buf) && max_len-- > 0) { + *cp++ = *buf++; + } + *cp = 0; + count++; + max_len = BIG; + break; + case 'c': + cp = (char *)va_arg(ap, char *); + *cp = *buf++; + count++; + break; + case '%': + if (*buf++ != '%') { + error = true; + } + break; + default: + fmt--; + max_len = 0; + while (B_ISDIGIT(*fmt)) { + max_len = B_TIMES10(max_len) + *fmt++ - '0'; + } +// Dmsg1(000, "Default max_len=%d\n", max_len); + if (*fmt == 's') { + goto switch_top; + } +// Dmsg1(000, "Default c=%c\n", *fmt); + error = true; + break; /* error: unknown format */ + } + continue; + + /* White space eats zero or more whitespace */ + } else if (B_ISSPACE(*fmt)) { + fmt++; + while (B_ISSPACE(*buf)) { + buf++; + } + /* Plain text must match */ + } else if (*buf++ != *fmt++) { +// Dmsg2(000, "Mismatch buf=%c fmt=%c\n", *--buf, *--fmt); + error = true; + } + } + va_end(ap); +// Dmsg2(000, "Error=%d count=%d\n", error, count); + if (error) { + count = -1; + } + return count; +} + +#ifdef TEST_PROGRAM +int main(int argc, char *argv[]) +{ + char buf[100]; + uint32_t val32; + uint64_t val64; + uint32_t FirstIndex, LastIndex, StartFile, EndFile, StartBlock, EndBlock; + char Job[200]; + int cnt; + char *helloreq= "Hello *UserAgent* calling\n"; + char *hello = "Hello %127s calling\n"; + char *catreq = +"CatReq Job=NightlySave.2004-06-11_19.11.32 CreateJobMedia FirstIndex=1 LastIndex=114 StartFile=0 EndFile=0 StartBlock=208 EndBlock=2903248"; +static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia " + "FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u " + "StartBlock=%u EndBlock=%u\n"; +static char OK_media[] = "1000 OK VolName=%127s VolJobs=%u VolFiles=%u" + " VolBlocks=%u VolBytes=%" lld " VolMounts=%u VolErrors=%u VolWrites=%u" + " MaxVolBytes=%" lld " VolCapacityBytes=%" lld " VolStatus=%20s" + " Slot=%d MaxVolJobs=%u MaxVolFiles=%u InChanger=%d" + " VolReadTime=%" lld " VolWriteTime=%" lld; + char *media = +"1000 OK VolName=TestVolume001 VolJobs=0 VolFiles=0 VolBlocks=0 VolBytes=1 VolMounts=0 VolErrors=0 VolWrites=0 MaxVolBytes=0 VolCapacityBytes=0 VolStatus=Append Slot=0 MaxVolJobs=0 MaxVolFiles=0 InChanger=1 VolReadTime=0 VolWriteTime=0"; +struct VOLUME_CAT_INFO { + /* Media info for the current Volume */ + uint32_t VolCatJobs; /* number of jobs on this Volume */ + uint32_t VolCatFiles; /* Number of files */ + uint32_t VolCatBlocks; /* Number of blocks */ + uint64_t VolCatBytes; /* Number of bytes written */ + uint32_t VolCatMounts; /* Number of mounts this volume */ + uint32_t VolCatErrors; /* Number of errors this volume */ + uint32_t VolCatWrites; /* Number of writes this volume */ + uint32_t VolCatReads; /* Number of reads this volume */ + uint64_t VolCatRBytes; /* Number of bytes read */ + uint32_t VolCatRecycles; /* Number of recycles this volume */ + int32_t Slot; /* Slot in changer */ + bool InChanger; /* Set if vol in current magazine */ + uint32_t VolCatMaxJobs; /* Maximum Jobs to write to volume */ + uint32_t VolCatMaxFiles; /* Maximum files to write to volume */ + uint64_t VolCatMaxBytes; /* Max bytes to write to volume */ + uint64_t VolCatCapacityBytes; /* capacity estimate */ + uint64_t VolReadTime; /* time spent reading */ + uint64_t VolWriteTime; /* time spent writing this Volume */ + char VolCatStatus[20]; /* Volume status */ + char VolCatName[MAX_NAME_LENGTH]; /* Desired volume to mount */ +}; + struct VOLUME_CAT_INFO vol; + +#ifdef xxx + bsscanf("Hello_world 123 1234", "%120s %ld %lld", buf, &val32, &val64); + printf("%s %d %lld\n", buf, val32, val64); + + *Job=0; + cnt = bsscanf(catreq, Create_job_media, &Job, + &FirstIndex, &LastIndex, &StartFile, &EndFile, + &StartBlock, &EndBlock); + printf("cnt=%d Job=%s\n", cnt, Job); + cnt = bsscanf(helloreq, hello, &Job); + printf("cnt=%d Agent=%s\n", cnt, Job); +#endif + cnt = bsscanf(media, OK_media, + vol.VolCatName, + &vol.VolCatJobs, &vol.VolCatFiles, + &vol.VolCatBlocks, &vol.VolCatBytes, + &vol.VolCatMounts, &vol.VolCatErrors, + &vol.VolCatWrites, &vol.VolCatMaxBytes, + &vol.VolCatCapacityBytes, vol.VolCatStatus, + &vol.Slot, &vol.VolCatMaxJobs, &vol.VolCatMaxFiles, + &vol.InChanger, &vol.VolReadTime, &vol.VolWriteTime); + printf("cnt=%d Vol=%s\n", cnt, vol.VolCatName); + +} + +#endif diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 80e6ce3af8..843490575a 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -78,7 +78,7 @@ DCR *acquire_device_for_read(JCR *jcr) bool tape_previously_mounted; bool tape_initially_mounted; VOL_LIST *vol; - int autochanger = 0; + bool try_autochanger = true; int i; DCR *dcr = jcr->dcr; DEVICE *dev; @@ -175,13 +175,13 @@ default_path: Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg); } /* Call autochanger only once unless ask_sysop called */ - if (!autochanger) { + if (try_autochanger) { int stat; Dmsg2(200, "calling autoload Vol=%s Slot=%d\n", jcr->VolumeName, jcr->VolCatInfo.Slot); stat = autoload_device(jcr, dev, 0, NULL); if (stat > 0) { - autochanger = 1; + try_autochanger = false; continue; } } @@ -190,7 +190,7 @@ default_path: if (!dir_ask_sysop_to_mount_volume(jcr, dev)) { goto get_out; /* error return */ } - autochanger = 0; /* permit using autochanger again */ + try_autochanger = true; /* permit using autochanger again */ continue; /* try reading again */ } /* end switch */ break; diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 469d605510..926e0db90c 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -79,6 +79,7 @@ static int do_get_volume_info(JCR *jcr) DCR *dcr = jcr->dcr; VOLUME_CAT_INFO vol; int n; + int InChanger; jcr->VolumeName[0] = 0; /* No volume */ dcr->VolumeName[0] = 0; /* No volume */ @@ -96,12 +97,13 @@ static int do_get_volume_info(JCR *jcr) &vol.VolCatWrites, &vol.VolCatMaxBytes, &vol.VolCatCapacityBytes, vol.VolCatStatus, &vol.Slot, &vol.VolCatMaxJobs, &vol.VolCatMaxFiles, - &vol.InChanger, &vol.VolReadTime, &vol.VolWriteTime); + &InChanger, &vol.VolReadTime, &vol.VolWriteTime); if (n != 17) { Dmsg2(100, "Bad response from Dir fields=%d: %s\n", n, dir->msg); Mmsg(&jcr->errmsg, _("Error getting Volume info: %s\n"), dir->msg); return 0; } + vol.InChanger = InChanger; /* bool in structure */ unbash_spaces(vol.VolCatName); pm_strcpy(&jcr->VolumeName, vol.VolCatName); /* set desired VolumeName */ bstrncpy(dcr->VolumeName, vol.VolCatName, sizeof(dcr->VolumeName)); @@ -195,7 +197,8 @@ int dir_find_next_appendable_volume(JCR *jcr) /* * After writing a Volume, send the updated statistics - * back to the director. + * back to the director. The information comes from the + * dev record. */ int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label) { @@ -203,6 +206,7 @@ int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label) time_t LastWritten = time(NULL); char ed1[50], ed2[50], ed3[50], ed4[50]; VOLUME_CAT_INFO *vol = &dev->VolCatInfo; + int InChanger; if (vol->VolCatName[0] == 0) { Jmsg0(jcr, M_ERROR, 0, _("NULL Volume name. This shouldn't happen!!!\n")); @@ -224,13 +228,14 @@ int dir_update_volume_info(JCR *jcr, DEVICE *dev, int label) vol->VolCatBytes = 1; /* indicates tape labeled */ } bash_spaces(vol->VolCatName); + InChanger = vol->InChanger; bnet_fsend(dir, Update_media, jcr->Job, vol->VolCatName, vol->VolCatJobs, vol->VolCatFiles, vol->VolCatBlocks, edit_uint64(vol->VolCatBytes, ed1), vol->VolCatMounts, vol->VolCatErrors, vol->VolCatWrites, edit_uint64(vol->VolCatMaxBytes, ed2), LastWritten, vol->VolCatStatus, vol->Slot, label, - vol->InChanger, + InChanger, /* bool in structure */ edit_uint64(vol->VolReadTime, ed3), edit_uint64(vol->VolWriteTime, ed4) ); @@ -468,6 +473,7 @@ int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev) return 0; } +#ifdef needed /* * If we have a valid volume name and we are not * removable media, return now, or if we have a @@ -478,6 +484,7 @@ int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev) Dmsg0(100, "Return 1 from mount without wait.\n"); return 1; } +#endif if (!dev->poll) { msg = _("Please mount"); diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index e7dbf04a26..0d318bc1b3 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -241,8 +241,8 @@ struct DCR { uint32_t StartFile; /* Start write file */ uint32_t StartBlock; /* Start write block */ uint32_t EndBlock; /* Ending block written */ - uint64_t spool_size; /* Current spool size */ - uint64_t max_spool_size; /* Max job spool size */ + int64_t spool_size; /* Current spool size */ + int64_t max_spool_size; /* Max job spool size */ char VolumeName[MAX_NAME_LENGTH]; /* Volume name */ VOLUME_CAT_INFO VolCatInfo; /* Catalog info for desired volume */ }; diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index 574e9d89ec..241855ef55 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -142,11 +142,13 @@ void *connection_request(void *arg) * See if this is a File daemon connection. If so * call FD handler. */ - if (sscanf(bs->msg, "Hello Start Job %127s calling\n", name) == 1) { + Dmsg1(110, "Conn: %s", bs->msg); + if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) { handle_filed_connection(bs, name); return NULL; } + Dmsg0(110, "Start Dir Job\n"); jcr = new_jcr(sizeof(JCR), stored_free_jcr); /* create Job Control Record */ jcr->dir_bsock = bs; /* save Director bsock */ jcr->dir_bsock->jcr = jcr; diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index c04c3d3b13..9451ea3735 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -139,7 +139,7 @@ int job_cmd(JCR *jcr) set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } - jcr->authenticated = FALSE; + jcr->authenticated = false; /* * Pass back an authorization key for the File daemon @@ -202,6 +202,7 @@ void handle_filed_connection(BSOCK *fd, char *job_name) bmicrosleep(0, 50000); /* wait 50 millisecs */ if (!(jcr=get_jcr_by_full_name(job_name))) { Jmsg1(NULL, M_FATAL, 0, _("Job name not found: %s\n"), job_name); + Dmsg1(100, "Job name not found: %s\n", job_name); return; } diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index db0ce23518..5e0a9b9109 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -96,12 +96,13 @@ int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) record = new_record(); Dmsg0(90, "Big if statement in read_volume_label\n"); if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) { - Mmsg(&jcr->errmsg, _("Volume on %s is not a Bacula labeled Volume, \ -because:\n %s"), dev_name(dev), strerror_dev(dev)); + Mmsg(&jcr->errmsg, _("Requested Volume \"%s\" on %s is not a Bacula " + "labeled Volume, because: ERR=%s"), NPRT(VolName), dev_name(dev), + strerror_dev(dev)); } else if (!read_record_from_block(block, record)) { Mmsg(&jcr->errmsg, _("Could not read Volume label from block.\n")); } else if (!unser_volume_label(dev, record)) { - Mmsg(&jcr->errmsg, _("Could not unserialize Volume label: %s\n"), + Mmsg(&jcr->errmsg, _("Could not unserialize Volume label: ERR=%s\n"), strerror_dev(dev)); } else if (strcmp(dev->VolHdr.Id, BaculaId) != 0 && strcmp(dev->VolHdr.Id, OldBaculaId) != 0) { diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 5d411b743e..de9d151826 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -129,6 +129,10 @@ mount_next_vol: if (!release && dev_is_tape(dev) && dev_cap(dev, CAP_AUTOMOUNT)) { ask = false; /* don't ask SYSOP this time */ } + /* Don't ask if not removable */ + if (!dev_cap(dev, CAP_REM)) { + ask = false; + } Dmsg2(100, "Ask=%d autochanger=%d\n", ask, autochanger); release = true; /* release next time if we "recurse" */ @@ -181,6 +185,17 @@ read_volume: case VOL_NAME_ERROR: VOLUME_CAT_INFO VolCatInfo; + /* If not removable, Volume is broken */ + if (!dev_cap(dev, CAP_REM)) { + bstrncpy(jcr->VolCatInfo.VolCatStatus, "Error", + sizeof(jcr->VolCatInfo.VolCatStatus)); + memcpy(&dev->VolCatInfo, &jcr->VolCatInfo, sizeof(dev->VolCatInfo)); + dir_update_volume_info(jcr, dev, 1); /* indicate tape labeled */ + Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s. Volume marked in error.\n"), + jcr->VolumeName, dev_name(dev)); + goto mount_next_vol; + } + Dmsg1(100, "Vol NAME Error Name=%s\n", jcr->VolumeName); /* If polling and got a previous bad name, ignore it */ if (dev->poll && strcmp(dev->BadVolName, dev->VolHdr.VolName) == 0) { @@ -247,6 +262,16 @@ read_volume: jcr->VolumeName, dev_name(dev)); goto read_volume; /* read label we just wrote */ } + /* If not removable, Volume is broken */ + if (!dev_cap(dev, CAP_REM)) { + bstrncpy(jcr->VolCatInfo.VolCatStatus, "Error", + sizeof(jcr->VolCatInfo.VolCatStatus)); + memcpy(&dev->VolCatInfo, &jcr->VolCatInfo, sizeof(dev->VolCatInfo)); + dir_update_volume_info(jcr, dev, 1); /* indicate tape labeled */ + Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s. Volume marked in error.\n"), + jcr->VolumeName, dev_name(dev)); + goto mount_next_vol; + } /* NOTE! Fall-through wanted. */ case VOL_NO_MEDIA: default: diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index 80f16f808d..ddc449acde 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -42,9 +42,9 @@ struct spool_stats_t { uint32_t attr_jobs; uint32_t total_data_jobs; /* total jobs to have spooled data */ uint32_t total_attr_jobs; - uint64_t max_data_size; /* max data size */ - uint64_t max_attr_size; - uint64_t data_size; /* current data size (all jobs running) */ + int64_t max_data_size; /* max data size */ + int64_t max_attr_size; + int64_t data_size; /* current data size (all jobs running) */ int64_t attr_size; }; diff --git a/bacula/src/version.h b/bacula/src/version.h index a27bd1a7f9..43844756f3 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.34.4" #define VSTRING "1" -#define BDATE "09 June 2004" -#define LSMDATE "09Jun04" +#define BDATE "12 June 2004" +#define LSMDATE "12Jun04" /* Debug flags */ #undef DEBUG