From: Eric Bollengier Date: Thu, 9 Mar 2023 16:35:47 +0000 (+0100) Subject: Add .ls dironly parameter to list only client directories X-Git-Tag: Beta-15.0.0~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=424fc88407513923d48c7daaea59be969d5707f4;p=thirdparty%2Fbacula.git Add .ls dironly parameter to list only client directories --- diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index dd1daab16..2609b3e5b 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -732,13 +732,19 @@ bool send_ls_plugin_fileset(JCR *jcr, const char *plugin, const char *path) /* * Send a include list with only one directory and recurse=no */ -bool send_ls_fileset(JCR *jcr, const char *path) +bool send_ls_fileset(JCR *jcr, const char *path, bool dironly) { BSOCK *fd = jcr->file_bsock; fd->fsend(filesetcmd, "" /* no vss */, "" /* no snapshot */); fd->fsend("I\n"); - fd->fsend("O h\n"); /* Limit recursion to one directory */ + if (dironly) { /* Display only directories */ + fd->fsend("O eh\n"); /* Limit recursion to one directory */ + fd->fsend("WF *\n"); + + } else { + fd->fsend("O h\n"); /* Limit recursion to one directory */ + } fd->fsend("N\n"); fd->fsend("F %s\n", path); fd->fsend("N\n"); diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 4342653fe..1750dba3e 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -98,7 +98,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp); /* fd_cmds.c */ extern int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, int verbose); -extern bool send_ls_fileset(JCR *jcr, const char *path); +extern bool send_ls_fileset(JCR *jcr, const char *path, bool dironly); extern bool send_ls_plugin_fileset(JCR *jcr, const char *plugin, const char *path); extern bool send_include_list(JCR *jcr); extern bool send_exclude_list(JCR *jcr); diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 639026287..5c7f262ab 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -156,7 +156,7 @@ static struct dcmd_struct commands[] = { /* help */ /* can be used in runscript { NT_(".bvfs_delete_fileid"),dot_bvfs_delete_fileid, NULL, NULL, false}, { NT_(".setuid"), dot_setuid, _("Set UID/GID for the current session"), ".setuid uid= gid=", false}, { NT_(".ls"), dot_ls_cmd, _("List files/directories on Client"), - ".ls client= path= [plugin=]", false}, + ".ls client= path= [dironly] [plugin=]", false}, { NT_(".types"), typescmd, _("List Job Types defined"), NULL, false}, { NT_(".query"), dot_querycmd, _("Query Plugin's Client"), ".query client= plugin= parameter=", false}, @@ -260,6 +260,7 @@ static bool dot_ls_cmd(UAContext *ua, const char *cmd) JCR *jcr = ua->jcr; int i; bool ret = false; + bool dironly = false; jcr->setJobLevel(L_FULL); i = find_arg_with_value(ua, NT_("client")); @@ -288,6 +289,11 @@ static bool dot_ls_cmd(UAContext *ua, const char *cmd) return false; } + i = find_arg(ua, NT_("dironly")); + if (i > 0) { + dironly = true; + } + /* optional plugin=... parameter */ i = find_arg_with_value(ua, NT_("plugin")); if (i > 0) { @@ -316,7 +322,7 @@ static bool dot_ls_cmd(UAContext *ua, const char *cmd) goto bail_out; } } else { - if (!send_ls_fileset(jcr, path)) { + if (!send_ls_fileset(jcr, path, dironly)) { ua->error_msg(_("Failed to send command to Client.\n")); goto bail_out; }