From: Kern Sibbald Date: Thu, 30 Dec 2004 20:07:31 +0000 (+0000) Subject: - Enhance CDROM boot to include some documentation at boot time. X-Git-Tag: Release-1.38.0~683 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8dcd2447310465bd9869c87f5fd5ced1defe50f6;p=bacula%2Fbacula - Enhance CDROM boot to include some documentation at boot time. - NOTE. The CDROM will not boot 2.6 kernels because the boot sequence has changed significantly. Updates to come later. - Add memtest option to CDROM boot. - Include Nicolas' changes to fix llist JobMedia records. - Make sure that ClientRunBefore/After messages from the program are terminated with a newline. Add strerror to output error messages. - Return program exit status code in Win32. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1781 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/examples/python/.cvsignore b/bacula/examples/python/.cvsignore new file mode 100644 index 0000000000..c294236e0e --- /dev/null +++ b/bacula/examples/python/.cvsignore @@ -0,0 +1,3 @@ +EndJob.pyc +NewVolume.pyc +StartJob.pyc diff --git a/bacula/kernstodo b/bacula/kernstodo index 6ad5d7df15..c1214b8899 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -30,6 +30,7 @@ Suggestions for Preben: - Optimized bootstrap. For 1.37: +- Add Set Error from Python. - Create a new GUI chapter explaining all the GUI programs. - Tell the "restore" user when browsing is no longer possible. - Add disk seeking on restore. @@ -99,11 +100,20 @@ Design: - Directory Pool - Media Type (read/write) - - Device Group + - Device List + - Next Pool + - Migration High + - Migration Low + - Migration Time (time after which data migrated to next Pool) + - Maximum Devices (that can use Pool simultaneously) Media - Autochanger Id - List of Devices/Device Groups/Storage groups (i.e. physical restraint) + - Migration High + - Migration Low + - Migration Time (time after which data migrated to next Pool) + - Maximum Devices (that can use Pool simultaneously) Autochanger - Device list diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index fa18ad9fac..ec69cda044 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -80,13 +80,13 @@ db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_ db_lock(mdb); if (type == VERT_LIST) { Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog," - "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes," - "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId," - "RecyclePoolId " - "FROM Pool ORDER BY PoolId"); + "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes," + "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId," + "RecyclePoolId " + "FROM Pool ORDER BY PoolId"); } else { Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,PoolType,LabelFormat " - "FROM Pool ORDER BY PoolId"); + "FROM Pool ORDER BY PoolId"); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -106,11 +106,11 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, db_lock(mdb); if (type == VERT_LIST) { Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention," - "FileRetention,JobRetention " - "FROM Client ORDER BY ClientId"); + "FileRetention,JobRetention " + "FROM Client ORDER BY ClientId"); } else { Mmsg(mdb->cmd, "SELECT ClientId,Name,FileRetention,JobRetention " - "FROM Client ORDER BY ClientId"); + "FROM Client ORDER BY ClientId"); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -136,31 +136,31 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, db_lock(mdb); if (type == VERT_LIST) { if (mdbr->VolumeName[0] != 0) { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," - "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," - "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," - "VolCapacityBytes,VolStatus,Recycle,VolRetention," - "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," - "EndFile,EndBlock " - "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," + "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," + "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," + "VolCapacityBytes,VolStatus,Recycle,VolRetention," + "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," + "EndFile,EndBlock " + "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," - "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," - "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," - "VolCapacityBytes,VolStatus,Recycle,VolRetention," - "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," - "EndFile,EndBlock " - "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," + "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," + "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," + "VolCapacityBytes,VolStatus,Recycle,VolRetention," + "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," + "EndFile,EndBlock " + "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); } } else { if (mdbr->VolumeName[0] != 0) { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," - "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " - "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " + "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," - "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " - "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " + "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); } } @@ -181,26 +181,26 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, db_lock(mdb); if (type == VERT_LIST) { if (JobId > 0) { /* do by JobId */ - Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," - "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," - "JobMedia.EndBlock " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " - "AND JobMedia.JobId=%u", JobId); + Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,Media.MediaId,Media.VolumeName," + "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," + "JobMedia.EndBlock " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " + "AND JobMedia.JobId=%u", JobId); } else { - Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," - "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," - "JobMedia.EndBlock " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); + Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,Media.MediaId,Media.VolumeName," + "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," + "JobMedia.EndBlock " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); } } else { if (JobId > 0) { /* do by JobId */ - Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " - "AND JobMedia.JobId=%u", JobId); + Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " + "AND JobMedia.JobId=%u", JobId); } else { - Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); + Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); } } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -230,33 +230,33 @@ db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, if (type == VERT_LIST) { if (jr->JobId == 0 && jr->Job[0] == 0) { Mmsg(mdb->cmd, - "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," - "Job.ClientId,Client.Name,JobStatus,SchedTime," - "StartTime,EndTime,JobTDate," - "VolSessionId,VolSessionTime,JobFiles,JobErrors," - "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " - "FROM Job,Client,Pool,FileSet WHERE " - "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " - "AND FileSet.FileSetId=Job.FileSetId ORDER BY StartTime"); + "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," + "Job.ClientId,Client.Name,JobStatus,SchedTime," + "StartTime,EndTime,JobTDate," + "VolSessionId,VolSessionTime,JobFiles,JobErrors," + "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " + "FROM Job,Client,Pool,FileSet WHERE " + "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " + "AND FileSet.FileSetId=Job.FileSetId ORDER BY StartTime"); } else { /* single record */ Mmsg(mdb->cmd, - "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," - "Job.ClientId,Client.Name,JobStatus,SchedTime," - "StartTime,EndTime,JobTDate," - "VolSessionId,VolSessionTime,JobFiles,JobErrors," - "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " - "FROM Job,Client,Pool,FileSet WHERE Job.JobId=%u AND " - "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " - "AND FileSet.FileSetId=Job.FileSetId", jr->JobId); + "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," + "Job.ClientId,Client.Name,JobStatus,SchedTime," + "StartTime,EndTime,JobTDate," + "VolSessionId,VolSessionTime,JobFiles,JobErrors," + "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " + "FROM Job,Client,Pool,FileSet WHERE Job.JobId=%u AND " + "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " + "AND FileSet.FileSetId=Job.FileSetId", jr->JobId); } } else { if (jr->JobId == 0 && jr->Job[0] == 0) { Mmsg(mdb->cmd, - "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus " - "FROM Job ORDER BY StartTime"); + "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus " + "FROM Job ORDER BY StartTime"); } else { /* single record */ - Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level," - "JobFiles,JobBytes,JobStatus FROM Job WHERE JobId=%u", jr->JobId); + Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level," + "JobFiles,JobBytes,JobStatus FROM Job WHERE JobId=%u", jr->JobId); } } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 0d55d702db..6e0019da22 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -15,7 +15,7 @@ */ /* - Copyright (C) 2000-2004 Kern Sibbald and John Walker + Copyright (C) 2000-2004 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -101,12 +101,12 @@ bool do_verify(JCR *jcr) if (!db_find_last_jobid(jcr, jcr->db, Name, &jr)) { if (jcr->JobLevel == L_VERIFY_CATALOG) { Jmsg(jcr, M_FATAL, 0, _( - "Unable to find JobId of previous InitCatalog Job.\n" - "Please run a Verify with Level=InitCatalog before\n" - "running the current Job.\n")); + "Unable to find JobId of previous InitCatalog Job.\n" + "Please run a Verify with Level=InitCatalog before\n" + "running the current Job.\n")); } else { Jmsg(jcr, M_FATAL, 0, _( - "Unable to find JobId of previous Job for this client.\n")); + "Unable to find JobId of previous Job for this client.\n")); } goto bail_out; } @@ -136,12 +136,12 @@ bool do_verify(JCR *jcr) jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { verify_jr.JobId = verify_jobid; if (!db_get_job_record(jcr, jcr->db, &verify_jr)) { - Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), + Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), db_strerror(jcr->db)); goto bail_out; } if (verify_jr.JobStatus != 'T') { - Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not terminate normally. JobStatus=%c\n"), + Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not terminate normally. JobStatus=%c\n"), verify_jobid, verify_jr.JobStatus); goto bail_out; } @@ -275,7 +275,7 @@ bool do_verify(JCR *jcr) jr.VolSessionId, jr.VolSessionTime, jr.StartFile, jr.EndFile, jr.StartBlock, jr.EndBlock); - if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) { + if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) { goto bail_out; } } @@ -404,7 +404,7 @@ static void verify_cleanup(JCR *jcr, int TermCode) default: term_msg = term_code; bsnprintf(term_code, sizeof(term_code), - _("Inappropriate term code: %d %c\n"), TermCode, TermCode); + _("Inappropriate term code: %d %c\n"), TermCode, TermCode); break; } bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); @@ -501,7 +501,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) char buf[MAXSTRING]; POOLMEM *fname = get_pool_memory(PM_MESSAGE); int do_SIG = NO_SIG; - long file_index = 0; + int32_t file_index = 0; memset(&fdbr, 0, sizeof(FILE_DBR)); fd = jcr->file_bsock; @@ -529,7 +529,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) Dmsg1(200, "Atts+SIG=%s\n", fd->msg); if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream, fname)) != 3) { - Jmsg3(jcr, M_FATAL, 0, _("birdmsglen, fd->msg); goto bail_out; } @@ -556,7 +556,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) */ if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_UNIX_ATTRIBUTES_EX) { int32_t LinkFIf, LinkFIc; - Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr); + Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr); jcr->JobFiles++; jcr->FileIndex = file_index; /* remember attribute file_index */ decode_stat(attr, &statf, &LinkFIf); /* decode file stat packet */ @@ -564,8 +564,8 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) jcr->fn_printed = false; pm_strcpy(jcr->fname, fname); /* move filename into JCR */ - Dmsg2(040, "dirdfname); - Dmsg1(020, "dirdfname); + Dmsg1(020, "dirddb, jcr->fname, jcr->verify_jr, &fdbr)) { - Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname); - Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname); + Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname); + Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname); stat = JS_Differences; continue; } else { @@ -585,7 +585,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) db_mark_file_record(jcr, jcr->db, fdbr.FileId, jcr->JobId); } - Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname, + Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname, file_index, Opts_SIG); decode_stat(fdbr.LStat, &statc, &LinkFIc); /* decode catalog stat */ /* @@ -595,95 +595,95 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) for (p=Opts_SIG; *p; p++) { char ed1[30], ed2[30]; switch (*p) { - case 'i': /* compare INODEs */ + case 'i': /* compare INODEs */ if (statc.st_ino != statf.st_ino) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_ino differ. Cat: %s File: %s\n"), + Jmsg(jcr, M_INFO, 0, _(" st_ino differ. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_ino, ed1), edit_uint64((uint64_t)statf.st_ino, ed2)); stat = JS_Differences; } break; - case 'p': /* permissions bits */ + case 'p': /* permissions bits */ if (statc.st_mode != statf.st_mode) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_mode differ. Cat: %x File: %x\n"), + Jmsg(jcr, M_INFO, 0, _(" st_mode differ. Cat: %x File: %x\n"), (uint32_t)statc.st_mode, (uint32_t)statf.st_mode); stat = JS_Differences; } break; - case 'n': /* number of links */ + case 'n': /* number of links */ if (statc.st_nlink != statf.st_nlink) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_nlink differ. Cat: %d File: %d\n"), + Jmsg(jcr, M_INFO, 0, _(" st_nlink differ. Cat: %d File: %d\n"), (uint32_t)statc.st_nlink, (uint32_t)statf.st_nlink); stat = JS_Differences; } break; - case 'u': /* user id */ + case 'u': /* user id */ if (statc.st_uid != statf.st_uid) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_uid differ. Cat: %u File: %u\n"), + Jmsg(jcr, M_INFO, 0, _(" st_uid differ. Cat: %u File: %u\n"), (uint32_t)statc.st_uid, (uint32_t)statf.st_uid); stat = JS_Differences; } break; - case 'g': /* group id */ + case 'g': /* group id */ if (statc.st_gid != statf.st_gid) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_gid differ. Cat: %u File: %u\n"), + Jmsg(jcr, M_INFO, 0, _(" st_gid differ. Cat: %u File: %u\n"), (uint32_t)statc.st_gid, (uint32_t)statf.st_gid); stat = JS_Differences; } break; - case 's': /* size */ + case 's': /* size */ if (statc.st_size != statf.st_size) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_size differ. Cat: %s File: %s\n"), + Jmsg(jcr, M_INFO, 0, _(" st_size differ. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_size, ed1), edit_uint64((uint64_t)statf.st_size, ed2)); stat = JS_Differences; } break; - case 'a': /* access time */ + case 'a': /* access time */ if (statc.st_atime != statf.st_atime) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_atime differs\n")); + Jmsg(jcr, M_INFO, 0, _(" st_atime differs\n")); stat = JS_Differences; } break; - case 'm': + case 'm': if (statc.st_mtime != statf.st_mtime) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_mtime differs\n")); + Jmsg(jcr, M_INFO, 0, _(" st_mtime differs\n")); stat = JS_Differences; } break; - case 'c': /* ctime */ + case 'c': /* ctime */ if (statc.st_ctime != statf.st_ctime) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_ctime differs\n")); + Jmsg(jcr, M_INFO, 0, _(" st_ctime differs\n")); stat = JS_Differences; } break; - case 'd': /* file size decrease */ + case 'd': /* file size decrease */ if (statc.st_size > statf.st_size) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_size decrease. Cat: %s File: %s\n"), + Jmsg(jcr, M_INFO, 0, _(" st_size decrease. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_size, ed1), edit_uint64((uint64_t)statf.st_size, ed2)); stat = JS_Differences; } break; - case '5': /* compare MD5 */ - Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname); + case '5': /* compare MD5 */ + Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname); do_SIG = MD5_SIG; break; - case '1': /* compare SHA1 */ + case '1': /* compare SHA1 */ do_SIG = SHA1_SIG; break; - case ':': - case 'V': + case ':': + case 'V': default: break; } @@ -693,13 +693,13 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) * It came across in the Opts_SIG field. */ } else if (stream == STREAM_MD5_SIGNATURE || stream == STREAM_SHA1_SIGNATURE) { - Dmsg2(400, "stream=SIG inx=%d SIG=%s\n", file_index, Opts_SIG); + Dmsg2(400, "stream=SIG inx=%d SIG=%s\n", file_index, Opts_SIG); /* * When ever we get a signature is MUST have been * preceded by an attributes record, which sets attr_file_index */ if (jcr->FileIndex != (uint32_t)file_index) { - Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), + Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), file_index, jcr->FileIndex); goto bail_out; } @@ -708,11 +708,11 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) if (strcmp(buf, fdbr.SIG) != 0) { prt_fname(jcr); if (debug_level >= 10) { - Jmsg(jcr, M_INFO, 0, _(" %s not same. File=%s Cat=%s\n"), - stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1", buf, fdbr.SIG); + Jmsg(jcr, M_INFO, 0, _(" %s not same. File=%s Cat=%s\n"), + stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1", buf, fdbr.SIG); } else { - Jmsg(jcr, M_INFO, 0, _(" %s differs.\n"), - stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1"); + Jmsg(jcr, M_INFO, 0, _(" %s differs.\n"), + stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1"); } stat = JS_Differences; } @@ -722,8 +722,9 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) jcr->JobFiles = file_index; } if (is_bnet_error(fd)) { + berrno be; Jmsg2(jcr, M_FATAL, 0, _("bdirdfn_printed = false; - sprintf(buf, + bsnprintf(buf, sizeof(buf), "SELECT Path.Path,Filename.Name FROM File,Path,Filename " "WHERE File.JobId=%d " "AND File.MarkedId!=%d AND File.PathId=Path.PathId " @@ -756,7 +757,7 @@ bail_out: * We are called here for each record that matches the above * SQL query -- that is for each file contained in the Catalog * that was not marked earlier. This means that the file in - * question is a missing file (in the Catalog but on on Disk). + * question is a missing file (in the Catalog but not on Disk). */ static int missing_handler(void *ctx, int num_fields, char **row) { diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index e931e31791..506f4517d5 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -201,15 +201,15 @@ void *handle_client_request(void *dirp) break; } if ((jcr->authenticated) && (!cmds[i].monitoraccess) && (jcr->director->monitor)) { - Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd); + Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd); bnet_fsend(dir, illegal_cmd); bnet_sig(dir, BNET_EOD); break; } - Dmsg1(100, "Executing %s command.\n", cmds[i].cmd); + Dmsg1(100, "Executing %s command.\n", cmds[i].cmd); if (!cmds[i].func(jcr)) { /* do command */ quit = true; /* error or fully terminated, get out */ - Dmsg0(20, "Quit command loop due to command error or Job done.\n"); + Dmsg0(20, "Quit command loop due to command error or Job done.\n"); } break; } @@ -313,7 +313,7 @@ static int cancel_cmd(JCR *jcr) if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) { if (!(cjcr=get_jcr_by_full_name(Job))) { - bnet_fsend(dir, "2901 Job %s not found.\n", Job); + bnet_fsend(dir, "2901 Job %s not found.\n", Job); } else { if (cjcr->store_bsock) { P(cjcr->mutex); @@ -329,7 +329,7 @@ static int cancel_cmd(JCR *jcr) } set_jcr_job_status(cjcr, JS_Canceled); free_jcr(cjcr); - bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job); + bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job); } } else { bnet_fsend(dir, _("2902 Error scanning cancel command.\n")); @@ -464,18 +464,23 @@ static int run_cmd(JCR *jcr, char *cmd, const char *name) bpipe = open_bpipe(ecmd, 0, "r"); free_pool_memory(ecmd); if (bpipe == NULL) { - Jmsg(jcr, M_FATAL, 0, _("%s could not execute\n"), name); - set_jcr_job_status(jcr, JS_FatalError); + berrno be; + Jmsg(jcr, M_FATAL, 0, _("%s could not execute. ERR=%s\n"), name, + be.strerror()); return 0; } while (fgets(line, sizeof(line), bpipe->rfd)) { + int len = strlen(line); + if (len > 0 && line[len-1] ! = '\n') { + bstrncat(line, sizeof(line), "\n"); + } Jmsg(jcr, M_INFO, 0, _("%s: %s"), name, line); } status = close_bpipe(bpipe); if (status != 0) { - Jmsg(jcr, M_FATAL, 0, _("%s returned non-zero status=%d\n"), name, - status); - set_jcr_job_status(jcr, JS_FatalError); + berrno be; + Jmsg(jcr, M_FATAL, 0, _("%s returned non-zero status=%d. ERR=%s\n"), name, + status, be.strerror(status)); return 0; } return 1; @@ -513,7 +518,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) bpipe = open_bpipe(fn, 0, "r"); free_pool_memory(fn); if (!bpipe) { - Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), p, strerror(errno)); return; } @@ -521,7 +526,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) if (list == INC_LIST) { *q = 0; /* terminate options */ strcpy(buf, fname); - strcat(buf, " "); + strcat(buf, " "); optlen = strlen(buf); } else { optlen = 0; @@ -535,7 +540,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) } } if ((stat=close_bpipe(bpipe)) != 0) { - Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), p, stat, strerror(errno)); return; } @@ -544,15 +549,15 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) p++; /* skip over < */ if ((ffd = fopen(p, "r")) == NULL) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"), - list==INC_LIST?"included":"excluded", p, be.strerror()); + Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"), + list==INC_LIST?"included":"excluded", p, be.strerror()); return; } /* Copy File options */ if (list == INC_LIST) { *q = 0; /* terminate options */ strcpy(buf, fname); - strcat(buf, " "); + strcat(buf, " "); optlen = strlen(buf); } else { optlen = 0; @@ -659,7 +664,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese bpipe = open_bpipe(fn, 0, "r"); free_pool_memory(fn); if (!bpipe) { - Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), p, strerror(errno)); return; } @@ -668,7 +673,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese fileset->incexe->name_list.append(bstrdup(buf)); } if ((stat=close_bpipe(bpipe)) != 0) { - Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), p, stat, strerror(errno)); return; } @@ -677,7 +682,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese p++; /* skip over < */ if ((ffd = fopen(p, "r")) == NULL) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), p, be.strerror()); return; } @@ -750,7 +755,7 @@ static void add_fileset(JCR *jcr, const char *item) regerror(rc, preg, prbuf, sizeof(prbuf)); regfree(preg); free(preg); - Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf); + Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf); state = state_error; break; } @@ -807,26 +812,26 @@ static bool term_fileset(JCR *jcr) for (j=0; jopts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); for (k=0; kregex.size(); k++) { - Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); + Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); } for (k=0; kwild.size(); k++) { - Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); + Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); } for (k=0; kbase.size(); k++) { - Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); + Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); } for (k=0; kfstype.size(); k++) { - Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); + Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); } if (fo->reader) { - Dmsg1(400, "D %s\n", fo->reader); + Dmsg1(400, "D %s\n", fo->reader); } if (fo->writer) { - Dmsg1(400, "T %s\n", fo->writer); + Dmsg1(400, "T %s\n", fo->writer); } } for (j=0; jname_list.size(); j++) { - Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); + Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); } } for (i=0; iexclude_list.size(); i++) { @@ -835,20 +840,20 @@ static bool term_fileset(JCR *jcr) for (j=0; jopts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); for (k=0; kregex.size(); k++) { - Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); + Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); } for (k=0; kwild.size(); k++) { - Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); + Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); } for (k=0; kbase.size(); k++) { - Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); + Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); } for (k=0; kfstype.size(); k++) { - Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); + Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); } } for (j=0; jname_list.size(); j++) { - Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); + Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); } } return ff->fileset->state != state_error; @@ -894,7 +899,7 @@ static void set_options(findFOPTS *fo, const char *opts) case 'p': /* use portable data format */ fo->flags |= FO_PORTABLE; break; - case 'R': /* Resource forks and Finder Info */ + case 'R': /* Resource forks and Finder Info */ fo->flags |= FO_HFSPLUS; case 'r': /* read fifo */ fo->flags |= FO_READFIFO; @@ -916,7 +921,7 @@ static void set_options(findFOPTS *fo, const char *opts) break; case 'V': /* verify options */ /* Copy Verify Options */ - for (j=0; *p && *p != ':'; p++) { + for (j=0; *p && *p != ':'; p++) { fo->VerifyOpts[j] = *p; if (j < (int)sizeof(fo->VerifyOpts) - 1) { j++; @@ -929,11 +934,11 @@ static void set_options(findFOPTS *fo, const char *opts) break; case 'Z': /* gzip compression */ fo->flags |= FO_GZIP; - fo->GZIP_level = *++p - '0'; - Dmsg1(200, "Compression level=%d\n", fo->GZIP_level); + fo->GZIP_level = *++p - '0'; + Dmsg1(200, "Compression level=%d\n", fo->GZIP_level); break; default: - Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p); + Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p); break; } } @@ -1091,7 +1096,7 @@ static int level_cmd(JCR *jcr) if (bnet_recv(dir) <= 0) { /* get response */ goto bail_out; } - if (sscanf(dir->msg, "btime %s", buf) != 1) { + if (sscanf(dir->msg, "btime %s", buf) != 1) { goto bail_out; } if (i < 2) { /* toss first two results */ @@ -1100,7 +1105,7 @@ static int level_cmd(JCR *jcr) his_time = str_to_uint64(buf); rt = get_current_btime() - bt_start; /* compute round trip time */ bt_adj -= his_time - bt_start - rt/2; - Dmsg2(200, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2)); + Dmsg2(200, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2)); } bt_adj = bt_adj / 8; /* compute average time */ @@ -1108,7 +1113,7 @@ static int level_cmd(JCR *jcr) adj = btime_to_utime(bt_adj); since_time += adj; /* adjust for clock difference */ if (adj != 0) { - Jmsg(jcr, M_INFO, 0, _("Since time adjusted by %d seconds.\n"), adj); + Jmsg(jcr, M_INFO, 0, _("Since time adjusted by %d seconds.\n"), adj); } bnet_sig(dir, BNET_EOD); @@ -1235,7 +1240,7 @@ static int backup_cmd(JCR *jcr) if (bget_msg(sd) >= 0) { Dmsg1(110, "msg); if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) { - Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg); + Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg); goto cleanup; } Dmsg1(110, "Got Ticket=%d\n", jcr->Ticket); @@ -1297,15 +1302,15 @@ static int backup_cmd(JCR *jcr) while (bget_msg(sd) >= 0) { /* stop on signal or error */ if (sscanf(sd->msg, OK_close, &SDJobStatus) == 1) { ok = 1; - Dmsg2(200, "SDJobStatus = %d %c\n", SDJobStatus, (char)SDJobStatus); + Dmsg2(200, "SDJobStatus = %d %c\n", SDJobStatus, (char)SDJobStatus); } } if (!ok) { - Jmsg(jcr, M_FATAL, 0, _("Append Close with SD failed.\n")); + Jmsg(jcr, M_FATAL, 0, _("Append Close with SD failed.\n")); goto cleanup; } if (SDJobStatus != JS_Terminated) { - Jmsg(jcr, M_FATAL, 0, _("Bad status %d returned from Storage Daemon.\n"), + Jmsg(jcr, M_FATAL, 0, _("Bad status %d returned from Storage Daemon.\n"), SDJobStatus); } } @@ -1421,7 +1426,7 @@ static int restore_cmd(JCR *jcr) if (sscanf(dir->msg, restorecmd, &replace, &prefix_links, where) != 3) { if (sscanf(dir->msg, restorecmd1, &replace, &prefix_links) != 2) { pm_strcpy(jcr->errmsg, dir->msg); - Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), jcr->errmsg); + Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), jcr->errmsg); return 0; } *where = 0; @@ -1516,7 +1521,7 @@ static int open_sd_read_session(JCR *jcr) if (bget_msg(sd) >= 0) { Dmsg1(110, "bfiledmsg); if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) { - Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg); + Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg); return 0; } Dmsg1(110, "bfiled: got Ticket=%d\n", jcr->Ticket); diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 8eca9c9464..5c3b638d15 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -272,6 +272,7 @@ bool is_bnet_stop(BSOCK * bsock) */ int is_bnet_error(BSOCK * bsock) { + errno = bsock->b_errno; return bsock->errors; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 9184181ccc..2479a40624 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.1" -#define BDATE "24 December 2004" -#define LSMDATE "24Dec04" +#define BDATE "30 December 2004" +#define LSMDATE "30Dec04" /* Debug flags */ #undef DEBUG diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index d75e87aa8d..8bcfa7fdf7 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -1090,13 +1090,13 @@ cleanup: int kill(int pid, int signal) { - int rval = 0; - if (!TerminateProcess((HANDLE)pid, (UINT) signal)) { - rval = -1; - errno = b_errno_win32; - } - CloseHandle((HANDLE)pid); - return rval; + int rval = 0; + if (!TerminateProcess((HANDLE)pid, (UINT) signal)) { + rval = -1; + errno = b_errno_win32; + } + CloseHandle((HANDLE)pid); + return rval; } #ifndef HAVE_MINGW @@ -1104,37 +1104,40 @@ kill(int pid, int signal) int close_bpipe(BPIPE *bpipe) { - int rval = 0; - if (bpipe->rfd) fclose(bpipe->rfd); - if (bpipe->wfd) fclose(bpipe->wfd); - - if (bpipe->wait) { - int remaining_wait = bpipe->wait; - do { - DWORD exitCode; - if (!GetExitCodeProcess((HANDLE)bpipe->worker_pid, &exitCode)) { - const char *err = errorString(); - rval = b_errno_win32; - d_msg(__FILE__, __LINE__, 0, - "GetExitCode error %s\n", err); - LocalFree((void *)err); - break; - } - - if (exitCode == STILL_ACTIVE) { - bmicrosleep(1, 0); /* wait one second */ - remaining_wait--; - } - else break; - } while(remaining_wait); - rval = ETIME; /* timed out */ - } + int rval = 0; + if (bpipe->rfd) fclose(bpipe->rfd); + if (bpipe->wfd) fclose(bpipe->wfd); + + if (bpipe->wait) { + int remaining_wait = bpipe->wait; + do { + DWORD exitCode; + if (!GetExitCodeProcess((HANDLE)bpipe->worker_pid, &exitCode)) { + const char *err = errorString(); + rval = b_errno_win32; + d_msg(__FILE__, __LINE__, 0, + "GetExitCode error %s\n", err); + LocalFree((void *)err); + break; + } - if (bpipe->timer_id) { - stop_child_timer(bpipe->timer_id); - } - free((void *)bpipe); - return rval; + if (exitCode == STILL_ACTIVE) { + bmicrosleep(1, 0); /* wait one second */ + remaining_wait--; + } else if (exitCode != 0) { + rval = exitCode | b_errno_exit; + break; + } else { + break; + } + } while(remaining_wait); + rval = ETIME; /* timed out */ } + + if (bpipe->timer_id) { + stop_child_timer(bpipe->timer_id); + } + free((void *)bpipe); + return rval; } int