The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
static bool changer_cmd(JCR *sjcr);
static bool do_label(JCR *jcr, int relabel);
static DCR *find_device(JCR *jcr, POOL_MEM &dev_name, int drive);
static bool changer_cmd(JCR *sjcr);
static bool do_label(JCR *jcr, int relabel);
static DCR *find_device(JCR *jcr, POOL_MEM &dev_name, int drive);
-static void read_volume_label(JCR *jcr, DEVICE *dev, int Slot);
+static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot);
static void label_volume_if_ok(DCR *dcr, char *oldname,
char *newname, char *poolname,
int Slot, int relabel);
static void label_volume_if_ok(DCR *dcr, char *oldname,
char *newname, char *poolname,
int Slot, int relabel);
-static bool try_autoload_device(JCR *jcr, int slot, const char *VolName);
+static bool try_autoload_device(JCR *jcr, DCR *dcr, int slot, const char *VolName);
Emsg1(M_ERROR, 0, _("Invalid connection. Len=%d\n"), bs->msglen);
Emsg1(M_ERROR, 0, _("Invalid connection. Len=%d\n"), bs->msglen);
if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {
Dmsg0(110, "Got a FD connection\n");
handle_filed_connection(bs, name);
if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {
Dmsg0(110, "Got a FD connection\n");
handle_filed_connection(bs, name);
/* Initialize FD start condition variable */
int errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
if (errstat != 0) {
/* Initialize FD start condition variable */
int errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
if (errstat != 0) {
- Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), strerror(errstat));
+ berrno be;
+ Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat));
if (strncmp(cmds[i].cmd, bs->msg, strlen(cmds[i].cmd)) == 0) {
if ((!cmds[i].monitoraccess) && (jcr->director->monitor)) {
Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd);
if (strncmp(cmds[i].cmd, bs->msg, strlen(cmds[i].cmd)) == 0) {
if ((!cmds[i].monitoraccess) && (jcr->director->monitor)) {
Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd);
break;
}
}
bail_out:
generate_daemon_event(jcr, "JobEnd");
dequeue_messages(jcr); /* send any queued messages */
break;
}
}
bail_out:
generate_daemon_event(jcr, "JobEnd");
dequeue_messages(jcr); /* send any queued messages */
Dmsg1(10, "setdebug_cmd: %s", dir->msg);
if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) {
Dmsg1(10, "setdebug_cmd: %s", dir->msg);
if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) {
if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
if (!(jcr=get_jcr_by_full_name(Job))) {
if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
if (!(jcr=get_jcr_by_full_name(Job))) {
oldStatus = jcr->JobStatus;
set_jcr_job_status(jcr, JS_Canceled);
if (!jcr->authenticated && oldStatus == JS_WaitFD) {
pthread_cond_signal(&jcr->job_start_wait); /* wake waiting thread */
}
oldStatus = jcr->JobStatus;
set_jcr_job_status(jcr, JS_Canceled);
if (!jcr->authenticated && oldStatus == JS_WaitFD) {
pthread_cond_signal(&jcr->job_start_wait); /* wake waiting thread */
}
pthread_cond_broadcast(&wait_device_release);
}
Jmsg(jcr, M_INFO, 0, _("Job %s marked to be canceled.\n"), jcr->Job);
pthread_cond_broadcast(&wait_device_release);
}
Jmsg(jcr, M_INFO, 0, _("Job %s marked to be canceled.\n"), jcr->Job);
}
} else {
/* NB dir->msg gets clobbered in bnet_fsend, so save command */
pm_strcpy(jcr->errmsg, dir->msg);
}
} else {
/* NB dir->msg gets clobbered in bnet_fsend, so save command */
pm_strcpy(jcr->errmsg, dir->msg);
- if (!try_autoload_device(dcr->jcr, slot, volname)) {
+ if (!try_autoload_device(dcr->jcr, dcr, slot, volname)) {
/* Set old volume name for open if relabeling */
bstrncpy(dcr->VolCatInfo.VolCatName, volname, sizeof(dcr->VolCatInfo.VolCatName));
if (dev->open(dcr, mode) < 0) {
/* Set old volume name for open if relabeling */
bstrncpy(dcr->VolCatInfo.VolCatName, volname, sizeof(dcr->VolCatInfo.VolCatName));
if (dev->open(dcr, mode) < 0) {
- bnet_fsend(dir, _("3910 Unable to open device %s: ERR=%s\n"),
- dev->print_name(), dev->strerror());
+ dir->fsend(_("3910 Unable to open device %s: ERR=%s\n"),
+ dev->print_name(), dev->bstrerror());
/* Relabel request. If oldname matches, continue */
if (strcmp(oldname, dev->VolHdr.VolumeName) != 0) {
/* Relabel request. If oldname matches, continue */
if (strcmp(oldname, dev->VolHdr.VolumeName) != 0) {
case VOL_NO_LABEL:
if (!write_new_volume_label_to_dev(dcr, newname, poolname,
relabel, true /* write dvd now */)) {
case VOL_NO_LABEL:
if (!write_new_volume_label_to_dev(dcr, newname, poolname,
relabel, true /* write dvd now */)) {
break;
}
bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
/* The following 3000 OK label. string is scanned in ua_label.c */
break;
}
bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
/* The following 3000 OK label. string is scanned in ua_label.c */
edit_uint64(dev->VolCatInfo.VolCatBytes, ed1),
dev->is_dvd()?1:0, newname, dev->print_name());
break;
case VOL_NO_MEDIA:
edit_uint64(dev->VolCatInfo.VolCatBytes, ed1),
dev->is_dvd()?1:0, newname, dev->print_name());
break;
case VOL_NO_MEDIA:
unbash_spaces(devname);
foreach_res(device, R_DEVICE) {
/* Find resource, and make sure we were able to open it */
unbash_spaces(devname);
foreach_res(device, R_DEVICE) {
/* Find resource, and make sure we were able to open it */
if (!found) {
foreach_res(changer, R_AUTOCHANGER) {
/* Find resource, and make sure we were able to open it */
if (!found) {
foreach_res(changer, R_AUTOCHANGER) {
/* Find resource, and make sure we were able to open it */
/* Try each device in this AutoChanger */
foreach_alist(device, changer->device) {
Dmsg1(100, "Try changer device %s\n", device->hdr.name);
/* Try each device in this AutoChanger */
foreach_alist(device, changer->device) {
Dmsg1(100, "Try changer device %s\n", device->hdr.name);
/* Someone is waiting, wake him */
Dmsg0(100, "Waiting for mount. Attempting to wake thread\n");
dev->set_blocked(BST_MOUNT);
/* Someone is waiting, wake him */
Dmsg0(100, "Waiting for mount. Attempting to wake thread\n");
dev->set_blocked(BST_MOUNT);
dev->print_name());
pthread_cond_broadcast(&dev->wait_next_vol);
Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)dcr->jcr->JobId);
dev->print_name());
pthread_cond_broadcast(&dev->wait_next_vol);
Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)dcr->jcr->JobId);
}
/* We freed the device, so reopen it and wake any waiting threads */
if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
}
/* We freed the device, so reopen it and wake any waiting threads */
if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
dev->bstrerror());
if (dev->blocked() == BST_UNMOUNTED) {
/* We blocked the device, so unblock it */
dev->bstrerror());
if (dev->blocked() == BST_UNMOUNTED) {
/* We blocked the device, so unblock it */
"If this is not a blank tape, try unmounting and remounting the Volume.\n"),
dev->print_name());
}
} else if (dev->is_tape()) {
if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
"If this is not a blank tape, try unmounting and remounting the Volume.\n"),
dev->print_name());
}
} else if (dev->is_tape()) {
if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
- if (dev->is_dvd() && !dev->unmount(0)) {
- bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+ if (dev->is_unmountable() && !dev->unmount(0)) {
+ dir->fsend(_("3907 %s"), dev->bstrerror());
- if (dev->is_dvd() && !dev->unmount(0)) {
- bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+ if (dev->is_unmountable() && !dev->unmount(0)) {
+ dir->fsend(_("3907 %s"), dev->bstrerror());
}
} else {
/* NB dir->msg gets clobbered in bnet_fsend, so save command */
pm_strcpy(jcr->errmsg, dir->msg);
}
} else {
/* NB dir->msg gets clobbered in bnet_fsend, so save command */
pm_strcpy(jcr->errmsg, dir->msg);
unload_autochanger(dcr, -1);
}
Dmsg0(90, "Device already released\n");
unload_autochanger(dcr, -1);
}
Dmsg0(90, "Device already released\n");
dev->print_name());
} else if (dev->blocked() == BST_WAITING_FOR_SYSOP) {
Dmsg2(90, "%d waiter dev_block=%d.\n", dev->num_waiting,
dev->blocked());
unload_autochanger(dcr, -1);
dev->print_name());
} else if (dev->blocked() == BST_WAITING_FOR_SYSOP) {
Dmsg2(90, "%d waiter dev_block=%d.\n", dev->num_waiting,
dev->blocked());
unload_autochanger(dcr, -1);
dev->print_name());
} else if (dev->blocked() == BST_UNMOUNTED_WAITING_FOR_SYSOP) {
Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
dev->blocked());
dev->print_name());
} else if (dev->blocked() == BST_UNMOUNTED_WAITING_FOR_SYSOP) {
Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
dev->blocked());
} else { /* device not being used */
Dmsg0(90, "Device not in use, releaseing\n");
unload_autochanger(dcr, -1);
} else { /* device not being used */
Dmsg0(90, "Device not in use, releaseing\n");
unload_autochanger(dcr, -1);
}
} else {
/* NB dir->msg gets clobbered in bnet_fsend, so save command */
pm_strcpy(jcr->errmsg, dir->msg);
}
} else {
/* NB dir->msg gets clobbered in bnet_fsend, so save command */
pm_strcpy(jcr->errmsg, dir->msg);
dev->print_name());
/* Under certain "safe" conditions, we can steal the lock */
} else if (safe_cmd || !dev->is_open() || dev->can_steal_lock()) {
dev->print_name());
/* Under certain "safe" conditions, we can steal the lock */
} else if (safe_cmd || !dev->is_open() || dev->can_steal_lock()) {
}
} else { /* error on scanf */
pm_strcpy(jcr->errmsg, dir->msg);
}
} else { /* error on scanf */
pm_strcpy(jcr->errmsg, dir->msg);
dev->close();
/* Under certain "safe" conditions, we can steal the lock */
} else if (dev->can_steal_lock()) {
dev->close();
/* Under certain "safe" conditions, we can steal the lock */
} else if (dev->can_steal_lock()) {
} else if (dev->is_busy() || dev->is_blocked()) {
send_dir_busy_message(dir, dev);
} else { /* device not being used */
} else if (dev->is_busy() || dev->is_blocked()) {
send_dir_busy_message(dir, dev);
} else { /* device not being used */
-static void read_volume_label(JCR *jcr, DEVICE *dev, int Slot)
+static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot)
switch (read_dev_volume_label(dcr)) {
case VOL_OK:
/* DO NOT add quotes around the Volume name. It is scanned in the DIR */
switch (read_dev_volume_label(dcr)) {
case VOL_OK:
/* DO NOT add quotes around the Volume name. It is scanned in the DIR */
- bnet_fsend(dir, _("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
+ dir->fsend(_("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
-static bool try_autoload_device(JCR *jcr, int slot, const char *VolName)
+static bool try_autoload_device(JCR *jcr, DCR *dcr, int slot, const char *VolName)
BSOCK *dir = jcr->dir_bsock;
bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));
BSOCK *dir = jcr->dir_bsock;
bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));