[vserver] Minor bug and patch: isDirectoryEmpty behaviour

From: Lars Bräuer <lb_at_mpexnet.de>
Date: Mon 15 Dec 2014 - 17:24:05 GMT
Message-ID: <548F1935.1040102@mpexnet.de>


while trying to install a vserver with vserver build I ran into massive problems when I tried to
install the vserver into a new LVM, which obviously has a "lost+found" directory.

After debugging the functions, I found out that in the function "base.initFilesystem" there is a
call for isDirectoryEmpty with "ignore lost+found" set to "1". In our older version of
util-vserver-build the test was still "test -z" which is now "-n" in the current git tree and works
for "isDirectoryEmpty <dir> 1".

Although there currently doesn't seem to be a use of "isDirectoryEmpty <dir> 0" (zero instead of no
value) so far, I tested this case while debugging and under the current circumstances it would never
work. So the "0" case should either be removed or fixed, to avoid future problems.

You can easily test the behaviour with this little test script:


function isDirectoryEmpty {
        test -n "$2" -o "$2" = 0 || echo -n "Unsetting ignore_lostfound"
       #This actually works for all cases:
       #test -z "$2" -o "$2" = 0 && echo -n "Unsetting ignore_lostfound"

echo -n "With ignore_lostfound 1:"
isDirectoryEmpty test 1

echo -n "With ignore_lostfound <empty> (should unset it):"
isDirectoryEmpty test

echo -n "With ignore_lostfound 0 (should unset it):"
isDirectoryEmpty test 0


So with this little patch the desired behaviour will be achieved:
--- /usr/lib/util-vserver/functions.orig 2013-01-14 22:51:34.000000000 +0100
+++ /usr/lib/util-vserver/functions 2014-12-15 15:37:43.000000000 +0100
@@ -91,7 +91,7 @@
         shopt -s nullglob || *

- test -n "$2" -o "$2" = 0 || ignore_lostfound=
+ test -z "$2" -o "$2" = 0 && ignore_lostfound=
         for i in "$1"/*; do
             case "$i" in


Best regards

Lars Bräuer
Received on Mon Dec 15 17:24:18 2014

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Mon 15 Dec 2014 - 17:24:18 GMT by hypermail 2.1.8