search for: reply_with_perror

Displaying 20 results from an estimated 346 matches for "reply_with_perror".

Did you mean: reply_with_error
2020 Mar 12
0
[PATCH libguestfs 1/3] daemon: xattr: Refactor code which splits attr names from the kernel.
...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 = NULL; buf = _listxattrs (path, listxattr, &len); @@ -114,18 +144,17 @@ getxattrs (const char *path, /* _listxattrs issues reply_with_perror already. */ goto error; + names = split_attr_names (buf, len); + if (names == NULL) + goto error; + r = calloc (1, sizeof (*r)); if (r == NULL) { reply_with_perror ("calloc"); goto error; } - /* What we get from the kernel is a string "foo\0bar\0baz&...
2020 Mar 16
0
[PATCH libguestfs v2 1/3] daemon: xattr: Refactor code which splits attr names from the kernel.
...len, vlen; CLEANUP_FREE char *buf = NULL; - size_t i, j; + CLEANUP_FREE /* not string list */ char **names = NULL; + size_t i; guestfs_int_xattr_list *r = NULL; buf = _listxattrs (path, listxattr, &len); @@ -114,18 +141,17 @@ getxattrs (const char *path, /* _listxattrs issues reply_with_perror already. */ goto error; + names = split_attr_names (buf, len); + if (names == NULL) + goto error; + r = calloc (1, sizeof (*r)); if (r == NULL) { reply_with_perror ("calloc"); goto error; } - /* What we get from the kernel is a string "foo\0bar\0baz&...
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.
2014 Jan 10
4
Re: RFC: copy-attributes command
...char *src, const char *dest, int > > permissions, int xattributes) +{ > > + int r; > > + struct stat srcstat, deststat; > > + > > + CHROOT_IN; > > + r = stat (src, &srcstat); > > + CHROOT_OUT; > > + > > + if (r == -1) { > > + reply_with_perror ("stat: %s", src); > > + return -1; > > + } > > + > > + CHROOT_IN; > > + r = stat (dest, &deststat); > > + CHROOT_OUT; > > + > > + if (r == -1) { > > + reply_with_perror ("stat: %s", dest); > > + retur...
2009 Aug 03
1
[PATCH] Recognise cd-rom devices in devsparts.c
...*block_dev_func_t)(const char *dev); + +static int foreach_block_device (block_dev_func_t func); + char ** do_list_devices (void) { char **r = NULL; int size = 0, alloc = 0; - DIR *dir; - struct dirent *d; - char buf[256]; - - dir = opendir ("/sys/block"); - if (!dir) { - reply_with_perror ("opendir: /sys/block"); - return NULL; - } - while ((d = readdir (dir)) != NULL) { - if (strncmp (d->d_name, "sd", 2) == 0 || - strncmp (d->d_name, "hd", 2) == 0 || - strncmp (d->d_name, "vd", 2) == 0) { - snprintf (buf, sizeof buf, &...
2015 Jun 17
2
[PATCH] btrfs: keep calloc and its error message match
...--- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -479,7 +479,7 @@ do_btrfs_subvolume_list (const mountable_t *fs) ret->guestfs_int_btrfssubvolume_list_val = calloc (nr_subvolumes, sizeof (struct guestfs_int_btrfssubvolume)); if (ret->guestfs_int_btrfssubvolume_list_val == NULL) { - reply_with_perror ("malloc"); + reply_with_perror ("calloc"); goto error; } @@ -1292,7 +1292,7 @@ do_btrfs_qgroup_show (const char *path) ret->guestfs_int_btrfsqgroup_list_val = calloc (nr_qgroups, sizeof (struct guestfs_int_btrfsqgroup)); if (ret->guestfs_int_btrfsq...
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 15
1
[PATCH] daemon: resolve paths for ll and llz
...- */ - char * do_ll (const char *path) { int r; char *out; CLEANUP_FREE char *err = NULL; + CLEANUP_FREE char *rpath = NULL; CLEANUP_FREE char *spath = NULL; - spath = sysroot_path (path); + CHROOT_IN; + rpath = realpath (path, NULL); + CHROOT_OUT; + if (rpath == NULL) { + reply_with_perror ("%s", path); + return NULL; + } + + spath = sysroot_path (rpath); if (!spath) { reply_with_perror ("malloc"); return NULL; @@ -131,9 +134,18 @@ do_llz (const char *path) int r; char *out; CLEANUP_FREE char *err = NULL; + CLEANUP_FREE char *rpath = NU...
2014 Jan 10
0
[PATCH] daemon: xattr: move the listxattrs code in an own function
...char *list, size_t size), ssize_t *size); guestfs_int_xattr_list * do_getxattrs (const char *path) @@ -111,27 +112,10 @@ getxattrs (const char *path, size_t i, j; guestfs_int_xattr_list *r = NULL; - CHROOT_IN; - len = listxattr (path, NULL, 0); - CHROOT_OUT; - if (len == -1) { - reply_with_perror ("listxattr: %s", path); + buf = _listxattrs (path, listxattr, &len); + if (buf == NULL) + /* _listxattrs issues reply_with_perror already. */ goto error; - } - - buf = malloc (len); - if (buf == NULL) { - reply_with_perror ("malloc"); - goto error; - } -...
2016 Jul 07
0
[PATCH 2/2] daemon: fix cleanup of stringsbuf usages
...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 readdir didn't fail */ if (errno != 0) { reply_with_perror ("readdir: /sys/block"); - free_stringslen (r.argv, r.size); closedir (dir); return NULL; } @@ -101,7 +100,6 @@ do_list_9p (void) /* Close the directory handle */ if (closedir (dir) == -1) { reply_with_perror ("closedir: /sys/block"); - free_strings...
2016 Jul 07
2
[PATCH 1/2] daemon: free the string on stringsbuf add failure
...abels (void) error: if (dir) closedir (dir); - free (rawdev); return NULL; } diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 8b9acc7..af151bd 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -512,6 +512,7 @@ add_string_nodup (struct stringsbuf *sb, char *str) reply_with_perror ("realloc"); free_stringslen (sb->argv, sb->size); sb->argv = NULL; + free (str); return -1; } sb->argv = new_argv; -- 2.5.5
2018 May 03
1
[PATCH] daemon: fix memory allocation and leaks in OCaml stubs
...uc_typ typ; + pr " guestfs_int_%s *real_ret;\n" typ; pr " value v;\n"; pr "\n"; - pr " ret = malloc (sizeof (*ret));\n"; + pr " ret = calloc (1, sizeof (*ret));\n"; pr " if (ret == NULL) {\n"; - pr " reply_with_perror (\"malloc\");\n"; + pr " reply_with_perror (\"calloc\");\n"; pr " return NULL;\n"; pr " }\n"; pr "\n"; @@ -644,16 +646,20 @@ let generate_daemon_caml_stubs () = pr " ret->%s = Int_val (v);...
2009 Aug 11
1
[PATCH libguestfs] generator.ml: constify do_mkdtemp
...a/daemon/dir.c +++ b/daemon/dir.c @@ -185,31 +185,20 @@ do_is_dir (const char *path) } char * -do_mkdtemp (char *template) +do_mkdtemp (const char *template) { - char *r; - - NEED_ROOT (return NULL); - ABS_PATH (template, return NULL); + char *r = strdup (template); + if (r == NULL) { + reply_with_perror ("strdup"); + return NULL; + } CHROOT_IN; - r = mkdtemp (template); + r = mkdtemp (r); CHROOT_OUT; - if (r == NULL) { + if (r == NULL) reply_with_perror ("mkdtemp: %s", template); - return NULL; - } - /* The caller will free template AND try to free th...
2014 Nov 23
0
[PATCH 3/3] New APIs: bmap-file, bmap-device, bmap.
...c void +bmap_finalize (void) +{ + if (fd >= 0) { + close (fd); + fd = -1; + } + if (dir != NULL) { + closedir (dir); + dir = NULL; + } +} + +static int +bmap_prepare (const char *path, const char *orig_path) +{ + bmap_finalize (); + + if (stat (path, &statbuf) == -1) { + reply_with_perror ("%s", orig_path); + return -1; + } + + if (S_ISDIR (statbuf.st_mode)) { + /* Open a directory. */ + dir = opendir (path); + if (dir == NULL) { + reply_with_perror ("opendir: %s", orig_path); + return -1; + } + } + else { + /* Open a regular file....
2014 Dec 12
0
[PATCH v3 01/11] daemon: btrfs: add helper functions mount and umount
...on/btrfs.c @@ -326,6 +326,58 @@ do_btrfs_subvolume_create (const char *dest, const char *qgroupid) return 0; } +static char +*mount (const mountable_t *fs) +{ + char *fs_buf; + + if (fs->type == MOUNTABLE_PATH) { + fs_buf = sysroot_path (fs->device); + if (fs_buf == NULL) + reply_with_perror ("malloc"); + } else { + fs_buf = strdup ("/tmp/btrfs.XXXXXX"); + if (fs_buf == NULL) { + reply_with_perror ("strdup"); + return NULL; + } + + if (mkdtemp (fs_buf) == NULL) { + reply_with_perror ("mkdtemp"); + free (fs_buf); +...
2015 Sep 15
1
[PATCH] daemon: initrd: print return value from failing process
If either zcat or cpio fails when spawned in initrd-list, pclose will return the actual return value of it, but reply_with_perror still uses errno regardless; thus, the reported error is: libguestfs: error: initrd_list: pclose: Success which is not much helpful. Instead, when pclose returns > 0, extract the actual return value of the subprocess, and print that. Thus now we get for example: libguestfs: error: initrd...
2014 Jan 07
8
RFC: copy-attributes command
Hi, attached there is a prototype of patch for adding a new copy-attributes command. Such command would allow copy the attributes of a "file" to another, so for example in guestfish: copy-attributes foo bar permissions:true xattributes:false would only copy the permissions of foo to bar, not copying its extended attributes too. Just few notes: - my first daemon command, so
2012 Jan 24
14
[PATCH 00/14] Run the daemon under valgrind and fix resultant errors.
This patch series lets you run the daemon under valgrind. Many errors were found and fixed. With the complete series applied, valgrind doesn't show any errors.
2016 Mar 29
0
[PATCH 1/2] rename icat API to download_inode
...if (inode < 0) { - reply_with_error ("inode must be >= 0"); + reply_with_error("inode must be >= 0"); + return -1; } /* Construct the command. */ - if (asprintf (&cmd, "icat -r %s %" PRIi64, mountable->device, inode) == -1) { - reply_with_perror ("asprintf"); + if (asprintf(&cmd, "%s -r %s %" PRIi64, + str_icat, mountable->device, inode) == -1) { + reply_with_perror("asprintf"); + return -1; } - return file_out (cmd); + return send_command_output(cmd); } -static int -file_...
2014 Nov 23
7
[PATCH 0/3] patches needed for virt-bmap
See http://rwmj.wordpress.com/2014/11/23/mapping-files-to-disk/