Skip to content

Commit

Permalink
bcommand: Add type=<pooltype> filtering to .pools cmd.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Jun 11, 2016
1 parent 830bf89 commit 0d40ab9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/defaultconfigs/diskonly/bareos-dir.conf.in
Expand Up @@ -330,7 +330,7 @@ Pool {
#
Pool {
Name = Scratch
Pool Type = Backup
Pool Type = Scratch
}

#
Expand Down
2 changes: 1 addition & 1 deletion src/dird/ua_cmds.c
Expand Up @@ -192,7 +192,7 @@ static struct cmdstruct commands[] = {
{ NT_(".msgs"), dot_msgs_cmd, _("List all message resources"),
NULL, false, false },
{ NT_(".pools"), dot_pools_cmd, _("List all pool resources"),
NULL, true, false },
NT_("type=<pooltype>"), true, false },
{ NT_(".profiles"), dot_profiles_cmd, _("List all profile resources"),
NULL, true, false },
{ NT_(".quit"), quit_cmd, _("Close connection"),
Expand Down
16 changes: 13 additions & 3 deletions src/dird/ua_dotcmds.c
Expand Up @@ -942,15 +942,25 @@ bool dot_msgs_cmd(UAContext *ua, const char *cmd)

bool dot_pools_cmd(UAContext *ua, const char *cmd)
{
int pos, length;
POOLRES *pool;

pos = find_arg_with_value(ua, "type");
if (pos >= 0) {
length = strlen(ua->argv[pos]);
} else {
length = 0;
}

LockRes();
ua->send->array_start("pools");
foreach_res(pool, R_POOL) {
if (acl_access_ok(ua, Pool_ACL, pool->name())) {
ua->send->object_start();
ua->send->object_key_value("name", pool->name(), "%s\n");
ua->send->object_end();
if (pos == -1 || bstrncasecmp(pool->pool_type, ua->argv[pos], length)) {
ua->send->object_start();
ua->send->object_key_value("name", pool->name(), "%s\n");
ua->send->object_end();
}
}
}
ua->send->array_end("pools");
Expand Down

0 comments on commit 0d40ab9

Please sign in to comment.