Displaying 20 results from an estimated 47 matches for "take_stringsbuf".
2016 Jul 07
0
[PATCH 2/2] daemon: fix cleanup of stringsbuf usages
Declare most of the stringsbuf as CLEANUP_FREE_STRINGSBUF, so they are
freed completely on stack unwind: use take_stringsbuf() in return
places to take away from the stringsbuf its content, and remove all the
manual calls to free_stringslen (no more needed now).
This requires to not use free_stringslen anymore on failure in the
helper functions of stringsbuf, which now leave the content as-is (might
be still useful even...
2016 Jul 07
2
[PATCH 1/2] daemon: free the string on stringsbuf add failure
If add_string_nodup fails free the passed string instead of leaking it,
as that string would have been owned by the stringbuf.
Adapt few places to this behaviour.
---
daemon/btrfs.c | 4 +---
daemon/devsparts.c | 8 ++++----
daemon/guestfsd.c | 1 +
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 9b52aa8..d70565a 100644
---
2015 Jun 17
4
[PATCH 1/4] daemon: introduce free_stringsbuf
Simple shortcut to easily cleanup a stringsbuf.
---
daemon/daemon.h | 1 +
daemon/guestfsd.c | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 53cb797..bed4dbc 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -92,6 +92,7 @@ extern int add_string (struct stringsbuf *sb, const char *str);
extern int add_sprintf (struct stringsbuf *sb, const
2020 Mar 12
8
[PATCH libguestfs 0/3] daemon: Fix various commands which break on NTFS-3g compressed files.
https://bugzilla.redhat.com/show_bug.cgi?id=1811539
Commands including virt-diff which read extended attributes will
sometimes fail on NTFS filesystems that are using system compressed.
The reason is complex, see comment 5 of the bug linked above.
This patch filters out the troublesome xattr. For justification, see
the comment I added in patch 3.
Patch 1 & 2 are refactoring.
I was on the
2017 Jul 14
0
[PATCH 23/27] daemon: Reimplement ‘md_detail’ API in OCaml.
...Ignore lines with no equals sign (shouldn't happen). Log to stderr so
- * it will show up in LIBGUESTFS_DEBUG. */
- fprintf (stderr, "md-detail: unexpected mdadm output ignored: %s", line);
- }
- }
-
- if (end_stringsbuf (&ret) == -1)
- return NULL;
-
- return take_stringsbuf (&ret);
-}
-
int
do_md_stop (const char *md)
{
diff --git a/daemon/md.ml b/daemon/md.ml
index caf87cf8f..ba045b5f7 100644
--- a/daemon/md.ml
+++ b/daemon/md.ml
@@ -46,3 +46,40 @@ let list_md_devices () =
(* Return the list sorted. *)
sort_device_names devs
+
+let md_detail md =
+ le...
2020 Mar 16
6
[PATCH libguestfs v2 0/3] daemon: Fix various commands which break on NTFS-3g compressed files.
v1 here:
https://www.redhat.com/archives/libguestfs/2020-March/msg00099.html
This one fixes most of the points picked up in review, and does not
strdup the strings which should keep down memory usage if that is a
concern.
Rich.
2017 Jul 14
0
[PATCH 14/27] daemon: Reimplement ‘lvs’ API in OCaml.
...@@ SOURCES_ML = \
is.ml \
ldm.ml \
link.ml \
+ lvm.ml \
mount.ml \
parted.ml \
realpath.ml \
diff --git a/daemon/lvm.c b/daemon/lvm.c
index 5d12b009f..072bf53b4 100644
--- a/daemon/lvm.c
+++ b/daemon/lvm.c
@@ -103,89 +103,6 @@ convert_lvm_output (char *out, const char *prefix)
return take_stringsbuf (&ret);
}
-/* Filter a colon-separated output of
- * lvs -o lv_attr,vg_name,lv_name
- * removing thin layouts, and building the device path as we expect it.
- *
- * This is used only when lvm has no -S.
- */
-static char **
-filter_convert_old_lvs_output (char *out)
-{
- char *p, *pend;
-...
2015 Jun 17
0
[PATCH 4/4] daemon: add split_lines_sb
...if (end_stringsbuf (&lines) == -1)
- return NULL;
+ if (end_stringsbuf (&lines) == -1) {
+ free_stringsbuf (&lines);
+ return null;
+ }
+
+ return lines;
+}
- return lines.argv;
+char **
+split_lines (char *str)
+{
+ struct stringsbuf sb = split_lines_sb (str);
+ return take_stringsbuf (&sb);
}
char **
--
2.1.0
2020 Mar 12
0
[PATCH libguestfs 2/3] daemon: Add filter_list utility function.
...(const char *str), char **strs)
+{
+ DECLARE_STRINGSBUF (ret);
+ size_t i;
+
+ for (i = 0; strs[i] != NULL; ++i) {
+ if (p (strs[i]) != 0) {
+ if (add_string (&ret, strs[i]) == -1)
+ return NULL;
+ }
+ }
+ if (end_stringsbuf (&ret) == -1)
+ return NULL;
+
+ return take_stringsbuf (&ret);
+}
+
/**
* Skip leading and trailing whitespace, updating the original string
* in-place.
--
2.25.0
2020 Mar 16
0
[PATCH libguestfs v2 2/3] daemon: Add filter_list utility function.
...const char *str), char **strs)
+{
+ DECLARE_STRINGSBUF (ret);
+ size_t i;
+
+ for (i = 0; strs[i] != NULL; ++i) {
+ if (p (strs[i])) {
+ if (add_string_nodup (&ret, strs[i]) == -1)
+ return NULL;
+ }
+ }
+ if (end_stringsbuf (&ret) == -1)
+ return NULL;
+
+ return take_stringsbuf (&ret);
+}
+
/**
* Skip leading and trailing whitespace, updating the original string
* in-place.
--
2.25.0
2020 Mar 16
0
[PATCH libguestfs v2 3/3] daemon: xattr: Filter out user.WofCompressedData from xattrs (RHBZ#1811539).
...4
--- a/daemon/xattr.c
+++ b/daemon/xattr.c
@@ -19,6 +19,8 @@
#include <config.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
#include <limits.h>
#include <unistd.h>
@@ -115,6 +117,29 @@ split_attr_names (char *buf, size_t len)
return take_stringsbuf (&ret);
}
+/* We hide one extended attribute automatically. This is used by NTFS
+ * to store the compressed contents of a file when using "CompactOS"
+ * (per-file compression). I justify this by:
+ *
+ * (1) The attribute is only used internally by NTFS. The actual file
+ * co...
2016 May 12
1
[PATCH] New API: btrfs-filesystem-show (RHBZ#1164765)
...ply_with_error_errno (ENODEV, "%s: missing devices", device);
+ return NULL;
+ } else {
+ reply_with_error ("unrecognized line in output from 'btrfs filesystem show': %s", lines[i]);
+ return NULL;
+ }
+ }
+
+ end_stringsbuf (&ret);
+
+ return take_stringsbuf (&ret);
+}
+
/* btrfs command add a new command
* inspect-internal min-dev-size <path>
* since v4.2
diff --git a/generator/actions.ml b/generator/actions.ml
index e5cb939..3566371 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12958,6 +12958,33 @@ and save it as F&l...
2017 Jun 19
0
[PATCH v7 13/13] daemon: Link guestfsd with libutils.
...((cleanup(cleanup_free_stringsbuf)))
+#else
+#define CLEANUP_AUG_CLOSE
+#define CLEANUP_FREE_STRINGSBUF
+#endif
+
/*-- in mount.c --*/
extern int mount_vfs_nochroot (const char *options, const char *vfstype,
@@ -109,21 +127,12 @@ extern int end_stringsbuf (struct stringsbuf *sb);
extern char **take_stringsbuf (struct stringsbuf *sb);
extern void free_stringsbuf (struct stringsbuf *sb);
-extern size_t count_strings (char *const *argv);
extern void sort_strings (char **argv, size_t len);
-extern void free_strings (char **argv);
extern void free_stringslen (char **argv, size_t len);
extern void sor...
2017 Jul 14
0
[PATCH 13/27] daemon: Reimplement ‘list_ldm_(volumes|partitions)’ APIs in OCaml.
..."rerun with LIBGUESTFS_DEBUG=1");
- goto error;
- }
-
- for (i = 0; i < devs.gl_pathc; ++i) {
- if (add_string (&ret, devs.gl_pathv[i]) == -1)
- goto error;
- }
-
- if (end_stringsbuf (&ret) == -1) goto error;
-
- globfree (&devs);
- return take_stringsbuf (&ret);
-
- error:
- globfree (&devs);
-
- return NULL;
-}
-
-/* All device mapper devices called /dev/mapper/ldm_vol_*. XXX We
- * could tighten this up in future if ldmtool had a way to read these
- * names back after they have been created.
- */
-char **
-do_list_ldm_volumes (void)
-{...
2017 Jul 14
0
[PATCH 05/27] daemon: Reimplement several devsparts APIs in OCaml.
...perror ("closedir: /sys/block");
- return NULL;
- }
-
- if (err)
- return NULL;
-
- /* Sort the devices. */
- if (r.size > 0)
- sort_device_names (r.argv, r.size);
-
- /* NULL terminate the list */
- if (end_stringsbuf (&r) == -1) {
- return NULL;
- }
-
- return take_stringsbuf (&r);
-}
-
-/* Add a device to the list of devices */
-static int
-add_device (const char *device, struct stringsbuf *r)
-{
- char *dev_path;
-
- if (asprintf (&dev_path, "/dev/%s", device) == -1) {
- reply_with_perror ("asprintf");
- return -1;
- }
-
- if (add...
2020 Mar 12
0
[PATCH libguestfs 1/3] daemon: xattr: Refactor code which splits attr names from the kernel.
...(ret);
+
+ for (i = 0; i < len; i += strlen (&buf[i]) + 1) {
+ if (add_string (&ret, &buf[i]) == -1) {
+ free_stringsbuf (&ret);
+ return NULL;
+ }
+ }
+ if (end_stringsbuf (&ret) == -1) {
+ free_stringsbuf (&ret);
+ return NULL;
+ }
+
+ return take_stringsbuf (&ret);
+}
+
static int
compare_xattrs (const void *vxa1, const void *vxa2)
{
@@ -106,7 +135,8 @@ getxattrs (const char *path,
{
ssize_t len, vlen;
CLEANUP_FREE char *buf = NULL;
- size_t i, j;
+ CLEANUP_FREE_STRING_LIST char **names = NULL;
+ size_t i;
guestfs_int_xattr_list *r...
2020 Mar 16
0
[PATCH libguestfs v2 1/3] daemon: xattr: Refactor code which splits attr names from the kernel.
...split_attr_names (char *buf, size_t len)
+{
+ size_t i;
+ DECLARE_STRINGSBUF (ret);
+
+ for (i = 0; i < len; i += strlen (&buf[i]) + 1) {
+ if (add_string_nodup (&ret, &buf[i]) == -1)
+ return NULL;
+ }
+ if (end_stringsbuf (&ret) == -1)
+ return NULL;
+
+ return take_stringsbuf (&ret);
+}
+
static int
compare_xattrs (const void *vxa1, const void *vxa2)
{
@@ -106,7 +132,8 @@ getxattrs (const char *path,
{
ssize_t len, vlen;
CLEANUP_FREE char *buf = NULL;
- size_t i, j;
+ CLEANUP_FREE /* not string list */ char **names = NULL;
+ size_t i;
guestfs_int_xat...
2017 Jul 14
0
[PATCH 19/27] daemon: Reimplement ‘list_filesystems’ API in the daemon, in OCaml.
...gle logical operating system
+(use C<guestfs_inspect_os> to look for OSes)." };
+
]
diff --git a/generator/daemon.ml b/generator/daemon.ml
index 83994e9d3..66b625388 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -573,6 +573,58 @@ return_string_list (value retv)
return take_stringsbuf (&ret); /* caller frees */
}
+/* Implement RString (RMountable, _). */
+static char *
+return_string_mountable (value retv)
+{
+ value typev = Field (retv, 0);
+ value devicev = Field (retv, 1);
+ value subvolv;
+ char *ret;
+
+ if (Is_long (typev)) { /* MountableDevice or Mountabl...
2015 Jun 19
3
[PATCH v3 1/2] Modify the function: analyze_line, make it more flexible
Mofify the function from a fixed delimiter to a variable. So,
it can be used in more APIs later. Also modified the existing
callers
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
daemon/btrfs.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 39392f7..caa28ca 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@
2017 Mar 06
7
[PATCH 0/6] Various Coverity fixes #2
Hi,
this patch series fixes few more issues discovered by Coverity.
Thanks,
Pino Toscano (6):
tail: check the return value pf guestfs_set_pgroup
daemon: btrfs: check end_stringsbuf return values everywhere
java: use cleanup handlers for structs (lists) as return values
lib: qemu: improve handling of FILE*
p2v: check more return values
p2v: fix possible close(-1) issue
cat/tail.c