Richard W.M. Jones
2015-Sep-29 11:55 UTC
Re: [Libguestfs] [PATCH 2/2] copy-in: error out early if the localpath does not exist (RHBZ#1267032)
On Tue, Sep 29, 2015 at 11:38:52AM +0200, Pino Toscano wrote:> --- > src/copy-in-out.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/copy-in-out.c b/src/copy-in-out.c > index 0dd8cd3..2b1e4d4 100644 > --- a/src/copy-in-out.c > +++ b/src/copy-in-out.c > @@ -47,6 +47,12 @@ guestfs_impl_copy_in (guestfs_h *g, const char *localpath, const char *remotedir > char buf[buf_len]; > const char *dirname, *basename; > CLEANUP_FREE char *tar_buf = NULL; > + struct stat statbuf; > + > + if (stat (localpath, &statbuf) == -1) { > + error (g, _("source '%s' does not exist (or cannot be read)"), localpath); > + return -1; > + } > > int remote_is_dir = guestfs_is_dir (g, remotedir); > if (remote_is_dir == -1)NACK. See the patch series I just posted. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Pino Toscano
2015-Sep-29 16:18 UTC
Re: [Libguestfs] [PATCH 2/2] copy-in: error out early if the localpath does not exist (RHBZ#1267032)
On Tuesday 29 September 2015 12:55:31 Richard W.M. Jones wrote:> On Tue, Sep 29, 2015 at 11:38:52AM +0200, Pino Toscano wrote: > > --- > > src/copy-in-out.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/src/copy-in-out.c b/src/copy-in-out.c > > index 0dd8cd3..2b1e4d4 100644 > > --- a/src/copy-in-out.c > > +++ b/src/copy-in-out.c > > @@ -47,6 +47,12 @@ guestfs_impl_copy_in (guestfs_h *g, const char *localpath, const char *remotedir > > char buf[buf_len]; > > const char *dirname, *basename; > > CLEANUP_FREE char *tar_buf = NULL; > > + struct stat statbuf; > > + > > + if (stat (localpath, &statbuf) == -1) { > > + error (g, _("source '%s' does not exist (or cannot be read)"), localpath); > > + return -1; > > + } > > > > int remote_is_dir = guestfs_is_dir (g, remotedir); > > if (remote_is_dir == -1) > > NACK. See the patch series I just posted.Would patch #2 be acceptable anyway, as simple starting check? -- Pino Toscano
Richard W.M. Jones
2015-Sep-29 16:45 UTC
Re: [Libguestfs] [PATCH 2/2] copy-in: error out early if the localpath does not exist (RHBZ#1267032)
On Tue, Sep 29, 2015 at 06:18:39PM +0200, Pino Toscano wrote:> On Tuesday 29 September 2015 12:55:31 Richard W.M. Jones wrote: > > On Tue, Sep 29, 2015 at 11:38:52AM +0200, Pino Toscano wrote: > > > --- > > > src/copy-in-out.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/src/copy-in-out.c b/src/copy-in-out.c > > > index 0dd8cd3..2b1e4d4 100644 > > > --- a/src/copy-in-out.c > > > +++ b/src/copy-in-out.c > > > @@ -47,6 +47,12 @@ guestfs_impl_copy_in (guestfs_h *g, const char *localpath, const char *remotedir > > > char buf[buf_len]; > > > const char *dirname, *basename; > > > CLEANUP_FREE char *tar_buf = NULL; > > > + struct stat statbuf; > > > + > > > + if (stat (localpath, &statbuf) == -1) { > > > + error (g, _("source '%s' does not exist (or cannot be read)"), localpath); > > > + return -1; > > > + } > > > > > > int remote_is_dir = guestfs_is_dir (g, remotedir); > > > if (remote_is_dir == -1) > > > > NACK. See the patch series I just posted. > > Would patch #2 be acceptable anyway, as simple starting check?Would it be better for it to use perrorf() there? I'm trying to think of a case where localpath could not be stat'ed, and yet tar would succeed, but I can't think of one. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Apparently Analagous Threads
- Re: [PATCH 2/2] copy-in: error out early if the localpath does not exist (RHBZ#1267032)
- [PATCH 2/2] copy-in: error out early if the localpath does not exist (RHBZ#1267032)
- [PATCH 1/2] copy-in: print tar stderr when it fails
- [PATCH v2] copy-in: error out early if the localpath does not exist
- Re: [PATCH 5/6] New APIs: copy-in and copy-out