/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
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
+ modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
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
+ You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*
* Split from job.c and acquire.c June 2005
*
- * Version $Id$
- *
*/
#include "bacula.h"
static int reserve_device(RCTX &rctx);
static bool reserve_device_for_read(DCR *dcr);
static bool reserve_device_for_append(DCR *dcr, RCTX &rctx);
-static bool use_storage_cmd(JCR *jcr);
+static bool use_device_cmd(JCR *jcr);
static void queue_reserve_message(JCR *jcr);
static void pop_reserve_messages(JCR *jcr);
//void switch_device(DCR *dcr, DEVICE *dev);
/*
* Get the device, media, and pool information
*/
- if (!use_storage_cmd(jcr)) {
- set_jcr_job_status(jcr, JS_ErrorTerminated);
+ if (!use_device_cmd(jcr)) {
+ jcr->setJobStatus(JS_ErrorTerminated);
memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
return false;
}
}
}
unlock_volumes();
+ generate_plugin_event(jcr, bsdEventDeviceClose, this);
dev->dunlock();
}
* use device=bbb
*
*/
-static bool use_storage_cmd(JCR *jcr)
+static bool use_device_cmd(JCR *jcr)
{
POOL_MEM store_name, dev_name, media_type, pool_name, pool_type;
BSOCK *dir = jcr->dir_bsock;
- int append;
+ int32_t append;
bool ok;
- int Copy, Stripe;
+ int32_t Copy, Stripe;
DIRSTORE *store;
RCTX rctx;
alist *dirstore;
}
} while (ok && dir->recv() >= 0);
+#ifdef xxxx
/* Developer debug code */
char *device_name;
if (debug_level >= dbglvl) {
}
}
}
+#endif
init_jcr_device_wait_timers(jcr);
jcr->dcr = new_dcr(jcr, NULL, NULL); /* get a dcr */
bool fail = false;
rctx.notify_dir = true;
+ /* Put new dcr in proper location */
+ if (rctx.append) {
+ rctx.jcr->dcr = jcr->dcr;
+ } else {
+ rctx.jcr->read_dcr = jcr->dcr;
+ }
lock_reservations();
for ( ; !fail && !job_canceled(jcr); ) {
pop_reserve_messages(jcr);
if (vol->dev->is_autochanger()) {
Dmsg1(dbglvl, "vol=%s is in changer\n", vol->vol_name);
- if (!is_vol_in_autochanger(rctx, vol)) {
+ if (!is_vol_in_autochanger(rctx, vol) || !vol->dev->autoselect) {
continue;
}
} else if (strcmp(device_name, vol->dev->device->hdr.name) != 0) {
goto bail_out;
}
+ /* Note: on failure this returns jcr->errmsg properly edited */
+ if (generate_plugin_event(jcr, bsdEventDeviceTryOpen, dcr) != bRC_OK) {
+ queue_reserve_message(jcr);
+ goto bail_out;
+ }
dev->clear_append();
dev->set_read();
- ok = true;
dcr->set_reserved();
+ ok = true;
bail_out:
dev->dunlock();
goto bail_out;
}
+ /* Note: on failure this returns jcr->errmsg properly edited */
+ if (generate_plugin_event(jcr, bsdEventDeviceTryOpen, dcr) != bRC_OK) {
+ queue_reserve_message(jcr);
+ goto bail_out;
+ }
dcr->set_reserved();
ok = true;