From 3ed2dca25497b477925b05d6fa3abd58ffe7f279 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 7 Feb 2005 21:35:05 +0000 Subject: [PATCH] Add BACULA.DATA to HDR1 record git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1819 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/bscan.c | 17 +++++++++++------ bacula/src/stored/label.c | 19 +++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 503dd9aa3a..291c3d5ba9 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -91,7 +91,7 @@ static bool list_records = false; static int ignored_msgs = 0; static uint64_t currentVolumeSize; -static int64_t last_pct = -1; +static int last_pct = -1; static bool showProgress = false; static int num_jobs = 0; static int num_pools = 0; @@ -120,6 +120,7 @@ static void usage() " -p proceed inspite of I/O errors\n" " -r list records\n" " -s synchronize or store in database\n" +" -S show scan progress periodically\n" " -v verbose\n" " -V specify Volume names (separated by |)\n" " -w specify working directory (default from conf file)\n" @@ -256,10 +257,12 @@ int main (int argc, char *argv[]) } dev = bjcr->dcr->dev; if (showProgress) { + char ed1[50]; struct stat sb; fstat(dev->fd, &sb); currentVolumeSize = sb.st_size; - Pmsg1(000, _("Current Volume Size = %" llu "\n"), currentVolumeSize); + Pmsg1(000, _("First Volume Size = %sn"), + edit_uint64(currentVolumeSize, ed1)); } if ((db=db_init_database(NULL, db_name, db_user, db_password, @@ -321,10 +324,12 @@ static bool bscan_mount_next_read_volume(DCR *dcr) bool stat = mount_next_read_volume(dcr); if (showProgress) { + char ed1[50]; struct stat sb; fstat(dev->fd, &sb); currentVolumeSize = sb.st_size; - Pmsg1(000, _("Current Volume Size = %" llu "\n"), currentVolumeSize); + Pmsg1(000, _("First Volume Size = %sn"), + edit_uint64(currentVolumeSize, ed1)); } return stat; } @@ -362,9 +367,10 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) if (rec->data_len > 0) { mr.VolBytes += rec->data_len + WRITE_RECHDR_LENGTH; /* Accumulate Volume bytes */ if (showProgress) { - int64_t pct = (mr.VolBytes * 100) / currentVolumeSize; + char ed1[50]; + int pct = (mr.VolBytes * 100) / currentVolumeSize; if (pct != last_pct) { - fprintf(stdout, "done: %" lld "\n", pct); + fprintf(stdout, "done: %d%%\n", pct); fflush(stdout); last_pct = pct; } @@ -1180,7 +1186,6 @@ static JCR *create_jcr(JOB_DBR *jr, DEV_RECORD *rec, uint32_t JobId) jobjcr->VolSessionId = rec->VolSessionId; jobjcr->VolSessionTime = rec->VolSessionTime; jobjcr->ClientId = jr->ClientId; -// attach_jcr_to_device(dev, jobjcr); new_dcr(jobjcr, dev); return jobjcr; } diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 50c9dcc7ff..cfda892467 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -1003,7 +1003,9 @@ bool write_ansi_ibm_label(DCR *dcr, const char *VolName) Dmsg1(000, "Write ANSI label type=%d\n", label_type); len = strlen(VolName); if (len > 6) { - len = 6; /* max len ANSI label */ + Jmsg1(jcr, M_FATAL, 0, _("ANSI Volume label name \"%s\" longer than 6 chars.\n"), + VolName); + return false; } memset(label, ' ', sizeof(label)); ser_begin(label, sizeof(label)); @@ -1021,15 +1023,8 @@ bool write_ansi_ibm_label(DCR *dcr, const char *VolName) /* Now construct HDR1 label */ ser_begin(label, sizeof(label)); ser_bytes("HDR1", 4); - len = strlen(VolName); - if (len > 17) { - len = 17; /* Max filename len */ - } - ser_bytes(VolName, len); /* stick Volume name in Filename field */ - if (len > 6) { - len = 6; - } - ser_begin(&label[21], sizeof(label)-21); + ser_bytes("BACULA.DATA", 11); /* Filename field */ + ser_begin(&label[21], sizeof(label)-21); /* fileset field */ ser_bytes(VolName, len); /* write Vol Ser No. */ ser_begin(&label[27], sizeof(label)-27); ser_bytes("00010001000100", 14); /* File section, File seq no, Generation no */ @@ -1120,6 +1115,10 @@ static int read_ansi_ibm_label(DCR *dcr) Dmsg0(000, "No HDR1 label\n"); return VOL_NO_LABEL; } + if (strncmp("BACULA.DATA", &label[4], 11) != 0) { + Dmsg0(000, "HD1 not Bacula label\n"); + return VOL_NAME_ERROR; + } break; case 2: if (stat != 80 || strncmp("HDR2", label, 4) != 0) { -- 2.39.5