[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/2] New API: llz: This runs ls -laZ and is useful for showing SELinux contexts.



From: "Richard W.M. Jones" <rjones redhat com>

---
 daemon/ls.c                    |   26 ++++++++++++++++++++++++++
 generator/generator_actions.ml |    9 +++++++++
 src/MAX_PROC_NR                |    2 +-
 3 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/daemon/ls.c b/daemon/ls.c
index d0c7b52..1df0b6a 100644
--- a/daemon/ls.c
+++ b/daemon/ls.c
@@ -102,3 +102,29 @@ do_ll (const char *path)
   free (err);
   return out;			/* caller frees */
 }
+
+char *
+do_llz (const char *path)
+{
+  int r;
+  char *out, *err;
+  char *spath;
+
+  spath = sysroot_path (path);
+  if (!spath) {
+    reply_with_perror ("malloc");
+    return NULL;
+  }
+
+  r = command (&out, &err, "ls", "-laZ", spath, NULL);
+  free (spath);
+  if (r == -1) {
+    reply_with_error ("%s", err);
+    free (out);
+    free (err);
+    return NULL;
+  }
+
+  free (err);
+  return out;			/* caller frees */
+}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 3a7be79..f9ba5c3 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -6651,6 +6651,15 @@ This option may not be specified at the same time as the C<correct> option.
 
 =back");
 
+  ("llz", (RString "listing", [Pathname "directory"], []), 305, [],
+   [],
+   "list the files in a directory (long format with SELinux contexts)",
+   "\
+List the files in C<directory> in the format of 'ls -laZ'.
+
+This command is mostly useful for interactive sessions.  It
+is I<not> intended that you try to parse the output string.");
+
 ]
 
 let all_functions = non_daemon_functions @ daemon_functions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 873b744..67d04b9 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-304
+305
-- 
1.7.9


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]