From 9423fef1929e91efe1b514a098228cfd511cd5fa Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 3 Oct 2010 17:27:25 +0200 Subject: [PATCH] Add .bvfs_get_path to traduce a pathid into a path --- bacula/src/dird/ua_dotcmds.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 6c7965453e..dc119285c0 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -75,11 +75,13 @@ static bool dot_bvfs_lsfiles(UAContext *ua, const char *cmd); static bool dot_bvfs_update(UAContext *ua, const char *cmd); 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_get_path(UAContext *ua, const char *cmd); static bool api_cmd(UAContext *ua, const char *cmd); static bool sql_cmd(UAContext *ua, const char *cmd); static bool dot_quit_cmd(UAContext *ua, const char *cmd); static bool dot_help_cmd(UAContext *ua, const char *cmd); +static int one_handler(void *ctx, int num_field, char **row); struct cmdstruct { const char *key; bool (*func)(UAContext *ua, const char *cmd); const char *help;const bool use_in_rs;}; static struct cmdstruct commands[] = { /* help */ /* can be used in runscript */ @@ -111,7 +113,8 @@ static struct cmdstruct commands[] = { /* help */ /* can be used in runscript * { NT_(".bvfs_update"), dot_bvfs_update, NULL, true}, { NT_(".bvfs_get_jobids"), dot_bvfs_get_jobids, NULL, true}, { NT_(".bvfs_versions"), dot_bvfs_versions, NULL, true}, - { NT_(".types"), typescmd, NULL, false} + { NT_(".bvfs_get_path"), dot_bvfs_get_path, NULL, true}, + { NT_(".types"), typescmd, NULL, false} }; #define comsize ((int)(sizeof(commands)/sizeof(struct cmdstruct))) @@ -315,6 +318,33 @@ static bool bvfs_parse_arg(UAContext *ua, return true; } +/* .bvfs_get_path pathid=10 + * -> /etc/ + */ +static bool dot_bvfs_get_path(UAContext *ua, const char *cmd) +{ + char buf[128]; + int i = find_arg_with_value(ua, NT_("pathid")); + if (!open_client_db(ua)) { + return false; + } + if (i >= 0) { + if (is_a_number(ua->argv[i])) { + bsnprintf(buf, sizeof(buf), "SELECT Path FROM Path WHERE PathId=%lld", + str_to_int64(ua->argv[i])); + + if (!db_sql_query(ua->db, buf, one_handler, (void *)ua)) + { + ua->error_msg("Can't find pathid\n"); + /* print error */ + } + } + } else { + ua->error_msg("Can't find pathid=\n"); + } + return true; +} + /* * .bvfs_lsfiles jobid=1,2,3,4 pathid=10 * .bvfs_lsfiles jobid=1,2,3,4 path=/ -- 2.39.5