]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add .ls dironly parameter to list only client directories
authorEric Bollengier <eric@baculasystems.com>
Thu, 9 Mar 2023 16:35:47 +0000 (17:35 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
bacula/src/dird/fd_cmds.c
bacula/src/dird/protos.h
bacula/src/dird/ua_dotcmds.c

index dd1daab166e61ed54bb0076269f27ce8d2a407a7..2609b3e5b2e62805f68a64b4b019e57124cea89c 100644 (file)
@@ -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");
index 4342653fef408b0be1ddc4d2269a300bb4f05871..1750dba3e21b1bfe4cadf7ad31a65e6666c09bdd 100644 (file)
@@ -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);
index 63902628773dd6fee4b66b40cd9876aef88999cf..5c7f262abe773dd56f3040a0527d4fbb2209456d 100644 (file)
@@ -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=<uid> gid=<gid>", false},
  { NT_(".ls"), dot_ls_cmd,                       _("List files/directories on Client"),
-                                                   ".ls client=<cli> path=<str> [plugin=<str>]",       false},
+                                                   ".ls client=<cli> path=<str> [dironly] [plugin=<str>]",       false},
  { NT_(".types"),      typescmd,                 _("List Job Types defined"),        NULL, false},
  { NT_(".query"),     dot_querycmd,              _("Query Plugin's Client"),
    ".query client=<cli> plugin=<str> parameter=<str>", 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;
       }