TESTS2RUN=${MYTESTS:-$ALL_TESTS}
# Running On-Disk Format (ODF) ? 1=yes, 0=no
-ODF=1
+ODF=0
# name of four devices to use
DEV0=/dev/loop0
#
# This Copyright notice must be kept intact and distributed with all sources.
-CFLAGS=-g -Wall -Werror -L /usr/lib/ -luuid# -lefence
+CFLAGS=-g -Wall -Werror -luuid
MOUNTPOINT=.
BINS=open-unlink flock-copyup fsync truncate bug418 rmdircheckinode \
creat-open rename mapper queryfile make_sb
+/*
+ * 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.
+ */
+
+/* create the /odf/sb state file */
+
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int fd;
unsigned int version = 2;
unsigned int no_branches = atoi(argv[1]);
- unsigned int bid[MAX_NO_BRANCHES];
- unsigned int pathlength[MAX_NO_BRANCHES];
+ unsigned int bid[MAX_NO_BRANCHES];
+ unsigned int pathlength[MAX_NO_BRANCHES];
char path[MAX_NO_BRANCHES][100];
unsigned int permission[MAX_NO_BRANCHES];
unsigned char uuid[MAX_NO_BRANCHES*UUID_LEN];
bid[i] = i;
}
-
fd = open("/n/odf/sb", O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
bytes = write(fd, (char *)&version, 4);
bytes = write(fd, (char *)&no_branches, 4);
bytes = write(fd, (char *)&pathlength[i], 4);
bytes = write(fd, path[i], pathlength[i]);
bytes = write(fd, (char *)&permission[i], 4);
- uuid_generate_random(uuid + i*UUID_LEN);
+ uuid_generate_random(uuid + i*UUID_LEN);
bytes = write(fd, uuid + i*UUID_LEN, UUID_LEN);
}
done
}
-
function do_umount
{
branch=$1
dev=$2
fs=$3
+ # first, unmount main branch
runcmd umount /n/lower/b$branch
-
+
case "$fs" in
nfs* )
runcmd exportfs -u localhost:/n/export/b$branch
fi
# test if file systems are supported by this kernel, and skip if not
- test_fs $MYFS $FS0 $FS1 $FS2 $FS3 $FS4 $SPECIAL_FS
+ test_fs $MYFS $FS0 $FS1 $FS2 $FS3 $ODF_FS $SPECIAL_FS
delay=$DELAY
echo "Sleeping for "$delay" seconds between each command."
# Export the type of file systems, as some tests need to know.
# For example: jffs2, cramfs, and squashfs.
- export FS0 FS1 FS2 FS3 ODF_FS DEV0 DEV1 DEV2 DEV3 ODF_DEV ODF_DIR SPECIAL_FS delay OUTPUT_COLOR ODF POPULATE_ODF
+ export FS0 FS1 FS2 FS3 DEV0 DEV1 DEV2 DEV3 SPECIAL_FS delay OUTPUT_COLOR
+ export ODF ODF_FS ODF_DEV ODF_DIR POPULATE_ODF
# run actual test and abort on error (test script tries to umount unionfs)
runcmd bash $t
runcmd sync
# try to unmount lower file systems (check if we leak anything)
- for i in 0 1 2 3 ; do
+ for i in 0 1 2 3 ; do
do_umount $i $(eval echo \$DEV$i) $(eval echo \$FS$i)
done
# unload unionfs module (check if we leak anything)
TOP_LOWER_DIR=/n/lower
-
test -z "$MOUNTPOINT" && MOUNTPOINT=/mnt/unionfs
test -z "$LOWER_DIR0" && LOWER_DIR0=$TOP_LOWER_DIR/b0
test -z "$LOWER_DIR1" && LOWER_DIR1=$TOP_LOWER_DIR/b1
if [ "$TYPE" = "w" ]; then
WH_LOC=`echo $LINE | cut -d' ' -f 2`
NAME=`echo $LINE | cut -d' ' -f 3`
- else
+ else
NAME=`echo $LINE | cut -d' ' -f 2`
fi
else
if [ $POPULATE_ODF -eq 1 ]; then
touch $NAME || exit $?
- else
+ else
echo $NAME > $NAME || exit $?
fi
fi
if [ ! -z "$IMMUTABLE" ] ; then
chattr +i $NAME || exit $?
fi
-
done
}
}
function check_hierarchy {
- ( find $1 -type d -printf 'd %p\n' ; find $1 -type f -links 1 -printf 'f %p\n' ; find $1 -type f -links +1 -printf 'w %p\n'; find $1 -type b -printf 'b %p\n' ; find $1 -type c -printf 'c %p\n' ; find $1 -type l -printf 'l %p\n') | sort > /tmp/check-$$
+ (
+ find $1 -type d -printf 'd %p\n'
+ find $1 -type f -links 1 -printf 'f %p\n'
+ find $1 -type f -links +1 -printf 'w %p\n'
+ find $1 -type b -printf 'b %p\n'
+ find $1 -type c -printf 'c %p\n'
+ find $1 -type l -printf 'l %p\n'
+ ) | sort > /tmp/check-$$
grep -v '^$' | sort | diff -u - /tmp/check-$$
ERR=$?
return $ERR
}
-function setup_odf
-{
+function setup_odf {
runcmd dd if=/dev/zero of=/tmp/fs.odf bs=1024k count=1 seek=100 2> /dev/null
runcmd losetup $ODF_DEV /tmp/fs.odf
-
+
runcmd mkfs -t $ODF_FS -q $ODF_DEV
if [ ! -d $ODF_DIR ]; then
runcmd mkdir -p $ODF_DIR
}
function fill_odf {
-mkdir $ODF_DIR/ic
-mkdir $ODF_DIR/ns
-mkdir $ODF_DIR/reclaim
-mkdir $ODF_DIR/sr
-touch $ODF_DIR/whiteout
+ mkdir $ODF_DIR/ic
+ mkdir $ODF_DIR/ns
+ mkdir $ODF_DIR/reclaim
+ mkdir $ODF_DIR/sr
+ touch $ODF_DIR/whiteout
}
function mount_union {
else
if [ -z "$2" ] ; then
OPTION="$1"
- else
+ else
OPTION="$1,dirs="
fi
fi
done
mount -t unionfs -o $OPTION none $MOUNTPOINT
+
MOUNTS=$((MOUNTS + 1))
return $?
}
-function discard_odf
+function discard_odf
{
runcmd umount $ODF_DIR
runcmd losetup -d $ODF_DEV
}
function unmount_union {
-
umount $MOUNTPOINT
-
+
# support compressed ram/rom file systems
if test -n "$CRAMFS_BRANCHES" ; then
uncramit
else
mount_union "" $LOWER_DIR0 $LOWER_DIR1
fi
-
+
do_chmod $MOUNTPOINT/a
do_chmod $MOUNTPOINT/b
do_chmod $MOUNTPOINT/c
do_chmod $MOUNTPOINT/f
unmount_union
+
( beforefiles ) | check_hierarchy $TOP_LOWER_DIR
echo -n "[rw] "
d $LOWER_DIR1
d $LOWER_DIR1/d5
d $LOWER_DIR1/d1
-f $LOWER_DIR1/d1/x
+d $LOWER_DIR1/d1/x
d $LOWER_DIR1/d1/d2
d $LOWER_DIR1/d1/d2/d3
d $LOWER_DIR2
#function fill_odf {
-# mkdir $ODF_DIR/ic
+# mkdir $ODF_DIR/ic
# mkdir $ODF_DIR/ns
# mkdir $ODF_DIR/reclaim
# mkdir $ODF_DIR/sr
FILES
}
+
if [ $ODF -eq 1 ]; then
POPULATE_ODF=0
fi
discard_odf
else
( files ; beforefiles ) | check_hierarchy $TOP_LOWER_DIR
-fi
+fi
complete_test
-