- device_name = get_pool_memory(PM_NAME);
- pool_name = get_pool_memory(PM_NAME);
- pool_type = get_pool_memory(PM_NAME);
- media_type = get_pool_memory(PM_NAME);
- pm_strcpy(device_name, storage->dev_name);
- pm_strcpy(media_type, storage->media_type);
- pm_strcpy(pool_type, jcr->pool->pool_type);
- pm_strcpy(pool_name, jcr->pool->hdr.name);
- bash_spaces(device_name);
- bash_spaces(media_type);
- bash_spaces(pool_type);
- bash_spaces(pool_name);
- bnet_fsend(sd, use_device, device_name, media_type, pool_name, pool_type);
- Dmsg1(110, ">stored: %s", sd->msg);
- status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY);
- if (!status) {
- pm_strcpy(pool_type, sd->msg); /* save message */
- Jmsg(jcr, M_FATAL, 0, _("\n"
- " Storage daemon didn't accept Device \"%s\" because:\n %s"),
- device_name, pool_type/* sd->msg */);
- }
- free_memory(device_name);
- free_memory(media_type);
- free_memory(pool_name);
- free_memory(pool_type);
-
- return status;
+ /* Do read side of storage daemon */
+ if (ok && rstore) {
+ /* For the moment, only migrate, copy and vbackup have rpool */
+ if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY) ||
+ (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL))) {
+ pm_strcpy(pool_type, jcr->rpool->pool_type);
+ pm_strcpy(pool_name, jcr->rpool->name());
+ } else {
+ pm_strcpy(pool_type, jcr->pool->pool_type);
+ pm_strcpy(pool_name, jcr->pool->name());
+ }
+ bash_spaces(pool_type);
+ bash_spaces(pool_name);
+ foreach_alist(storage, rstore) {
+ Dmsg1(100, "Rstore=%s\n", storage->name());
+ pm_strcpy(store_name, storage->name());
+ bash_spaces(store_name);
+ if (jcr->media_type) {
+ pm_strcpy(media_type, jcr->media_type); /* user override */
+ } else {
+ pm_strcpy(media_type, storage->media_type);
+ }
+ bash_spaces(media_type);
+ sd->fsend(use_storage, store_name.c_str(), media_type.c_str(),
+ pool_name.c_str(), pool_type.c_str(), 0, copy, stripe);
+ Dmsg1(100, "rstore >stored: %s", sd->msg);
+ DEVICE *dev;
+ /* Loop over alternative storage Devices until one is OK */
+ foreach_alist(dev, storage->device) {
+ pm_strcpy(device_name, dev->name());
+ bash_spaces(device_name);
+ sd->fsend(use_device, device_name.c_str());
+ Dmsg1(100, ">stored: %s", sd->msg);
+ }
+ sd->signal(BNET_EOD); /* end of Devices */
+ }
+ sd->signal(BNET_EOD); /* end of Storages */
+ if (bget_dirmsg(sd) > 0) {
+ Dmsg1(100, "<stored: %s", sd->msg);
+ /* ****FIXME**** save actual device name */
+ ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1;
+ } else {
+ ok = false;
+ }
+ if (ok) {
+ Jmsg(jcr, M_INFO, 0, _("Using Device \"%s\" to read.\n"), device_name.c_str());
+ }
+ }
+
+ /* Do write side of storage daemon */
+ if (ok && wstore) {
+ pm_strcpy(pool_type, jcr->pool->pool_type);
+ pm_strcpy(pool_name, jcr->pool->name());
+ bash_spaces(pool_type);
+ bash_spaces(pool_name);
+ foreach_alist(storage, wstore) {
+ Dmsg1(100, "Wstore=%s\n", storage->name());
+ pm_strcpy(store_name, storage->name());
+ bash_spaces(store_name);
+ pm_strcpy(media_type, storage->media_type);
+ bash_spaces(media_type);
+ sd->fsend(use_storage, store_name.c_str(), media_type.c_str(),
+ pool_name.c_str(), pool_type.c_str(), 1, copy, stripe);
+
+ Dmsg1(100, "wstore >stored: %s", sd->msg);
+ DEVICE *dev;
+ /* Loop over alternative storage Devices until one is OK */
+ foreach_alist(dev, storage->device) {
+ pm_strcpy(device_name, dev->name());
+ bash_spaces(device_name);
+ sd->fsend(use_device, device_name.c_str());
+ Dmsg1(100, ">stored: %s", sd->msg);
+ }
+ sd->signal(BNET_EOD); /* end of Devices */
+ }
+ sd->signal(BNET_EOD); /* end of Storages */
+ if (bget_dirmsg(sd) > 0) {
+ Dmsg1(100, "<stored: %s", sd->msg);
+ /* ****FIXME**** save actual device name */
+ ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1;
+ } else {
+ ok = false;
+ }
+ if (ok) {
+ Jmsg(jcr, M_INFO, 0, _("Using Device \"%s\" to write.\n"), device_name.c_str());
+ }
+ }
+ if (!ok) {
+ POOL_MEM err_msg;
+ if (sd->msg[0]) {
+ pm_strcpy(err_msg, sd->msg); /* save message */
+ Jmsg(jcr, M_FATAL, 0, _("\n"
+ " Storage daemon didn't accept Device \"%s\" because:\n %s"),
+ device_name.c_str(), err_msg.c_str()/* sd->msg */);
+ } else {
+ Jmsg(jcr, M_FATAL, 0, _("\n"
+ " Storage daemon didn't accept Device \"%s\" command.\n"),
+ device_name.c_str());
+ }
+ }
+ return ok;