]> git.sur5r.net Git - bacula/bacula/commitdiff
Add BACULA.DATA to HDR1 record
authorKern Sibbald <kern@sibbald.com>
Mon, 7 Feb 2005 21:35:05 +0000 (21:35 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 7 Feb 2005 21:35:05 +0000 (21:35 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1819 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/bscan.c
bacula/src/stored/label.c

index 503dd9aa3ac9917d0bf74c62f5bb904ccb8497e9..291c3d5ba901249444c21ddcc0b959e758c800fb 100644 (file)
@@ -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 <Volumes>      specify Volume names (separated by |)\n"
 "       -w <dir>          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;
 }
index 50c9dcc7ff09c9474967c4a12b28004e9e4e4203..cfda892467d4d119f9739a26f714b243aa3f00e1 100644 (file)
@@ -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) {