]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/tools/bvfs_test.c
Tweak mutex order for SD
[bacula/bacula] / bacula / src / tools / bvfs_test.c
index 87555e50e4a8029befb2555fb7b455e806b439d5..5fa4d06dd9354f46d1feb37c37c5e21cc4958e49 100644 (file)
@@ -1,16 +1,7 @@
-/*
- *
- *  Program to test cache path
- *
- *   Eric Bollengier, March 2007
- *
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2009-2009 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ *  Program to test cache path
+ *
+ *   Eric Bollengier, August 2009
+ *
+ *
+ */
 
 #include "bacula.h"
 #include "cats/cats.h"
@@ -42,7 +41,7 @@
  
 /* Local variables */
 static B_DB *db;
-static char *file="COPYRIGHT";
+static const char *file = "COPYRIGHT";
 static DBId_t fnid=0;
 static const char *db_name = "regress";
 static const char *db_user = "regress";
@@ -75,21 +74,22 @@ static int result_handler(void *ctx, int fields, char **row)
 {
    Bvfs *vfs = (Bvfs *)ctx;
    ATTR *attr = vfs->get_attr();
-   char *empty = "A A A A A A A A A A A A A A";
+   char empty[] = "A A A A A A A A A A A A A A";
 
    memset(&attr->statp, 0, sizeof(struct stat));
    decode_stat((row[BVFS_LStat] && row[BVFS_LStat][0])?row[BVFS_LStat]:empty,
                &attr->statp, &attr->LinkFI);
 
-   if (fields == BVFS_DIR_RECORD || fields == BVFS_FILE_RECORD) {
+   if (bvfs_is_dir(row) || bvfs_is_file(row))
+   {
       /* display clean stuffs */
 
-      if (fields == BVFS_DIR_RECORD) {
+      if (bvfs_is_dir(row)) {
          pm_strcpy(attr->ofname, bvfs_basename_dir(row[BVFS_Name]));   
       } else {
          /* if we see the requested file, note his filenameid */
          if (bstrcmp(row[BVFS_Name], file)) {
-            fnid = str_to_int64(row[BVFS_Id]);
+            fnid = str_to_int64(row[BVFS_FilenameId]);
          }
          pm_strcpy(attr->ofname, row[BVFS_Name]);   
       }
@@ -97,7 +97,7 @@ static int result_handler(void *ctx, int fields, char **row)
 
    } else {
       Pmsg5(0, "JobId=%s FileId=%s\tMd5=%s\tVolName=%s\tVolInChanger=%s\n",
-            row[BVFS_JobId], row[BVFS_Id], row[BVFS_Md5], row[BVFS_VolName],
+            row[BVFS_JobId], row[BVFS_FileId], row[BVFS_Md5], row[BVFS_VolName],
             row[BVFS_VolInchanger]);
 
       pm_strcpy(attr->ofname, file);
@@ -112,7 +112,8 @@ static int result_handler(void *ctx, int fields, char **row)
 int main (int argc, char *argv[])
 {
    int ch;
-   char *jobids="1", *path=NULL, *client=NULL;
+   char *jobids = (char *)"1";
+   char *path=NULL, *client=NULL;
    uint64_t limit=0;
    bool clean=false;
    setlocale(LC_ALL, "");
@@ -227,9 +228,9 @@ int main (int argc, char *argv[])
 
    if (clean) {
       Pmsg0(0, "Clean old table\n");
-      db_sql_query(db, "DELETE FROM brestore_pathhierarchy", NULL, NULL);
-      db_sql_query(db, "DELETE FROM brestore_knownjobid", NULL, NULL);
-      db_sql_query(db, "DELETE FROM brestore_pathvisibility", NULL, NULL);
+      db_sql_query(db, "DELETE FROM PathHierarchy", NULL, NULL);
+      db_sql_query(db, "UPDATE Job SET HasCache=0", NULL, NULL);
+      db_sql_query(db, "DELETE FROM PathVisibility", NULL, NULL);
       bvfs_update_cache(bjcr, db);
    }