- char *reason = NULL; /* detailed reason for rejection */
- jcr->MediaId = mr.MediaId;
- Dmsg1(120, "VolumeInfo MediaId=%d\n", jcr->MediaId);
- pm_strcpy(&jcr->VolumeName, mr.VolumeName);
- /*
- * If we are reading, accept any volume (reason == NULL)
- * If we are writing, check if the Volume is valid
- * for this job, and do a recycle if necessary
- */
- if (writing) {
- /*
- * SD wants to write this Volume, so make
- * sure it is suitable for this job, i.e.
- * Pool matches, and it is either Append or Recycle
- * and Media Type matches and Pool allows any volume.
- */
- if (mr.PoolId != jcr->PoolId) {
- reason = "not in Pool";
- } else if (strcmp(mr.MediaType, jcr->store->media_type) != 0) {
- reason = "not correct MediaType";
- } else {
- /*
- * ****FIXME***
- * This test (accept_any_volume) is turned off
- * because it doesn't properly check if the volume
- * really is out of sequence!
- *
- * } else if (!jcr->pool->accept_any_volume) {
- * reason = "Volume not in sequence";
- */
-
- /*
- * Now try recycling if necessary
- */
- is_volume_valid_or_recyclable(jcr, &mr, &reason);
- }
- }
- if (reason == NULL) {
- char ed1[50], ed2[50], ed3[50];
- /*
- * Send Find Media response to Storage daemon
- */
- bash_spaces(mr.VolumeName);
- bnet_fsend(bs, OK_media, mr.VolumeName, mr.VolJobs,
- mr.VolFiles, mr.VolBlocks, edit_uint64(mr.VolBytes, ed1),
- mr.VolMounts, mr.VolErrors, mr.VolWrites,
- edit_uint64(mr.MaxVolBytes, ed2),
- edit_uint64(mr.VolCapacityBytes, ed3),
- mr.VolStatus, mr.Slot, mr.MaxVolJobs, mr.MaxVolFiles);
- Dmsg2(100, "Vol Info for %s: %s", jcr->Job, bs->msg);
- } else {
- /* Not suitable volume */
- bnet_fsend(bs, "1998 Volume \"%s\" status is %s, %s.\n", mr.VolumeName,
- mr.VolStatus, reason);
- }
+ const char *reason = NULL; /* detailed reason for rejection */
+ /*
+ * If we are reading, accept any volume (reason == NULL)
+ * If we are writing, check if the Volume is valid
+ * for this job, and do a recycle if necessary
+ */
+ if (writing) {
+ /*
+ * SD wants to write this Volume, so make
+ * sure it is suitable for this job, i.e.
+ * Pool matches, and it is either Append or Recycle
+ * and Media Type matches and Pool allows any volume.
+ */
+ if (mr.PoolId != jcr->jr.PoolId) {
+ reason = _("not in Pool");
+ } else if (strcmp(mr.MediaType, jcr->wstore->media_type) != 0) {
+ reason = _("not correct MediaType");
+ } else {
+ /*
+ * Now try recycling if necessary
+ * reason set non-NULL if we cannot use it
+ */
+ check_if_volume_valid_or_recyclable(jcr, &mr, &reason);
+ }
+ }
+ if (!reason && mr.Enabled != 1) {
+ reason = _("is not Enabled");
+ }
+ if (reason == NULL) {
+ /*
+ * Send Find Media response to Storage daemon
+ */
+ send_volume_info_to_storage_daemon(jcr, bs, &mr);
+ } else {
+ /* Not suitable volume */
+ bs->fsend(_("1998 Volume \"%s\" status is %s, %s.\n"), mr.VolumeName,
+ mr.VolStatus, reason);
+ }