search for: safe_asprintf

Displaying 20 results from an estimated 198 matches for "safe_asprintf".

2016 Dec 11
3
[PATCH 0/2] generic function for temporary path generation
Cosmetic change as suggested in this previous patch: https://www.redhat.com/archives/libguestfs/2016-November/msg00111.html Matteo Cafasso (2): lib: generic function for temporary path generation lib: use guestfs_int_make_temp_path to generate temporary files src/drives.c | 5 ++--- src/file.c | 22 +++++++++------------- src/guestfs-internal.h | 1 + src/journal.c
2012 Sep 20
1
[PATCH] rename local variable to avoid clash with match macro
...Hash_table **map) mdadm_app_free); if (!*map) g->abort_cb(); - for (char **match = matches; *match != NULL; match++) { + for (char **_match = matches; *_match != NULL; _match++) { /* Get device name and uuid for each array */ - char *dev_path = safe_asprintf(g, "%s/devicename", *match); + char *dev_path = safe_asprintf(g, "%s/devicename", *_match); char *dev = guestfs_aug_get(g, dev_path); free(dev_path); if (!dev) goto error; - char *uuid_path = safe_asprintf(g, "%s/uuid", *match); + char *uuid_p...
2017 Sep 19
0
[PATCH 6/6] lib: Use guestfs_int_make_temp_path in a few more places.
...986989e67..38dd2ef6d 100644 --- a/lib/appliance-uefi.c +++ b/lib/appliance-uefi.c @@ -74,7 +74,9 @@ guestfs_int_get_uefi (guestfs_h *g, char **code, char **vars, int *flags) * into the address space read-only as that triggers a different * path inside UEFI. */ - varst = safe_asprintf (g, "%s/vars.fd.%d", g->tmpdir, ++g->unique); + varst = guestfs_int_make_temp_path (g, "vars", "fd"); + if (!varst) + return -1; guestfs_int_cmd_add_arg (copycmd, "cp"); guestfs_int_cmd_add_arg (copycmd, varsfile);...
2015 Oct 16
1
[PATCH] inspect: Include more information for augeas parse errors (RHBZ#1229119)
...EFIX(*match, "/augeas/files") && - STREQLEN(*match + 13, configfiles[i], len) && - STREQ(*match + 13 + len, "/error")) { - error (g, _("augeas could not parse %s"), configfiles[i]); + CLEANUP_FREE char *errorpath = + safe_asprintf (g, "/augeas/files%s/error", configfiles[i]); + + if (STREQ (*match, errorpath)) { + /* Get the various error details. */ + guestfs_push_error_handler (g, NULL, NULL); + CLEANUP_FREE char *messagepath = + safe_asprintf (g, "%s/message", errorpa...
2016 Dec 11
0
[PATCH 2/2] lib: use guestfs_int_make_temp_path to generate temporary files
...(g) == -1) + tmpfile = guestfs_int_make_temp_path (g, "devnull"); + if (tmpfile == NULL) return NULL; /* Because we create a special file, there is no point forcing qemu @@ -429,8 +430,6 @@ create_drive_dev_null (guestfs_h *g, */ data->readonly = false; - tmpfile = safe_asprintf (g, "%s/devnull%d", g->tmpdir, ++g->unique); - if (guestfs_disk_create (g, tmpfile, "raw", 4096, -1) == -1) return NULL; diff --git a/src/file.c b/src/file.c index d57c4e1..53b859d 100644 --- a/src/file.c +++ b/src/file.c @@ -86,11 +86,10 @@ guestfs_impl_read_file...
2019 Dec 10
1
[PATCH] inspect: correct osinfo ID for CentOS >= 8
...644 --- a/lib/inspect-osinfo.c +++ b/lib/inspect-osinfo.c @@ -40,7 +40,9 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root) if (STREQ (type, "linux")) { if (STREQ (distro, "centos")) { - if (major >= 7) + if (major >= 8) + return safe_asprintf (g, "%s%d", distro, major); + else if (major == 7) return safe_asprintf (g, "%s%d.0", distro, major); else if (major == 6) return safe_asprintf (g, "%s%d.%d", distro, major, minor); -- 2.23.0
2013 Apr 30
1
[PATCH] ssh: fix setting the username part
...rc/drives.c b/src/drives.c index a13dd03..0e62ca8 100644 --- a/src/drives.c +++ b/src/drives.c @@ -1105,7 +1105,7 @@ guestfs___drive_source_qemu_param (guestfs_h *g, const struct drive_source *src) CLEANUP_FREE char *username = NULL, *port = NULL; if (src->username) - username = safe_asprintf (g, "%s@", username); + username = safe_asprintf (g, "%s@", src->username); if (src->servers[0].port != 0) port = safe_asprintf (g, ":%d", src->servers[0].port); -- 1.7.9.5
2016 May 18
2
[PATCH v2 0/2] lib: qemu: Memoize qemu feature detection.
v1 -> v2: - Rebase on top of Pino's version work. Two patches went upstream, these are the two remaining patches. Note the generation number is still inside the qemu.stat file. We could put it in the filename, I have no particular preference. Rich.
2016 May 12
7
[PATCH 0/4] lib: qemu: Memoize qemu feature detection.
Doing qemu feature detection in the direct backend takes ~100ms because we need to run `qemu -help' and `qemu -devices ?', and each of those interacts with glibc's very slow link loader. Fixing the link loader is really hard. Instead memoize the output of those two commands. This patch series first separates all the code dealing with qemu into a separate module (src/qemu.c) and
2018 Feb 21
3
[PATCH] New API: inspect_get_osinfo
...et_distro (g, root); + if (!distro) + return NULL; + major = guestfs_inspect_get_major_version (g, root); + minor = guestfs_inspect_get_minor_version (g, root); + + if (STREQ (type, "linux")) { + if (STREQ (distro, "centos")) { + if (major >= 7) + return safe_asprintf (g, "%s%d.0", distro, major); + else if (major == 6) + return safe_asprintf (g, "%s%d.%d", distro, major, minor); + } + else if (STREQ (distro, "debian")) { + if (major >= 4) + return safe_asprintf (g, "%s%d", distro, major);...
2019 Apr 02
6
[PATCH 0/5] Small inspection improvements
Few improvements to the results of the inspection on some distros. Pino Toscano (5): inspect: factorize list of rolling distros inspect: detect Gentoo from os-release inspect: fully detect Arch Linux from os-release inspect: return osinfo short IDs for rolling distros inspect: correct osinfo ID for ALT Linux >= 8 daemon/inspect_fs_unix.ml | 15 +++++++++------
2014 Jan 16
3
[PATCH 0/2] Don't use snapshot=on
QEMU upstream has broken snapshot=on ... again. These two patches stop using it entirely. Instead we run 'qemu-img create' to create overlay disks as required. Note that the libvirt and UML backends were already doing this: The libvirt backend because <transient/> has never worked, and the UML backend was running uml_mkcow because the UML-equivalent syntax of snapshot=on was
2013 Nov 03
2
[PATCH stable-1.24] Fix fstab block device resolution for FreeBSD
...;s'; + int disk_i = guestfs___parse_unsigned_int (g, disk); + int part_i = guestfs___parse_unsigned_int (g, part); + free (type); + free (disk); + free (part); + + if (disk_i != -1 && disk_i <= 26 && part_i > 0 && part_i <= 128) + device = safe_asprintf (g, "/dev/%cd%c%d", type_c, disk_i + 'a', part_i); + } + else if (match4 (g, spec, re_freebsd_mbr, &type, &disk, &slice, &part)) { /* FreeBSD disks are organized quite differently. See: * http://www.freebsd.org/doc/handbook/disk-organization.html...
2020 Jan 08
1
[PATCH] inspect: avoid returning "unknownX.Y" for unknown Linux distros
....c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c index ba07e4564..d2272dfdd 100644 --- a/lib/inspect-osinfo.c +++ b/lib/inspect-osinfo.c @@ -70,7 +70,7 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root) return safe_asprintf (g, "%s%d.%d", distro, major, minor); } - if (major > 0 || minor > 0) + if (STRNEQ (distro, "unknown") && (major > 0 || minor > 0)) return safe_asprintf (g, "%s%d.%d", distro, major, minor); } else if (STREQ (type, "fr...
2017 Sep 20
1
Re: [PATCH 6/6] lib: Use guestfs_int_make_temp_path in a few more places.
...dex bc469de59..7018c3ac0 100644 > --- a/lib/command.c > +++ b/lib/command.c > @@ -815,8 +815,9 @@ guestfs_int_cmd_pipe_run (struct command *cmd, const char *mode) > if (guestfs_int_lazy_make_tmpdir (cmd->g) == -1) > goto error; > > - cmd->error_file = > - safe_asprintf (cmd->g, "%s/cmderr.%d", cmd->g->tmpdir, ++cmd->g->unique); > + cmd->error_file = guestfs_int_make_temp_path (cmd->g, "cmderr", "txt"); > + if (!cmd->error_file) > + goto error; > errfd = open (cmd->error_file, >...
2016 May 12
0
[PATCH 3/4] appliance: Move code for creating supermin appliance directory to tmpdirs.c.
...uid_t uid, char **kernel, char **initrd, char **appliance) { - CLEANUP_FREE char *tmpdir = guestfs_get_cachedir (g); CLEANUP_FREE char *cachedir = NULL, *lockfile = NULL, *appliancedir = NULL; - struct stat statbuf; - cachedir = safe_asprintf (g, "%s/.guestfs-%ju", tmpdir, (uintmax_t) uid); - lockfile = safe_asprintf (g, "%s/lock", cachedir); + cachedir = guestfs_int_lazy_make_supermin_appliance_dir (g); + if (cachedir == NULL) + return -1; + appliancedir = safe_asprintf (g, "%s/appliance.d", cache...
2017 Sep 12
0
[PATCH v3 4/6] lib: qemu: Allow parallel qemu binaries to be used with cache conflicts.
...vious versions of * libguestfs. */ -#define MEMO_GENERATION 2 +#define MEMO_GENERATION 3 /** * Test that the qemu binary (or wrapper) runs, and do C<qemu -help> @@ -147,7 +148,7 @@ guestfs_int_test_qemu (guestfs_h *g) data = safe_calloc (g, 1, sizeof *data); - stat_filename = safe_asprintf (g, "%s/qemu.stat", cachedir); + stat_filename = cache_filename (g, cachedir, &statbuf, "stat"); r = read_cache_qemu_stat (g, data, stat_filename); if (r == -1) goto error; @@ -163,7 +164,7 @@ guestfs_int_test_qemu (guestfs_h *g) for (i = 0; i < NR_FIELDS...
2016 Sep 17
0
[PATCH 4/4] TSK: small refactoring
...; struct guestfs_tsk_dirent_list * guestfs_impl_filesystem_walk (guestfs_h *g, const char *mountable) { int ret = 0; - CLEANUP_FCLOSE FILE *fp = NULL; CLEANUP_UNLINK_FREE char *tmpfile = NULL; - ret = guestfs_int_lazy_make_tmpdir (g); - if (ret < 0) - return NULL; - - tmpfile = safe_asprintf (g, "%s/filesystem_walk%d", g->tmpdir, ++g->unique); + tmpfile = make_temp_file (g, "filesystem_walk"); ret = guestfs_internal_filesystem_walk (g, mountable, tmpfile); if (ret < 0) return NULL; - fp = fopen (tmpfile, "r"); - if (fp == NULL) { -...
2017 Sep 19
7
[PATCH 0/6] Various clean ups in lib/
Miscellaneous small cleanups in lib/ directory. Rich.
2016 May 17
2
[PATCH 0/2] Use -bios bios-fast.bin where supported.
NOTE: Not for upstream, yet. This depends on 3 non-upstream patches. - The qemu rework in libguestfs, which in turn depends on what Pino is up to. - Support for '-L ?' in qemu: https://lists.gnu.org/archive/html/qemu-devel/2016-05/threads.html#02596 - Support for bios-fast.bin in qemu: https://lists.gnu.org/archive/html/qemu-devel/2016-05/threads.html#02408 This commit