2 This patch corrects a Bacula crash after a "list nextvol" followed
4 It can be applied to 1.36.0 with:
7 patch -p0 <1.36.0-list.patch
12 Index: src/dird/ua_output.c
13 ===================================================================
14 RCS file: /cvsroot/bacula/bacula/src/dird/ua_output.c,v
15 retrieving revision 1.47
16 diff -u -r1.47 ua_output.c
17 --- src/dird/ua_output.c 19 Sep 2004 18:56:24 -0000 1.47
18 +++ src/dird/ua_output.c 13 Nov 2004 10:26:08 -0000
21 extern brwlock_t con_lock;
24 /* Imported functions */
26 /* Forward referenced functions */
27 static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist);
28 +static bool list_nextvol(UAContext *ua);
31 * Turn auto display of console messages on/off
33 /* List next volume */
34 } else if (strcasecmp(ua->argk[i], _("nextvol")) == 0 ||
35 strcasecmp(ua->argk[i], _("nextvolume")) == 0) {
43 - i = find_arg_with_value(ua, "job");
45 - if ((job = select_job_resource(ua)) == NULL) {
49 - job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
51 - Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]);
52 - if ((job = select_job_resource(ua)) == NULL) {
57 - for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
58 - pool = run ? run->pool : NULL;
59 - if (!complete_jcr_for_job(jcr, job, pool)) {
63 - if (!find_next_volume_for_append(jcr, &mr, 0)) {
64 - bsendmsg(ua, _("Could not find next Volume.\n"));
66 - db_close_database(jcr, jcr->db);
71 - bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"),
72 - job->hdr.name, mr.VolumeName);
76 - db_close_database(jcr, jcr->db);
81 - db_close_database(jcr, jcr->db);
85 - bsendmsg(ua, _("Could not find next Volume.\n"));
90 bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
96 +static bool list_nextvol(UAContext *ua)
103 + bool found = false;
106 + memset(&mr, 0, sizeof(mr));
107 + int i = find_arg_with_value(ua, "job");
109 + if ((job = select_job_resource(ua)) == NULL) {
113 + job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
115 + Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]);
116 + if ((job = select_job_resource(ua)) == NULL) {
121 + for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
122 + pool = run ? run->pool : NULL;
123 + if (!complete_jcr_for_job(jcr, job, pool)) {
127 + if (!find_next_volume_for_append(jcr, &mr, 0)) {
128 + bsendmsg(ua, _("Could not find next Volume.\n"));
130 + bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"),
131 + job->hdr.name, mr.VolumeName);
134 + if (jcr->db && jcr->db != ua->db) {
135 + db_close_database(jcr, jcr->db);
140 + bsendmsg(ua, _("Could not find next Volume.\n"));
148 * For a given job, we examine all his run records
149 * to see if it is scheduled today or tomorrow.