]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_dotcmds.c
Cleanup new timeout code for bconsole
[bacula/bacula] / bacula / src / dird / ua_dotcmds.c
index c444efa0a3f6079649f6d52c492a4fa06de6e715..b6ae1c38b9d29a714b6bcc514c5ce5866ee3d633 100644 (file)
@@ -66,9 +66,9 @@ static bool backupscmd(UAContext *ua, const char *cmd);
 static bool levelscmd(UAContext *ua, const char *cmd);
 static bool getmsgscmd(UAContext *ua, const char *cmd);
 
-static bool dot_lsdirs(UAContext *ua, const char *cmd);
-static bool dot_lsfiles(UAContext *ua, const char *cmd);
-static bool dot_update(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);
+static bool dot_bvfs_update(UAContext *ua, const char *cmd);
 
 static bool api_cmd(UAContext *ua, const char *cmd);
 static bool sql_cmd(UAContext *ua, const char *cmd);
@@ -94,9 +94,9 @@ static struct cmdstruct commands[] = { /* help */  /* can be used in runscript *
  { NT_(".sql"),        sql_cmd,          NULL,       false},
  { NT_(".status"),     dot_status_cmd,   NULL,       false},
  { NT_(".storage"),    storagecmd,       NULL,       true},
- { NT_(".lsdirs"),     dot_lsdirs,       NULL,       true},
- { NT_(".lsfiles"),    dot_lsfiles,      NULL,       true},
- { NT_(".update"),     dot_update,       NULL,       true},
+ { NT_(".bvfs_lsdirs"), dot_bvfs_lsdirs, NULL,       true},
+ { NT_(".bvfs_lsfiles"),dot_bvfs_lsfiles,NULL,       true},
+ { NT_(".bvfs_update"), dot_bvfs_update, NULL,       true},
  { NT_(".types"),      typescmd,         NULL,       false} 
              };
 #define comsize ((int)(sizeof(commands)/sizeof(struct cmdstruct)))
@@ -154,7 +154,7 @@ bool do_a_dot_command(UAContext *ua)
    return ok;
 }
 
-static bool dot_update(UAContext *ua, const char *cmd)
+static bool dot_bvfs_update(UAContext *ua, const char *cmd)
 {
 
    if (!open_client_db(ua)) {
@@ -163,9 +163,9 @@ static bool dot_update(UAContext *ua, const char *cmd)
 
    int pos = find_arg_with_value(ua, "jobid");
    if (pos != -1 && is_a_number_list(ua->argv[pos])) {
-      db_list_ctx jobids;
-      pm_strcpy(jobids.list, ua->argv[pos]);
-      bvfs_update_path_hierarchy_cache(ua->jcr, ua->db, &jobids);
+      POOL_MEM jobids;
+      pm_strcpy(jobids, ua->argv[pos]);
+      bvfs_update_path_hierarchy_cache(ua->jcr, ua->db, jobids.c_str());
    } else {
       /* update cache for all jobids */
       bvfs_update_cache(ua->jcr, ua->db);
@@ -178,17 +178,26 @@ static int bvfs_result_handler(void *ctx, int fields, char **row)
    UAContext *ua = (UAContext *)ctx;
    struct stat statp;
    int32_t LinkFI;
+   const char *fileid;
+   char *lstat;
    char empty[] = "A A A A A A A A A A A A A A";
 
+   lstat = (row[BVFS_LStat] && row[BVFS_LStat][0])?row[BVFS_LStat]:empty;
+   fileid = (row[BVFS_FileId] && row[BVFS_FileId][0])?row[BVFS_FileId]:"0";
+
    memset(&statp, 0, sizeof(struct stat));
-   decode_stat((row[BVFS_LStat] && row[BVFS_LStat][0])?row[BVFS_LStat]:empty,
-               &statp, &LinkFI);
+   decode_stat(lstat, &statp, &LinkFI);
 
-   if (fields == BVFS_DIR_RECORD) {
+   Dmsg1(0, "type=%s\n", row[0]);
+   if (bvfs_is_dir(row)) {
       char *path = bvfs_basename_dir(row[BVFS_Name]);
-      ua->send_msg("%s\t%s\t\%s\n", row[BVFS_Id], row[BVFS_JobId], path);
-   } else if (fields == BVFS_FILE_RECORD) {
-      ua->send_msg("%s\t%s\t\%s\n", row[BVFS_Id], row[BVFS_JobId], row[BVFS_Name]);
+      ua->send_msg("%s\t0\t%s\t%s\t%s\t%s\n", row[BVFS_PathId], fileid,
+                   row[BVFS_JobId], row[BVFS_LStat], path);
+
+   } else if (bvfs_is_file(row)) {
+      ua->send_msg("%s\t%s\t%s\t%s\t%s\t%s\n", row[BVFS_PathId],
+                   row[BVFS_FilenameId], fileid, row[BVFS_JobId],
+                   row[BVFS_LStat], row[BVFS_Name]);
    }
 
    return 0;
@@ -233,7 +242,7 @@ static bool bvfs_parse_arg(UAContext *ua,
       }
    }
 
-   if (!((pathid || path) && jobid)) {
+   if (!((*pathid || *path) && *jobid)) {
       return false;
    }
 
@@ -245,10 +254,10 @@ static bool bvfs_parse_arg(UAContext *ua,
 }
 
 /* 
- * .lsfiles jobid=1,2,3,4 pathid=10
- * .lsfiles jobid=1,2,3,4 path=/
+ * .bvfs_lsfiles jobid=1,2,3,4 pathid=10
+ * .bvfs_lsfiles jobid=1,2,3,4 path=/
  */
-static bool dot_lsfiles(UAContext *ua, const char *cmd)
+static bool dot_bvfs_lsfiles(UAContext *ua, const char *cmd)
 {
    DBId_t pathid=0;
    int limit=2000, offset=0;
@@ -280,11 +289,11 @@ static bool dot_lsfiles(UAContext *ua, const char *cmd)
 }
 
 /* 
- * .lsdirs jobid=1,2,3,4 pathid=10
- * .lsdirs jobid=1,2,3,4 path=/
- * .lsdirs jobid=1,2,3,4 path=
+ * .bvfs_lsdirs jobid=1,2,3,4 pathid=10
+ * .bvfs_lsdirs jobid=1,2,3,4 path=/
+ * .bvfs_lsdirs jobid=1,2,3,4 path=
  */
-static bool dot_lsdirs(UAContext *ua, const char *cmd)
+static bool dot_bvfs_lsdirs(UAContext *ua, const char *cmd)
 {
    DBId_t pathid=0;
    int limit=2000, offset=0;