]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_dotcmds.c
Ensure that StorageId is updated after write
[bacula/bacula] / bacula / src / dird / ua_dotcmds.c
index 887387e4580bf56814023c8be92f25d4fbbf86c3..c90052b2ef6b79460add898e01e8b1801ba82c34 100644 (file)
@@ -71,6 +71,7 @@ static bool mediatypescmd(UAContext *ua, const char *cmd);
 static bool locationscmd(UAContext *ua, const char *cmd);
 static bool mediacmd(UAContext *ua, const char *cmd);
 static bool aopcmd(UAContext *ua, const char *cmd);
+static bool catalogscmd(UAContext *ua, const char *cmd);
 
 static bool dot_bvfs_lsdirs(UAContext *ua, const char *cmd);
 static bool dot_bvfs_lsfiles(UAContext *ua, const char *cmd);
@@ -79,6 +80,7 @@ static bool dot_bvfs_get_jobids(UAContext *ua, const char *cmd);
 static bool dot_bvfs_versions(UAContext *ua, const char *cmd);
 static bool dot_bvfs_restore(UAContext *ua, const char *cmd);
 static bool dot_bvfs_cleanup(UAContext *ua, const char *cmd);
+static bool dot_bvfs_clear_cache(UAContext *ua, const char *cmd);
 
 static bool api_cmd(UAContext *ua, const char *cmd);
 static bool sql_cmd(UAContext *ua, const char *cmd);
@@ -91,6 +93,7 @@ static struct cmdstruct commands[] = { /* help */  /* can be used in runscript *
  { NT_(".api"),        api_cmd,                  NULL,       false},
  { NT_(".backups"),    backupscmd,               NULL,       false},
  { NT_(".clients"),    clientscmd,               NULL,       true},
+ { NT_(".catalogs"),   catalogscmd,              NULL,       false},
  { NT_(".defaults"),   defaultscmd,              NULL,       false},
  { NT_(".die"),        admin_cmds,               NULL,       false},
  { NT_(".dump"),       admin_cmds,               NULL,       false},
@@ -118,8 +121,9 @@ static struct cmdstruct commands[] = { /* help */  /* can be used in runscript *
  { NT_(".bvfs_versions"), dot_bvfs_versions,     NULL,       true},
  { NT_(".bvfs_restore"), dot_bvfs_restore,       NULL,       true},
  { NT_(".bvfs_cleanup"), dot_bvfs_cleanup,       NULL,       true},
+ { NT_(".bvfs_clear_cache"),dot_bvfs_clear_cache,NULL,       false},
  { NT_(".types"),      typescmd,                 NULL,       false}
-             };
+};
 #define comsize ((int)(sizeof(commands)/sizeof(struct cmdstruct)))
 
 /*
@@ -182,7 +186,10 @@ static bool dot_bvfs_update(UAContext *ua, const char *cmd)
 
    int pos = find_arg_with_value(ua, "jobid");
    if (pos != -1 && is_a_number_list(ua->argv[pos])) {
-      bvfs_update_path_hierarchy_cache(ua->jcr, ua->db, ua->argv[pos]);
+      if (!bvfs_update_path_hierarchy_cache(ua->jcr, ua->db, ua->argv[pos])) {
+         ua->error_msg("ERROR: BVFS reported a problem for %s\n", 
+                       ua->argv[pos]);
+      }
    } else {
       /* update cache for all jobids */
       bvfs_update_cache(ua->jcr, ua->db);
@@ -192,6 +199,25 @@ static bool dot_bvfs_update(UAContext *ua, const char *cmd)
    return true;
 }
 
+static bool dot_bvfs_clear_cache(UAContext *ua, const char *cmd)
+{
+   if (!open_new_client_db(ua)) {
+      return 1;
+   }
+
+   int pos = find_arg(ua, "yes");
+   if (pos != -1) {
+      Bvfs fs(ua->jcr, ua->db);
+      fs.clear_cache();
+      ua->info_msg("OK\n");
+   } else {
+      ua->error_msg("Can't find 'yes' argument\n");
+   }
+
+   close_db(ua);
+   return true;
+}
+
 static int bvfs_result_handler(void *ctx, int fields, char **row)
 {
    UAContext *ua = (UAContext *)ctx;
@@ -522,6 +548,12 @@ static bool dot_bvfs_get_jobids(UAContext *ua, const char *cmd)
       return true;
    }
 
+   /* When in level base, we don't rely on any Full/Incr/Diff */
+   if (jr.JobLevel == L_BASE) {
+      ua->send_msg("%s\n", edit_int64(jr.JobId, ed1));
+      return true;
+   }
+
    /* If we have the "all" option, we do a search on all defined fileset
     * for this client
     */
@@ -727,6 +759,7 @@ static bool admin_cmds(UAContext *ua, const char *cmd)
          ua->send_msg(_("The Director will segment fault.\n"));
          a = jcr->JobId; /* ref NULL pointer */
          jcr->JobId = 1000; /* another ref NULL pointer */
+         jcr->JobId = a;
 
       } else if (strncmp(remote_cmd, ".dump", 5) == 0) {
          sm_dump(false, true);
@@ -788,6 +821,19 @@ static bool filesetscmd(UAContext *ua, const char *cmd)
    return true;
 }
 
+static bool catalogscmd(UAContext *ua, const char *cmd)
+{
+   CAT *cat;
+   LockRes();
+   foreach_res(cat, R_CATALOG) {
+      if (acl_access_ok(ua, Catalog_ACL, cat->name())) {
+         ua->send_msg("%s\n", cat->name());
+      }
+   }
+   UnlockRes();
+   return true;
+}
+
 static bool clientscmd(UAContext *ua, const char *cmd)
 {
    CLIENT *client;