Pino Toscano
2015-Nov-23 16:58 UTC
[Libguestfs] [PATCH] fuse: fix return value of guestunmount for unmounted paths
Exit with 3 as return value when fusermount fails, because the specified mount point is not considered mounted for the user. This is in line with what the guestunmount documentation says. Adapt the test-guestunmount-fd test to the updated return value. Thanks to: Maxim Perevedentsev. --- fuse/guestunmount.c | 2 +- fuse/test-guestunmount-fd.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fuse/guestunmount.c b/fuse/guestunmount.c index e952c63..fa6d5bb 100644 --- a/fuse/guestunmount.c +++ b/fuse/guestunmount.c @@ -220,7 +220,7 @@ main (int argc, char *argv[]) free (error); - exit (2); + exit (3); /* success */ done: diff --git a/fuse/test-guestunmount-fd.c b/fuse/test-guestunmount-fd.c index 93adc98..b09a60f 100644 --- a/fuse/test-guestunmount-fd.c +++ b/fuse/test-guestunmount-fd.c @@ -107,8 +107,8 @@ main (int argc, char *argv[]) } /* Close the write side of the pipe. This should cause guestunmount - * to exit. It should exit with status code _2_ because we gave it - * a mountpoint which isn't a FUSE mountpoint. + * to exit. It should exit with status code _3_ because we gave it + * a directory which isn't a FUSE mountpoint. */ close (pipefd[1]); @@ -117,10 +117,10 @@ main (int argc, char *argv[]) perror ("waitpid"); exit (EXIT_FAILURE); } - if (!WIFEXITED (status) || WEXITSTATUS (status) != 2) { + if (!WIFEXITED (status) || WEXITSTATUS (status) != 3) { char status_string[80]; - fprintf (stderr, "%s: test failed: guestunmount didn't return status code 2; %s\n", + fprintf (stderr, "%s: test failed: guestunmount didn't return status code 3; %s\n", guestfs_int_program_name, guestfs_int_exit_status_to_string (status, "guestunmount", status_string, -- 2.1.0
Richard W.M. Jones
2015-Nov-24 15:26 UTC
Re: [Libguestfs] [PATCH] fuse: fix return value of guestunmount for unmounted paths
On Mon, Nov 23, 2015 at 05:58:44PM +0100, Pino Toscano wrote:> Exit with 3 as return value when fusermount fails, because the specified > mount point is not considered mounted for the user. This is in line > with what the guestunmount documentation says. > > Adapt the test-guestunmount-fd test to the updated return value. > > Thanks to: Maxim Perevedentsev. > --- > fuse/guestunmount.c | 2 +- > fuse/test-guestunmount-fd.c | 8 ++++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/fuse/guestunmount.c b/fuse/guestunmount.c > index e952c63..fa6d5bb 100644 > --- a/fuse/guestunmount.c > +++ b/fuse/guestunmount.c > @@ -220,7 +220,7 @@ main (int argc, char *argv[]) > > free (error); > > - exit (2); > + exit (3); > > /* success */ > done: > diff --git a/fuse/test-guestunmount-fd.c b/fuse/test-guestunmount-fd.c > index 93adc98..b09a60f 100644 > --- a/fuse/test-guestunmount-fd.c > +++ b/fuse/test-guestunmount-fd.c > @@ -107,8 +107,8 @@ main (int argc, char *argv[]) > } > > /* Close the write side of the pipe. This should cause guestunmount > - * to exit. It should exit with status code _2_ because we gave it > - * a mountpoint which isn't a FUSE mountpoint. > + * to exit. It should exit with status code _3_ because we gave it > + * a directory which isn't a FUSE mountpoint. > */ > close (pipefd[1]); > > @@ -117,10 +117,10 @@ main (int argc, char *argv[]) > perror ("waitpid"); > exit (EXIT_FAILURE); > } > - if (!WIFEXITED (status) || WEXITSTATUS (status) != 2) { > + if (!WIFEXITED (status) || WEXITSTATUS (status) != 3) { > char status_string[80]; > > - fprintf (stderr, "%s: test failed: guestunmount didn't return status code 2; %s\n", > + fprintf (stderr, "%s: test failed: guestunmount didn't return status code 3; %s\n", > guestfs_int_program_name, > guestfs_int_exit_status_to_string (status, "guestunmount", > status_string,Indeed this was buggy - thanks Maxim and Pino. ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/