Pino Toscano
2015-Oct-15 13:46 UTC
[Libguestfs] [PATCH] Chop final '/' in output directory (RHBZ#1146753)
If the specified output directory ends with a slash, chop it then; leaving it in will create problems later, like creating the temporary directory inside the output directory (and not aside it), and trying to rename it to the directory containing it (which will fail indeed). --- src/supermin.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/supermin.ml b/src/supermin.ml index 9623229..3070b6b 100644 --- a/src/supermin.ml +++ b/src/supermin.ml @@ -186,6 +186,11 @@ let main () eprintf "supermin: output directory (-o option) must be supplied\n"; exit 1 ); + (* Chop final '/' in output directory (RHBZ#1146753). *) + let outputdir + let len = String.length outputdir in + if outputdir.[len - 1] == '/' then String.sub outputdir 0 (len - 1) + else outputdir in debug, mode, if_newer, inputs, lockfile, outputdir, (copy_kernel, dtb_wildcard, format, host_cpu, -- 2.1.0
Richard W.M. Jones
2015-Oct-15 13:51 UTC
Re: [Libguestfs] [PATCH] Chop final '/' in output directory (RHBZ#1146753)
On Thu, Oct 15, 2015 at 03:46:29PM +0200, Pino Toscano wrote:> If the specified output directory ends with a slash, chop it then; > leaving it in will create problems later, like creating the temporary > directory inside the output directory (and not aside it), and trying to > rename it to the directory containing it (which will fail indeed). > --- > src/supermin.ml | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/src/supermin.ml b/src/supermin.ml > index 9623229..3070b6b 100644 > --- a/src/supermin.ml > +++ b/src/supermin.ml > @@ -186,6 +186,11 @@ let main () > eprintf "supermin: output directory (-o option) must be supplied\n"; > exit 1 > ); > + (* Chop final '/' in output directory (RHBZ#1146753). *) > + let outputdir > + let len = String.length outputdir in > + if outputdir.[len - 1] == '/' then String.sub outputdir 0 (len - 1) > + else outputdir in > > debug, mode, if_newer, inputs, lockfile, outputdir, > (copy_kernel, dtb_wildcard, format, host_cpu,ACK. 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
Possibly Parallel Threads
- [PATCH 1/2] utils: import parse_size from libguestfs
- [PATCH 0/3] supermin: add --include-packagelist
- [PATCH 0/3] Miscellaneous improvements to supermin.
- [PATCH 2/2] Add --size for ext2 filesystem
- [supermin PATCH v2 0/4] Check for output results for --if-newer (RHBZ#1813809)