search for: cleanup_unlink_free

Displaying 20 results from an estimated 81 matches for "cleanup_unlink_free".

2014 Aug 08
3
[PATCH] daemon: add CLEANUP_CLOSE
...+) diff --git a/daemon/daemon.h b/daemon/daemon.h index fb74e91..0caad45 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -173,6 +173,7 @@ asprintf_nowarn (char **strp, const char *fmt, ...) extern void cleanup_free (void *ptr); extern void cleanup_free_string_list (void *ptr); extern void cleanup_unlink_free (void *ptr); +extern void cleanup_close (void *ptr); /*-- in names.c (auto-generated) --*/ extern const char *function_names[]; @@ -405,10 +406,12 @@ is_zero (const char *buffer, size_t size) #define CLEANUP_FREE_STRING_LIST \ __attribute__((cleanup(cleanup_free_str...
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
2016 Sep 17
0
[PATCH 4/4] TSK: small refactoring
...deserialise_dirent_list (guestfs_h *, FILE *, struct guestfs_tsk_dirent_list *); +static char *make_temp_file (guestfs_h *, const char *); 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_filesyste...
2016 Jan 21
0
[PATCH v3 2/6] daemon: Split out command() functions and CLEANUP_* macros into separate files.
...lude "cleanups.h" + +/* Use by the CLEANUP_* macros. Do not call these directly. */ +void +cleanup_free (void *ptr) +{ + free (* (void **) ptr); +} + +extern void free_strings (char **argv); + +void +cleanup_free_string_list (void *ptr) +{ + free_strings (* (char ***) ptr); +} + +void +cleanup_unlink_free (void *ptr) +{ + char *filename = * (char **) ptr; + + if (filename) { + unlink (filename); + free (filename); + } +} + +void +cleanup_close (void *ptr) +{ + int fd = * (int *) ptr; + + if (fd >= 0) + close (fd); +} + +void +cleanup_aug_close (void *ptr) +{ + augeas *aug = * (auge...
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
2017 Apr 25
1
Re: [PATCH v8 4/8] New API: yara_load
...as **) ptr; > diff --git a/daemon/cleanups.h b/daemon/cleanups.h > index 6746e2744..a791244cb 100644 > --- a/daemon/cleanups.h > +++ b/daemon/cleanups.h > @@ -26,6 +26,7 @@ extern void cleanup_free (void *ptr); > extern void cleanup_free_string_list (void *ptr); > extern void cleanup_unlink_free (void *ptr); > extern void cleanup_close (void *ptr); > +extern void cleanup_fclose (void *ptr); > extern void cleanup_aug_close (void *ptr); > extern void cleanup_free_stringsbuf (void *ptr); > > @@ -35,6 +36,7 @@ extern void cleanup_free_stringsbuf (void *ptr); > __a...
2017 Jun 19
0
[PATCH v7 13/13] daemon: Link guestfsd with libutils.
...lude "cleanups.h" - -/* Use by the CLEANUP_* macros. Do not call these directly. */ -void -cleanup_free (void *ptr) -{ - free (* (void **) ptr); -} - -extern void free_strings (char **argv); - -void -cleanup_free_string_list (void *ptr) -{ - free_strings (* (char ***) ptr); -} - -void -cleanup_unlink_free (void *ptr) -{ - char *filename = * (char **) ptr; - - if (filename) { - unlink (filename); - free (filename); - } -} - -void -cleanup_close (void *ptr) -{ - const int fd = * (int *) ptr; - - if (fd >= 0) - close (fd); -} - -void -cleanup_fclose (void *ptr) -{ - FILE *f = * (FILE...
2016 Sep 17
7
[PATCH 0/4] New API - find_block
This series is ready for review but requires the previous one to be merged first: https://www.redhat.com/archives/libguestfs/2016-September/msg00101.html The find_block API allows the User to search all the filesystem entries referring to a given data block and returns a tsk_dirent structure for each of them. Use case examples: - Check whether a block containing a deleted file has been re-used
2014 Sep 04
10
[PATCH 0/5] use augeas for /etc/shadow
Hi, currently /etc/shadow is edited manually when needed (i.e. when setting the password for an user), and it is not changed when removing users. Import the upstream shadow.aug (currently in their development serie, but not part of any released version yet), and use it only when the augeas version is less than a potential 1.2.1 (covering also the case when the new version is just 1.3.0). Pino
2020 Feb 18
2
[PATCH] make-fs: Don't use du --apparent-size to estimate input size.
...s/make-fs.c b/make-fs/make-fs.c index 5d8c3a385..386142280 100644 --- a/make-fs/make-fs.c +++ b/make-fs/make-fs.c @@ -393,7 +393,7 @@ static int estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn) { struct stat statbuf; - const char *argv[6]; + const char *argv[5]; CLEANUP_UNLINK_FREE char *tmpfile = NULL; CLEANUP_FCLOSE FILE *fp = NULL; char line[256]; @@ -424,11 +424,10 @@ estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn) } argv[0] = "du"; - argv[1] = "--apparent-size"; - argv[2] = "-b"; - argv[...
2017 Mar 12
0
[PATCH v4 3/7] New API: yara_load
...d *ptr) { augeas *aug = * (augeas **) ptr; diff --git a/daemon/cleanups.h b/daemon/cleanups.h index 6746e2744..a791244cb 100644 --- a/daemon/cleanups.h +++ b/daemon/cleanups.h @@ -26,6 +26,7 @@ extern void cleanup_free (void *ptr); extern void cleanup_free_string_list (void *ptr); extern void cleanup_unlink_free (void *ptr); extern void cleanup_close (void *ptr); +extern void cleanup_fclose (void *ptr); extern void cleanup_aug_close (void *ptr); extern void cleanup_free_stringsbuf (void *ptr); @@ -35,6 +36,7 @@ extern void cleanup_free_stringsbuf (void *ptr); __attribute__((cleanup(cleanup_free_st...
2016 Nov 09
0
[PATCH v2 2/6] New API: yara_load
...estroy (compiler); +} + +#endif /* !HAVE_YARA */ diff --git a/daemon/cleanups.h b/daemon/cleanups.h index 6746e27..c61f646 100644 --- a/daemon/cleanups.h +++ b/daemon/cleanups.h @@ -26,8 +26,12 @@ extern void cleanup_free (void *ptr); extern void cleanup_free_string_list (void *ptr); extern void cleanup_unlink_free (void *ptr); extern void cleanup_close (void *ptr); +extern void cleanup_fclose (void *ptr); extern void cleanup_aug_close (void *ptr); extern void cleanup_free_stringsbuf (void *ptr); +#ifdef HAVE_YARA +extern void cleanup_destroy_yara_compiler (void *ptr); +#endif /* !HAVE_YARA */ #ifdef H...
2016 Dec 11
0
[PATCH 2/2] lib: use guestfs_int_make_temp_path to generate temporary files
...struct guestfs_tsk_dirent_list *); -static char *make_temp_file (guestfs_h *, const char *); struct guestfs_tsk_dirent_list * guestfs_impl_filesystem_walk (guestfs_h *g, const char *mountable) @@ -44,7 +43,7 @@ guestfs_impl_filesystem_walk (guestfs_h *g, const char *mountable) int ret = 0; CLEANUP_UNLINK_FREE char *tmpfile = NULL; - tmpfile = make_temp_file (g, "filesystem_walk"); + tmpfile = guestfs_int_make_temp_path (g, "filesystem_walk"); if (tmpfile == NULL) return NULL; @@ -61,7 +60,7 @@ guestfs_impl_find_inode (guestfs_h *g, const char *mountable, int64_t inode)...
2017 Apr 06
0
[PATCH v6 3/7] New API: yara_load
...d *ptr) { augeas *aug = * (augeas **) ptr; diff --git a/daemon/cleanups.h b/daemon/cleanups.h index 6746e2744..a791244cb 100644 --- a/daemon/cleanups.h +++ b/daemon/cleanups.h @@ -26,6 +26,7 @@ extern void cleanup_free (void *ptr); extern void cleanup_free_string_list (void *ptr); extern void cleanup_unlink_free (void *ptr); extern void cleanup_close (void *ptr); +extern void cleanup_fclose (void *ptr); extern void cleanup_aug_close (void *ptr); extern void cleanup_free_stringsbuf (void *ptr); @@ -35,6 +36,7 @@ extern void cleanup_free_stringsbuf (void *ptr); __attribute__((cleanup(cleanup_free_st...
2017 Apr 24
0
[PATCH v8 4/8] New API: yara_load
...d *ptr) { augeas *aug = * (augeas **) ptr; diff --git a/daemon/cleanups.h b/daemon/cleanups.h index 6746e2744..a791244cb 100644 --- a/daemon/cleanups.h +++ b/daemon/cleanups.h @@ -26,6 +26,7 @@ extern void cleanup_free (void *ptr); extern void cleanup_free_string_list (void *ptr); extern void cleanup_unlink_free (void *ptr); extern void cleanup_close (void *ptr); +extern void cleanup_fclose (void *ptr); extern void cleanup_aug_close (void *ptr); extern void cleanup_free_stringsbuf (void *ptr); @@ -35,6 +36,7 @@ extern void cleanup_free_stringsbuf (void *ptr); __attribute__((cleanup(cleanup_free_st...
2017 Apr 04
0
[PATCH v5 3/7] New API: yara_load
...d *ptr) { augeas *aug = * (augeas **) ptr; diff --git a/daemon/cleanups.h b/daemon/cleanups.h index 6746e2744..a791244cb 100644 --- a/daemon/cleanups.h +++ b/daemon/cleanups.h @@ -26,6 +26,7 @@ extern void cleanup_free (void *ptr); extern void cleanup_free_string_list (void *ptr); extern void cleanup_unlink_free (void *ptr); extern void cleanup_close (void *ptr); +extern void cleanup_fclose (void *ptr); extern void cleanup_aug_close (void *ptr); extern void cleanup_free_stringsbuf (void *ptr); @@ -35,6 +36,7 @@ extern void cleanup_free_stringsbuf (void *ptr); __attribute__((cleanup(cleanup_free_st...
2016 Jul 28
3
[PATCH] utils: add new CLEANUP_XMLFREE cleanup, to call xmlFree()
...ispose xmlChar* buffers. --- src/cleanup.c | 9 +++++++++ src/guestfs-internal-frontend.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/cleanup.c b/src/cleanup.c index 1aa3051..6c4558c 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -106,6 +106,15 @@ guestfs_int_cleanup_unlink_free (char **ptr) } void +guestfs_int_cleanup_xmlFree (void *ptr) +{ + xmlChar *buf = * (xmlChar **) ptr; + + if (buf) + xmlFree (buf); +} + +void guestfs_int_cleanup_xmlBufferFree (void *ptr) { xmlBufferPtr xb = * (xmlBufferPtr *) ptr; diff --git a/src/guestfs-internal-frontend.h b/src/gu...
2017 Mar 12
8
[PATCH v4 0/7] Feature: Yara file scanning
Rebase patches on top of 1.37.1. No changes since last series. Matteo Cafasso (7): daemon: expose file upload logic appliance: add yara dependency New API: yara_load New API: yara_destroy New API: internal_yara_scan New API: yara_scan yara_scan: added API tests appliance/packagelist.in | 4 + configure.ac | 1 + daemon/Makefile.am
2017 Feb 14
0
[PATCH 09/10] New API: mksquashfs
...r_mksquashfs, mksquashfs); + +int +optgroup_squashfs_available (void) +{ + return prog_exists (str_mksquashfs); +} + +/* Takes optional arguments, consult optargs_bitmask. */ +int +do_mksquashfs (const char *path, const char *compress, char *const *excludes) +{ + CLEANUP_FREE char *buf = NULL; + CLEANUP_UNLINK_FREE char *tmpfile = NULL; + CLEANUP_UNLINK_FREE char *exclude_from_file = NULL; + CLEANUP_FREE char *err = NULL; + CLEANUP_FREE char *buffer = NULL; + int r; + const char *argv[MAX_ARGS]; + size_t i = 0; + int fd; + FILE *fp; + + buf = sysroot_path (path); + if (buf == NULL) { + reply_with...
2020 Aug 13
2
[PATCH v3] appliance: extract UUID from QCOW2 disk image
...(r) != 0) { + guestfs_int_external_command_failed (g, r, "qemu-img dd", NULL); + return -1; + } + + return 0; +} + +/** + * Get the UUID from the appliance disk image. + */ +static char * +get_root_uuid (guestfs_h *g, const char *appliance) +{ + char *uuid = NULL; + int ret; + CLEANUP_UNLINK_FREE char *tmpfile = NULL; + + uuid = get_root_uuid_with_file (g, appliance); + if (uuid) { + return uuid; + } + + tmpfile = guestfs_int_make_temp_path (g, "root", "raw"); + if (!tmpfile) { + error (g, "get_root_uuid: failed to make temporary file"); + retur...