Added opaque dir sematics
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Fri, 19 Oct 2007 22:15:39 +0000 (18:15 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Fri, 19 Oct 2007 22:15:39 +0000 (18:15 -0400)
More tests added to be generic:
1) lookup-opaque
2) mkdir
3) open-unlink
4) rename-matrix
5) symlink
6) truncate-all
7) unlink-whiteout

progs/Makefile
progs/get_branch_id.c [new file with mode: 0644]
scaffold
t-create.sh
t-lookup-opaque.sh
t-mkdir.sh
t-open-unlink.sh
t-rename-matrix.sh
t-symlink.sh
t-truncate-all.sh
t-unlink-whiteout.sh

index 659aca5523e00bee0dfcdb2c0fdd95750398e1b0..5d6a3b3e6dadf3f362b8fc196f53083f619967f1 100644 (file)
@@ -19,7 +19,7 @@
 CFLAGS=-g -Wall -Werror -luuid
 MOUNTPOINT=.
 BINS=open-unlink flock-copyup fsync truncate bug418 rmdircheckinode \
-       creat-open rename mapper queryfile mkodf_sb
+       creat-open rename mapper queryfile mkodf_sb get_branch_id
 
 all: $(BINS)
 
diff --git a/progs/get_branch_id.c b/progs/get_branch_id.c
new file mode 100644 (file)
index 0000000..5ed24d1
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007-2007 Erez Zadok
+ * Copyright (c) 2007-2007 Rachita Kothiyal
+ * Copyright (c) 2007-2007 Stony Brook University
+ * Copyright (c) 2007-2007 The Research Foundation of SUNY
+ *
+ * For specific licensing information, see the COPYING file distributed with
+ * this package.
+ *
+ * This Copyright notice must be kept intact and distributed with all sources.
+ */
+
+/* Get branch id for a branch, by path name*/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define UUID_LEN 16
+int main(int argc, char *argv[])
+{
+       int fd;
+       unsigned int version;
+       unsigned int no_branches;
+       unsigned int bid;
+       unsigned int pathlength;
+       char path[100];
+       unsigned int permission;
+       unsigned char *uuid;
+       int i;
+       size_t bytes;
+
+       uuid = (unsigned char *)malloc(UUID_LEN);
+
+       fd = open(argv[1], O_RDONLY, 0);
+       bytes = read(fd, &version, 4);
+       bytes = read(fd, &no_branches, 4);
+
+       for (i = 0; i < no_branches; i++) {
+               bytes = read(fd, &bid, 4);
+               bytes = read(fd, &pathlength, 4);
+               bytes = read(fd, path, pathlength);
+               path[pathlength] = '\0';
+               if (strcmp(path, argv[2]) == 0){
+                       printf("%d", bid);
+                       break;
+               } 
+               bytes = read(fd, &permission, 4);
+               bytes = read(fd, uuid, UUID_LEN);
+       }
+
+       close(fd);
+       free(uuid);
+       return 0;
+}
index c7363673d9ce4ba4e9809cf3ec701d06c6e9df0d..cf3436c5f663f5a10bcae3039fc03b3af7c8b2d5 100644 (file)
--- a/scaffold
+++ b/scaffold
@@ -58,11 +58,14 @@ function create_hierarchy {
                if [ "$TYPE" = "w" ]; then
                        WH_LOC=`echo $LINE | cut -d' ' -f 2`
                        NAME=`echo $LINE | cut -d' ' -f 3`
+               elif [ "$TYPE" = "o" ]; then
+                       OPQ_LOC=`echo $LINE | cut -d' ' -f 2`
+                       NAME=`echo $LINE | cut -d' ' -f 3`
                else
                        NAME=`echo $LINE | cut -d' ' -f 2`
                fi
 
-               unset DIR FILE IMMUTABLE SOURCE SYMLINK WH
+               unset DIR FILE IMMUTABLE SOURCE SYMLINK WH OPQ
 
                ( echo $TYPE | grep -q d ) && DIR=1
                ( echo $TYPE | grep -q f ) && FILE=1
@@ -70,6 +73,7 @@ function create_hierarchy {
                ( echo $TYPE | grep -q s ) && SOURCE=1
                ( echo $TYPE | grep -q l ) && SYMLINK=1
                ( echo $TYPE | grep -q w ) && WH=1
+               ( echo $TYPE | grep -q o ) && OPQ=1
 
                if [ ! -z "$SOURCE" ] ; then
                        if [ ! -z "$DIR" ] ; then
@@ -131,6 +135,17 @@ function create_hierarchy {
                                wh_abs_path=$wh_dir"/"$wh_file
                                touch $wh_abs_path
                        fi
+               elif [ ! -z "$OPQ" ]; then
+                       if [ "$ODF" -eq "1" ]; then
+                               if [ ! -d $ODF_DIR/ns/$NAME ]; then
+                                       mkdir -p $ODF_DIR"/ns/"$NAME || exit $?
+                               fi
+                               branch_id=$(./progs/get_branch_id $ODF_DIR/sb $OPQ_LOC)
+                               branch_id=`expr $branch_id + 1`;
+                               chgrp $branch_id $ODF_DIR"/ns/"$NAME
+                       else
+                               touch $OPQ_LOC"/"$NAME"/.wh.__dir_opaque"
+                       fi
                else
                        echo "What type am i: $TYPE" 1>&2
                        exit $?
@@ -204,13 +219,15 @@ function check_hierarchy {
        for i in $browse_path; do
         (
            if [ "$i" == $ODF_DIR/ns/ ]; then
-                   find $i -type f -samefile $ODF_DIR/whiteout | sed "s:$i:w $i :g"  
-                   break
+               find $i -type f -samefile $ODF_DIR/whiteout | sed "s:$i:w $i :g"
+               find $i -type d -gid +0 | sed "s:$i:o $i :g"
+               break
            fi
            find $i -type d -printf 'd %p\n'
            find $i -type f -not -name ".wh.*" -printf 'f %p\n'
            if [ $ODF -eq 0 ]; then
-                   find $i -type f -name ".wh.*" | sed "s:$i/:w $i :g" | sed "s:\.wh\.::g"
+                   find $i -type f -name ".wh.[a-zA-Z0-9]*" | sed "s:$i/:w $i :g" | sed "s:\.wh\.::g"
+                   find $i -type f -name ".wh.__dir_opaque" | sed "s:$i/:o $i :g" | sed "s:\/\.wh\.__dir_opaque::g"
            fi
            find $i -type b -printf 'b %p\n'
            find $i -type c -printf 'c %p\n'
@@ -229,6 +246,8 @@ function check_hierarchy {
                        first=`echo $line | cut -d" " -f 1`
                        if [ "$first" == "w" ]; then
                                echo $line | sed "s: [a-zA-Z0-9\/\_\-]* : $ODF_DIR/ns/ :g" >> /tmp/expected-$$-tmp
+                       elif [ "$first" == "o" ]; then
+                               echo $line | sed "s: [a-zA-Z0-9\/\_\-]* : $ODF_DIR/ns/ :g" >> /tmp/expected-$$-tmp
                        else
                                echo $line >> /tmp/expected-$$-tmp
                        fi
index 96436f82c67f7b6370cde66309c4c9a0edd840e3..ee362817f81a1845e6cf6ccfe0dd1ed937a86b7a 100644 (file)
@@ -102,7 +102,6 @@ fi
 function rw {
        init_odf $LOWER_DIR0 $LOWER_DIR1 $LOWER_DIR2 
        ( directories ; beforefiles ) | create_hierarchy
-
        mount_union "" $LOWER_DIR0 $LOWER_DIR1 $LOWER_DIR2
 
        touch $MOUNTPOINT/y
@@ -116,7 +115,6 @@ function rw {
 
        #Sanity check the lower level dirs/files
        ( directories ; afterfiles_rw )  | check_hierarchy
-
        discard_odf
 }
 
@@ -124,7 +122,6 @@ function rw {
 function ro {
        init_odf $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
        ( directories ; beforefiles ) | create_hierarchy
-
        mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
 
        touch $MOUNTPOINT/y
@@ -136,14 +133,12 @@ function ro {
 
        unmount_union
        ( directories ; afterfiles_ro )  | check_hierarchy
-
        discard_odf
 }
 
 function BUG383 {
        init_odf $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
        ( directories ; beforefiles_383 ) | create_hierarchy
-
        mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
 
        local SM=`umask`
@@ -163,7 +158,6 @@ function BUG383 {
 
        unmount_union
        ( directories ; afterfiles_383 )  | check_hierarchy
-
        discard_odf
 }
 
index 67699804b83946b4e6d5b6d81b881bd3af431c28..936c80a2a66d630b4ba429c403398e962593d26d 100755 (executable)
@@ -15,7 +15,7 @@ d $LOWER_DIR0/dir
 f $LOWER_DIR0/dir/ro
 d $LOWER_DIR1
 d $LOWER_DIR1/dir
-f $LOWER_DIR1/dir/.wh.__dir_opaque
+o $LOWER_DIR1 dir
 f $LOWER_DIR1/dir/rw
 d $LOWER_DIR2
 d $LOWER_DIR3
@@ -26,6 +26,7 @@ function cleanup {
        userdel -f -r $UNPRIV_USER
 }
 
+init_odf $LOWER_DIR1=rw $LOWER_DIR0=ro
 branch_files | create_hierarchy
 
 chmod 777 $LOWER_DIR0
@@ -33,7 +34,11 @@ chmod 777 $LOWER_DIR1
 chmod 700 $LOWER_DIR0/dir
 chmod 700 $LOWER_DIR1/dir
 chmod 644 $LOWER_DIR0/dir/ro
-chmod 644 $LOWER_DIR1/dir/.wh.__dir_opaque
+if [ $ODF -eq "0" ]; then
+       chmod 644 $LOWER_DIR1/dir/.wh.__dir_opaque
+else
+       chmod 644 $ODF_DIR/ns/dir
+fi
 chmod 644 $LOWER_DIR1/dir/rw
 
 PRIV_USER="root"
@@ -51,7 +56,11 @@ chown $UNPRIV_USER $LOWER_DIR1
 chown $PRIV_USER $LOWER_DIR0/dir
 chown $PRIV_USER $LOWER_DIR1/dir
 chown $UNPRIV_USER $LOWER_DIR0/dir/ro
-chown $UNPRIV_USER $LOWER_DIR1/dir/.wh.__dir_opaque
+if [ $ODF -eq "0" ]; then
+       chown $UNPRIV_USER $LOWER_DIR1/dir/.wh.__dir_opaque
+else
+       chown $UNPRIV_USER $ODF_DIR/ns/dir
+fi
 chown $UNPRIV_USER $LOWER_DIR1/dir/rw
 
 mount_union "" $LOWER_DIR1=rw $LOWER_DIR0=ro
@@ -66,6 +75,6 @@ shouldfail su $UNPRIV_USER -c "ls -al $MOUNTPOINT/dir"
 # unmount, remove user, ...
 cleanup
 
-branch_files | check_hierarchy $TOP_LOWER_DIR
-
+branch_files | check_hierarchy
+discard_odf
 complete_test
index f00dfcc6602d134ac9e4295ef260b9e8f99bd3c0..b89dff570e3fdac62d515a4b182fa01019653ef9 100755 (executable)
@@ -37,9 +37,9 @@ FILES
 function beforefiles {
 cat <<FILES
 
-f $LOWER_DIR0/d1/.wh.x
+w $LOWER_DIR0 d1/x
 
-f $LOWER_DIR0/d1/d2/.wh.d3
+w $LOWER_DIR0 d1/d2/d3
 
 FILES
 }
@@ -53,9 +53,9 @@ d $LOWER_DIR0/d1/x
 
 d $LOWER_DIR0/d1/d2/d3
 
-f $LOWER_DIR0/d1/d2/d3/.wh.__dir_opaque
-f $LOWER_DIR0/d1/x/.wh.__dir_opaque
-f $LOWER_DIR0/y/.wh.__dir_opaque
+o $LOWER_DIR0 d1/d2/d3
+o $LOWER_DIR0 d1/x
+o $LOWER_DIR0 y
 
 FILES
 }
@@ -69,9 +69,9 @@ d $LOWER_DIR0/y
 d $LOWER_DIR0/d1/x
 
 d $LOWER_DIR0/d1/d2/d3
-f $LOWER_DIR0/d1/d2/d3/.wh.__dir_opaque
-f $LOWER_DIR0/d1/x/.wh.__dir_opaque
-f $LOWER_DIR0/y/.wh.__dir_opaque
+o $LOWER_DIR0 d1/d2/d3
+o $LOWER_DIR0 d1/x
+o $LOWER_DIR0 y
 
 FILES
 }
@@ -80,6 +80,7 @@ FILES
 
 
 ##### simple tests
+init_odf $LOWER_DIR0 $LOWER_DIR1 $LOWER_DIR2
 ( directories ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1 $LOWER_DIR2
@@ -94,12 +95,13 @@ checktype $MOUNTPOINT/d1/d2/d3 'd'
 checktype $MOUNTPOINT/d1/d2/d3/d4 '-'
 
 unmount_union
-( directories ; afterfiles_rw )  | check_hierarchy $TOP_LOWER_DIR
-
+( directories ; afterfiles_rw )  | check_hierarchy
+discard_odf
 
 
 
 #### simple tests
+init_odf $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
 ( directories ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
@@ -113,6 +115,7 @@ checktype $MOUNTPOINT/d1/d2/d3 'd'
 checktype $MOUNTPOINT/d1/d2/d3/d4 '-'
 
 unmount_union
-( directories ; afterfiles_ro )  | check_hierarchy $TOP_LOWER_DIR
+( directories ; afterfiles_ro )  | check_hierarchy
+discard_odf
 
 complete_test
index a5c77d9dcf9afcb7205fd975b71daa1782aacb88..4e31c75a5ed62afa03cdc823c7b9bdbe9e5eac8a 100755 (executable)
@@ -20,7 +20,7 @@ function afterfiles_ro {
 cat <<FILES
 d $TOP_LOWER_DIR
 d $LOWER_DIR0
-f $LOWER_DIR0/.wh.a
+w $LOWER_DIR0 a
 d $LOWER_DIR1
 f $LOWER_DIR1/a
 d $LOWER_DIR2
@@ -39,10 +39,11 @@ FILES
 }
 
 
+init_odf
 ( files ) | create_hierarchy
 mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro
 ./progs/open-unlink $MOUNTPOINT/a || exit $?
 unmount_union
-( afterfiles_ro ) | check_hierarchy $TOP_LOWER_DIR
-
+( afterfiles_ro ) | check_hierarchy
+discard_odf
 complete_test
index ab1ef00b5c681ceaee8a2692658cb1978247641d..cdfa63f8ed7bbbda7328fe2780d0794f3599eca6 100755 (executable)
@@ -16,13 +16,13 @@ d $LOWER_DIR0/s.dir
 d $LOWER_DIR0/s.child
 f $LOWER_DIR0/s.child/foo
 d $LOWER_DIR0/s.wh
-f $LOWER_DIR0/s.wh/.wh.foo
+w $LOWER_DIR0 s.wh/foo
 f $LOWER_DIR0/d.file
 d $LOWER_DIR0/d.dir
 d $LOWER_DIR0/d.child
 f $LOWER_DIR0/d.child/foo
 d $LOWER_DIR0/d.wh
-f $LOWER_DIR0/d.wh/.wh.foo
+w $LOWER_DIR0 d.wh/foo
 d $LOWER_DIR1
 d $LOWER_DIR2
 d $LOWER_DIR3
@@ -89,7 +89,9 @@ function dir2none {
 }
 function afterfiles_dir2none {
        beforefiles | sed -e "`renamestr $LOWER_DIR0/s.dir $LOWER_DIR0/d.none`"
-       echo "f $LOWER_DIR0/d.none/.wh.__dir_opaque"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.none"
+       fi
 }
 
 # dir->file
@@ -108,7 +110,9 @@ function dir2dir {
 }
 function afterfiles_dir2dir {
        beforefiles | grep -v "$LOWER_DIR0/s.dir"
-       echo "f $LOWER_DIR0/d.dir/.wh.__dir_opaque"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.dir"
+       fi
 }
 
 # dir->child
@@ -126,8 +130,10 @@ function dir2wh {
        return $?
 }
 function afterfiles_dir2wh {
-       beforefiles | grep -v "$LOWER_DIR0/s.dir" | grep -v "$LOWER_DIR0/d.wh/.wh.foo"
-       echo "f $LOWER_DIR0/d.wh/.wh.__dir_opaque"
+       beforefiles | grep -v "$LOWER_DIR0/s.dir" | grep -v "$LOWER_DIR0 d.wh/foo"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.wh"
+       fi
 }
 
 
@@ -140,7 +146,9 @@ function afterfiles_child2none {
        beforefiles | grep -v "$LOWER_DIR0/s.child"
        echo "d $LOWER_DIR0/d.none"
        echo "f $LOWER_DIR0/d.none/foo"
-       echo "f $LOWER_DIR0/d.none/.wh.__dir_opaque"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.none"
+       fi
 }
 
 # child->file
@@ -160,7 +168,9 @@ function child2dir {
 function afterfiles_child2dir {
        beforefiles | grep -v "$LOWER_DIR0/s.child"
        echo "f $LOWER_DIR0/d.dir/foo"
-       echo "f $LOWER_DIR0/d.dir/.wh.__dir_opaque"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.dir"
+       fi
 }
 
 # child->child
@@ -178,9 +188,11 @@ function child2wh {
        return $?
 }
 function afterfiles_child2wh {
-       beforefiles | grep -v "$LOWER_DIR0/s.child" | grep -v "$LOWER_DIR0/d.wh/.wh.foo"
+       beforefiles | grep -v "$LOWER_DIR0/s.child" | grep -v "$LOWER_DIR0 d.wh/foo"
        echo "f $LOWER_DIR0/d.wh/foo"
-       echo "f $LOWER_DIR0/d.wh/.wh.__dir_opaque"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.wh"
+       fi
 }
 
 
@@ -191,7 +203,9 @@ function wh2none {
 }
 function afterfiles_wh2none {
        beforefiles | sed -e 's/s\.wh/d\.none/'
-       echo "f $LOWER_DIR0/d.none/.wh.__dir_opaque"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.none"
+       fi
 }
 
 # wh->file
@@ -209,9 +223,11 @@ function wh2dir {
        return $?
 }
 function afterfiles_wh2dir {
-       beforefiles | grep -v "$LOWER_DIR0/s.wh"
-       echo "f $LOWER_DIR0/d.dir/.wh.foo"
-       echo "f $LOWER_DIR0/d.dir/.wh.__dir_opaque"
+       beforefiles | grep -v "$LOWER_DIR0[/ ]s.wh"
+       echo "w $LOWER_DIR0 d.dir/foo"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.dir"
+       fi
 }
 
 # wh->child
@@ -229,8 +245,10 @@ function wh2wh {
        return $?
 }
 function afterfiles_wh2wh {
-       beforefiles | grep -v "$LOWER_DIR0/s.wh"
-       echo "f $LOWER_DIR0/d.wh/.wh.__dir_opaque"
+       beforefiles | grep -v "$LOWER_DIR0[/ ]s.wh"
+       if [ $ODF -eq 0 ]; then
+               echo "o $LOWER_DIR0 d.wh"
+       fi
 }
 
 SRC="file dir child wh"
@@ -240,15 +258,17 @@ for s in $SRC
 do
        for d in $DST
        do
+               init_odf $LOWER_DIR0
                beforefiles | create_hierarchy
                mount_union "" $LOWER_DIR0
 
                ${s}2${d}
 
-               afterfiles_${s}2${d}  | check_hierarchy $TOP_LOWER_DIR
+               afterfiles_${s}2${d}  | check_hierarchy
                unmount_union
 
                echo -n "[${s} ${d}] "
+               discard_odf
        done
 done
 
index cf1716e2fb10602f64d5deba4ca2aae2a263ff03..3756205c9ecda4bbf3b02d4f25d5473f69dcaa69 100755 (executable)
@@ -37,7 +37,7 @@ f $LOWER_DIR0/a
 
 f $LOWER_DIR0/b
 
-f $LOWER_DIR1/d1/d2/d3/d4/.wh.c
+w $LOWER_DIR1 d1/d2/d3/d4/c
 
 FILES
 }
@@ -68,19 +68,24 @@ f $LOWER_DIR0/b
 d $LOWER_DIR0/d5
 l $LOWER_DIR0/d5/e
 
-f $LOWER_DIR1/d1/d2/d3/d4/.wh.c
 d $LOWER_DIR0/d1/d2
 d $LOWER_DIR0/d1/d2/d3
 d $LOWER_DIR0/d1/d2/d3/d4
 l $LOWER_DIR0/d1/d2/d3/d4/c
 
 FILES
+if [ $ODF -eq 0 ]; then
+cat <<FILES
+w $LOWER_DIR1 d1/d2/d3/d4/c
+FILES
+fi
 }
 
 
 
 
 ##### simple tests
+init_odf $LOWER_DIR0 $LOWER_DIR1
 ( directories ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1
@@ -105,8 +110,10 @@ do_link $MOUNTPOINT/b $MOUNTPOINT/d5/e || exit $?
 do_link $MOUNTPOINT/a $MOUNTPOINT/d1/d2/d3/d4/c || exit $?
 
 unmount_union
-( directories ; afterfiles_rw )  | check_hierarchy $TOP_LOWER_DIR
+( directories ; ( [ $ODF -eq 0 ] && afterfiles_rw ) || afterfiles_ro )  | check_hierarchy
+discard_odf
 
+init_odf $LOWER_DIR0 $LOWER_DIR1=ro
 ( directories ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro
@@ -118,7 +125,7 @@ ln --symbolic $MOUNTPOINT/b $MOUNTPOINT/d5/e || exit $?
 ln --symbolic $MOUNTPOINT/a $MOUNTPOINT/d1/d2/d3/d4/c || exit $?
 
 unmount_union
-( directories ; afterfiles_ro )  | check_hierarchy $TOP_LOWER_DIR
-
+( directories ; afterfiles_ro )  | check_hierarchy
+discard_odf
 
 complete_test
index ff24a515d8700d97f032aff687c78809468d72d0..133ed11940f1938ba5723711892fdfc8256b0806 100755 (executable)
@@ -38,6 +38,7 @@ FILES
 
 # read-only test
 function rw_test {
+    init_odf
     (directories) | create_hierarchy
 
     dd if=/dev/zero of=$LOWER_DIR0/a bs=4000 count=2 2>/dev/null
@@ -78,12 +79,14 @@ function rw_test {
     fi
 
     unmount_union
+    discard_odf
     echo -n "[rw] "
 }
 
 # read-only tests
 function ro_test {
 
+    init_odf
     (directories) | create_hierarchy
 
     dd if=/dev/zero of=$LOWER_DIR0/a bs=4000 count=2 2>/dev/null
@@ -124,6 +127,7 @@ function ro_test {
     fi
 
     unmount_union
+    discard_odf
     echo -n "[ro] "
 }
 
index d12ea2b06dbc1024a4244b2be073d90e72ee98e1..50264015dae973f0661a641cbde039dea697e79a 100755 (executable)
@@ -49,40 +49,43 @@ FILES
 
 function afterfiles_ro {
 cat <<FILES
-f $LOWER_DIR0/.wh.a
+w $LOWER_DIR0 a
 f $LOWER_DIR1/a
 
-f $LOWER_DIR0/.wh.b
+w $LOWER_DIR0 b
 f $LOWER_DIR1/b
 
-f $LOWER_DIR0/.wh.c
+w $LOWER_DIR0 c
 f $LOWER_DIR1/c
 
-f $LOWER_DIR0/.wh.d
-
-f $LOWER_DIR0/d1/d2/.wh.e
+w $LOWER_DIR0 d1/d2/e
 f $LOWER_DIR1/d1/d2/e
 
-f $LOWER_DIR0/.wh.g
+w $LOWER_DIR0 g
 l $LOWER_DIR1/g
 FILES
+if [ $ODF -eq 0 ]; then
+cat <<FILES
+w $LOWER_DIR0 d
+FILES
+fi
 }
 
 function afterfiles_rw {
 cat <<FILES
-f $LOWER_DIR0/.wh.a
+w $LOWER_DIR0 a
 f $LOWER_DIR1/a
 
-f $LOWER_DIR1/.wh.b
+w $LOWER_DIR1 b
 
-f $LOWER_DIR0/.wh.c
+w $LOWER_DIR0 c
 f $LOWER_DIR1/c
 
-f $LOWER_DIR0/.wh.d
+w $LOWER_DIR0 d
 
-f $LOWER_DIR1/d1/d2/.wh.e
+w $LOWER_DIR1 d1/d2/e
 
-f $LOWER_DIR1/.wh.g
+w $LOWER_DIR1 g
 FILES
 }
 
@@ -108,23 +111,22 @@ FILES
 }
 
 function afterfiles_createback_rw {
+if [ $ODF -eq 0 ]; then
 cat <<FILES
-f $LOWER_DIR0/a
 f $LOWER_DIR1/a
-
+w $LOWER_DIR1 b
+f $LOWER_DIR1/c
+w $LOWER_DIR1 d1/d2/e
+w $LOWER_DIR1 g
+FILES
+fi
+cat <<FILES
+f $LOWER_DIR0/a
 f $LOWER_DIR0/b
-f $LOWER_DIR1/.wh.b
-
 f $LOWER_DIR0/c
-f $LOWER_DIR1/c
-
 f $LOWER_DIR0/d
-
 f $LOWER_DIR0/d1/d2/e
-f $LOWER_DIR1/d1/d2/.wh.e
-
 f $LOWER_DIR0/g
-f $LOWER_DIR1/.wh.g
 FILES
 }
 
@@ -132,6 +134,7 @@ FILES
 function test1
 {
 ##### simple test
+init_odf
 ( files ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro
@@ -152,7 +155,8 @@ checktype $MOUNTPOINT/d1/d2/e '-'
 checktype $MOUNTPOINT/g '-'
 
 unmount_union
-( files ; afterfiles_ro )  | check_hierarchy $TOP_LOWER_DIR
+( files ; afterfiles_ro )  | check_hierarchy
+discard_odf
 
 echo -n "[ro] "
 }
@@ -160,6 +164,7 @@ echo -n "[ro] "
 function test2
 {
 ##### now unlink files and then create them before unmount
+init_odf
 ( files ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro
@@ -194,7 +199,8 @@ checktype $MOUNTPOINT/d1/d2/e 'f'
 checktype $MOUNTPOINT/g 'f'
 
 unmount_union
-( files ; afterfiles_createback_ro )  | check_hierarchy $TOP_LOWER_DIR
+( files ; afterfiles_createback_ro )  | check_hierarchy
+discard_odf
 
 echo -n "[ro createback] "
 }
@@ -202,6 +208,7 @@ echo -n "[ro createback] "
 function test3
 {
 ##### now unlink files and then create them after unmount
+init_odf
 ( files ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro
@@ -221,7 +228,10 @@ checktype $MOUNTPOINT/d1/d2/e '-'
 checktype $MOUNTPOINT/g '-'
 
 unmount_union
-( files ; afterfiles_ro )  | check_hierarchy $TOP_LOWER_DIR
+( files ; afterfiles_ro )  | check_hierarchy
+# For ODF case, no discard_odf here, coz we want to use this mounted
+# ODF for the test4 below. Also note there is no init_odf in test4 
+# below for the same reason.
 echo -n "[ro] "
 }
 
@@ -245,14 +255,15 @@ checktype $MOUNTPOINT/d1/d2/e 'f'
 checktype $MOUNTPOINT/g 'f'
 
 unmount_union
-( files ; afterfiles_createback_ro)  | check_hierarchy $TOP_LOWER_DIR
-
+( files ; afterfiles_createback_ro)  | check_hierarchy
+discard_odf
 echo -n "[ro createback 2] "
 }
 
 function test5
 {
 ##### simple test with rw branches
+init_odf
 ( files ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1
@@ -273,14 +284,16 @@ checktype $MOUNTPOINT/g '-'
 
 unmount_union
 
-( files ; afterfiles_rw)  | check_hierarchy $TOP_LOWER_DIR
 
+( files ; [ $ODF -eq 0 ] && afterfiles_rw)  | check_hierarchy
+discard_odf
 echo -n "[rw] "
 }
 
 function test6
 {
 ##### now unlink files and then create them before unmount
+init_odf
 ( files ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1
@@ -315,14 +328,15 @@ checktype $MOUNTPOINT/d1/d2/e 'f'
 checktype $MOUNTPOINT/g 'f'
 
 unmount_union
-( files ; afterfiles_createback_rw )  | check_hierarchy $TOP_LOWER_DIR
-
+( files ; afterfiles_createback_rw )  | check_hierarchy
+discard_odf
 echo -n "[rw createback] "
 }
 
 function test7
 {
 ##### now unlink files and then create them after unmount
+init_odf
 ( files ; beforefiles) | create_hierarchy
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1
@@ -342,7 +356,7 @@ checktype $MOUNTPOINT/d1/d2/e '-'
 checktype $MOUNTPOINT/g '-'
 
 unmount_union
-( files ; afterfiles_rw )  | check_hierarchy $TOP_LOWER_DIR
+( files ;  [ $ODF -eq 0 ] && afterfiles_rw )  | check_hierarchy 
 
 mount_union "" $LOWER_DIR0 $LOWER_DIR1
 
@@ -362,7 +376,8 @@ checktype  $MOUNTPOINT/d1/d2/e 'f'
 checktype $MOUNTPOINT/g 'f'
 
 unmount_union
-( files ; afterfiles_createback_rw)  | check_hierarchy $TOP_LOWER_DIR
+( files ; afterfiles_createback_rw)  | check_hierarchy
+discard_odf
 echo -n "[rw createback 2] "
 }