From: Eric Bollengier Date: Sun, 3 Oct 2010 15:27:25 +0000 (+0200) Subject: Add .bvfs_get_path to traduce a pathid into a path X-Git-Tag: Release-5.2.1~1055 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6e351d95d90caf02957ff49f4da855e7da6d1e3b;p=bacula%2Fbacula Add .bvfs_get_path to traduce a pathid into a path --- 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=/