Displaying 20 results from an estimated 92 matches for "declare_stringsbuf".
2016 Jul 07
0
[PATCH 2/2] daemon: fix cleanup of stringsbuf usages
...on/mount.c | 13 ++++---------
15 files changed, 65 insertions(+), 120 deletions(-)
diff --git a/daemon/9p.c b/daemon/9p.c
index fefbb71..a9e36d1 100644
--- a/daemon/9p.c
+++ b/daemon/9p.c
@@ -41,7 +41,7 @@ static char *read_whole_file (const char *filename);
char **
do_list_9p (void)
{
- DECLARE_STRINGSBUF (r);
+ CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (r);
DIR *dir;
@@ -60,7 +60,7 @@ do_list_9p (void)
if (end_stringsbuf (&r) == -1)
return NULL;
- return r.argv;
+ return take_stringsbuf (&r);
}
while (1) {
@@ -93,7 +93,6 @@ do_list_9p (void)
/* Check...
2016 Jul 07
2
[PATCH 1/2] daemon: free the string on stringsbuf add failure
...et, "") == -1)
return NULL;
diff --git a/daemon/devsparts.c b/daemon/devsparts.c
index 7c690f8..41c728c 100644
--- a/daemon/devsparts.c
+++ b/daemon/devsparts.c
@@ -311,7 +311,6 @@ do_list_disk_labels (void)
{
DIR *dir = NULL;
struct dirent *d;
- char *rawdev = NULL;
DECLARE_STRINGSBUF (ret);
dir = opendir (GUESTFSDIR);
@@ -330,6 +329,7 @@ do_list_disk_labels (void)
errno = 0;
while ((d = readdir (dir)) != NULL) {
CLEANUP_FREE char *path = NULL;
+ char *rawdev;
if (d->d_name[0] == '.')
continue;
@@ -347,12 +347,13 @@ do_list_disk_labels...
2012 Mar 13
2
[PATCH 0/2] 'int' to 'size_t' changes
These two patches are probably not completely independent, but
separating them is a lot of work.
With *both* patches applied, all the tests and extra-tests pass.
That's no guarantee however that there isn't a mistake, so I don't
think this patch is a candidate for the 1.16 branch, until it's had a
lot more testing in development.
Rich.
2014 Mar 21
2
[PATCH] listfs: If LDM not available, don't inhibit partition detection (RHBZ#1079182).
...parseable as plain old NTFS.
---
src/listfs.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/listfs.c b/src/listfs.c
index bbdb0a2..ffb0adc 100644
--- a/src/listfs.c
+++ b/src/listfs.c
@@ -47,8 +47,11 @@ guestfs__list_filesystems (guestfs_h *g)
{
size_t i;
DECLARE_STRINGSBUF (ret);
+
const char *lvm2[] = { "lvm2", NULL };
+ int has_lvm2 = guestfs_feature_available (g, (char **) lvm2);
const char *ldm[] = { "ldm", NULL };
+ int has_ldm = guestfs_feature_available (g, (char **) ldm);
CLEANUP_FREE_STRING_LIST char **devices = NULL;
CLEA...
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
2015 Jun 17
0
[PATCH 4/4] daemon: add split_lines_sb
...because it's the 'out' string
* from command()). You can free the original string, because
* add_string() strdups the strings.
+ *
+ * argv in the stringsbuf will be NULL in case of errors.
*/
-char **
-split_lines (char *str)
+struct stringsbuf
+split_lines_sb (char *str)
{
DECLARE_STRINGSBUF (lines);
+ DECLARE_STRINGSBUF (null);
char *p, *pend;
- if (STREQ (str, ""))
- return empty_list ();
+ if (STREQ (str, "")) {
+ /* No need to check the return value, as the stringsbuf will be
+ * returned as it is anyway.
+ */
+ end_stringsbuf (&line...
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
@@
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.
2015 Jun 17
2
Re: [PATCH] New API: btrfs_device_stats
...+{
>> + const size_t MAX_ARGS = 64;
>> + const char *argv[MAX_ARGS];
>> + size_t i = 0;
>> + CLEANUP_FREE char *buf = NULL;
>> + CLEANUP_FREE char *err = NULL;
>> + CLEANUP_FREE char *out = NULL;
>> + char *p, *key = NULL, *value = NULL;
>> + DECLARE_STRINGSBUF (ret);
>
> 'ret' is leaked if returning before "return ret.argv".
>
yup...will fix this. see some other APIs have the same problem.
>> + int r;
>> + int is_dev;
>> +
>> + is_dev = STREQLEN (path, "/dev/", 5);
>> + buf = is_dev...
2017 Jul 14
0
[PATCH 23/27] daemon: Reimplement ‘md_detail’ API in OCaml.
...8,72 +218,6 @@ do_md_create (const char *name, char *const *devices,
#pragma GCC diagnostic pop
#endif
-char **
-do_md_detail (const char *md)
-{
- size_t i;
- int r;
-
- CLEANUP_FREE char *out = NULL, *err = NULL;
- CLEANUP_FREE_STRING_LIST char **lines = NULL;
-
- CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (ret);
-
- const char *mdadm[] = { str_mdadm, "-D", "--export", md, NULL };
- r = commandv (&out, &err, mdadm);
- if (r == -1) {
- reply_with_error ("%s", err);
- return NULL;
- }
-
- /* Split the command output into lines */
- lines = split_lines (...
2017 Jan 19
3
[PATCH 1/2] daemon: Fix part-to-dev when the partition name includes p<N>.
From: Pino Toscano <ptoscano@redhat.com>
If the device name ends with a number, Linux uses partition names of
the form <device>p<N>. Handle this case by knocking off the 'p'
character.
---
daemon/devsparts.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/daemon/devsparts.c b/daemon/devsparts.c
index 5862ae2..b764f63 100644
--- a/daemon/devsparts.c
+++
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
2016 Jan 27
4
[PATCH] lvm: support lvm2 older than 2.02.107
...ret.argv;
}
+/* 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;
+ DECLARE_STRINGSBUF (ret);
+
+ p = out;
+ while (p) {
+ size_t len;
+ char *saveptr;
+ char *lv_attr, *vg_name, *lv_name;
+
+ pend = strchr (p, '\n'); /* Get the next line of output. */
+ if (pend) {
+ *pend = '\0';
+ pend++;
+ }
+
+ while (*p && c_isspace (*p))...
2015 Jun 19
2
[PATCH v2 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
@@
2015 Jul 13
1
[PATCH] daemon: add a space after func name to fit code-style
...sertions(+), 15 deletions(-)
diff --git a/daemon/blkid.c b/daemon/blkid.c
index 1ac42b4..74d2fa6 100644
--- a/daemon/blkid.c
+++ b/daemon/blkid.c
@@ -199,7 +199,7 @@ error:
}
static char **
-blkid_without_p_i_opt(const char *device)
+blkid_without_p_i_opt (const char *device)
{
char *s;
DECLARE_STRINGSBUF (ret);
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index ee3464d..50b0ba8 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -876,7 +876,7 @@ btrfs_set_uuid (const char *device, const char *uuid)
int has_uuid_opts = test_btrfstune_uuid_opt ();
if (has_uuid_opts <= 0)
- NOT_SUPPORTED...
2015 Jun 16
2
[PATCH] New API: btrfs_device_stats
...urn 0;
}
+
+char **
+do_btrfs_device_stats (const char *path, int zero)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ char *p, *key = NULL, *value = NULL;
+ DECLARE_STRINGSBUF (ret);
+ int r;
+ int is_dev;
+
+ is_dev = STREQLEN (path, "/dev/", 5);
+ buf = is_dev ? strdup (path) : sysroot_path (path);
+ if (buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "devic...
2015 Jun 17
0
Re: [PATCH] New API: btrfs_device_stats
...GS = 64;
> >> + const char *argv[MAX_ARGS];
> >> + size_t i = 0;
> >> + CLEANUP_FREE char *buf = NULL;
> >> + CLEANUP_FREE char *err = NULL;
> >> + CLEANUP_FREE char *out = NULL;
> >> + char *p, *key = NULL, *value = NULL;
> >> + DECLARE_STRINGSBUF (ret);
> >
> > 'ret' is leaked if returning before "return ret.argv".
> >
>
> yup...will fix this. see some other APIs have the same problem.
I will send something to help with these issues, so no need to change
this for now.
> >> + if (add_s...
2015 Jun 19
0
[PATCH v2 2/2] New API: btrfs_device_stats
...ge,
return 0;
}
+char **
+do_btrfs_device_stats (const char *path)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ char *p, *key = NULL, *value = NULL;
+ DECLARE_STRINGSBUF (ret);
+ int r;
+ int is_dev;
+
+ is_dev = STREQLEN (path, "/dev/", 5);
+ buf = is_dev ? strdup (path) : sysroot_path (path);
+ if (buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "device&...
2015 Jun 19
0
[PATCH v3 2/2] New API: btrfs_device_stats
...ge,
return 0;
}
+char **
+do_btrfs_device_stats (const char *path)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ char *p, *key = NULL, *value = NULL;
+ DECLARE_STRINGSBUF (ret);
+ int r;
+ int is_dev;
+
+ is_dev = STREQLEN (path, "/dev/", 5);
+ buf = is_dev ? strdup (path) : sysroot_path (path);
+ if (buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "device&...
2017 Jan 19
0
[PATCH 2/2] daemon: Return MD partitions in guestfs_list_partitions (RHBZ#1414510).
...,7 @@ typedef int (*block_dev_func_t) (const char *dev, struct stringsbuf *r);
/* Execute a given function for each discovered block device */
static char **
-foreach_block_device (block_dev_func_t func)
+foreach_block_device (block_dev_func_t func, bool return_md)
{
CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (r);
DIR *dir;
@@ -60,7 +61,9 @@ foreach_block_device (block_dev_func_t func)
STREQLEN (d->d_name, "hd", 2) ||
STREQLEN (d->d_name, "ubd", 3) ||
STREQLEN (d->d_name, "vd", 2) ||
- STREQLEN (d->d_name, "sr", 2))...