From 9840abc725983a5acd7c24b3eb0eed17ef385b06 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sat, 13 Oct 2007 15:57:46 -0400 Subject: [PATCH] cleanup some odf-specific code. 1st code review done. --- default.conf | 2 +- progs/Makefile | 2 +- progs/make_sb.c | 21 +++++++++++++++++---- run-tests | 11 ++++++----- scaffold | 38 +++++++++++++++++++++----------------- t-chmod.sh | 3 ++- t-create.sh | 4 ++-- t-flock.sh | 1 + t-lookup.sh | 3 +-- 9 files changed, 52 insertions(+), 33 deletions(-) mode change 100755 => 100644 t-chmod.sh diff --git a/default.conf b/default.conf index 90e6f25..ccbfd37 100644 --- a/default.conf +++ b/default.conf @@ -38,7 +38,7 @@ BROKEN_TESTS=" 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 diff --git a/progs/Makefile b/progs/Makefile index 298866b..3fad4b7 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -16,7 +16,7 @@ # # 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 diff --git a/progs/make_sb.c b/progs/make_sb.c index 304b8ea..b4ddf8e 100644 --- a/progs/make_sb.c +++ b/progs/make_sb.c @@ -1,3 +1,17 @@ +/* + * 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 #include #include @@ -14,8 +28,8 @@ int main(int argc, char *argv[]) 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]; @@ -30,7 +44,6 @@ int main(int argc, char *argv[]) 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); @@ -40,7 +53,7 @@ int main(int argc, char *argv[]) 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); } diff --git a/run-tests b/run-tests index c9fbdfa..1e97736 100755 --- a/run-tests +++ b/run-tests @@ -161,15 +161,15 @@ function setup_lower 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 @@ -253,7 +253,7 @@ do 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." @@ -261,7 +261,8 @@ do # 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 @@ -275,7 +276,7 @@ do 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) diff --git a/scaffold b/scaffold index 6538373..a003c70 100644 --- a/scaffold +++ b/scaffold @@ -7,7 +7,6 @@ echo -n "$0: " 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 @@ -61,7 +60,7 @@ function create_hierarchy { 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 @@ -121,7 +120,7 @@ function create_hierarchy { else if [ $POPULATE_ODF -eq 1 ]; then touch $NAME || exit $? - else + else echo $NAME > $NAME || exit $? fi fi @@ -146,7 +145,6 @@ function create_hierarchy { if [ ! -z "$IMMUTABLE" ] ; then chattr +i $NAME || exit $? fi - done } @@ -199,7 +197,14 @@ function uncramit { } 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=$? @@ -207,11 +212,10 @@ function check_hierarchy { 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 @@ -221,11 +225,11 @@ function setup_odf } 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 { @@ -245,7 +249,7 @@ function mount_union { else if [ -z "$2" ] ; then OPTION="$1" - else + else OPTION="$1,dirs=" fi fi @@ -262,12 +266,13 @@ function mount_union { 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 @@ -278,9 +283,8 @@ function discard_odf } function unmount_union { - umount $MOUNTPOINT - + # support compressed ram/rom file systems if test -n "$CRAMFS_BRANCHES" ; then uncramit diff --git a/t-chmod.sh b/t-chmod.sh old mode 100755 new mode 100644 index 40b9d12..aea8d7e --- a/t-chmod.sh +++ b/t-chmod.sh @@ -69,7 +69,7 @@ if [ $ODF -eq 1 ]; then else mount_union "" $LOWER_DIR0 $LOWER_DIR1 fi - + do_chmod $MOUNTPOINT/a do_chmod $MOUNTPOINT/b do_chmod $MOUNTPOINT/c @@ -78,6 +78,7 @@ do_chmod $MOUNTPOINT/e do_chmod $MOUNTPOINT/f unmount_union + ( beforefiles ) | check_hierarchy $TOP_LOWER_DIR echo -n "[rw] " diff --git a/t-create.sh b/t-create.sh index c3b8b50..45e5bcd 100644 --- a/t-create.sh +++ b/t-create.sh @@ -26,7 +26,7 @@ d $LOWER_DIR0/d6 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 @@ -224,7 +224,7 @@ function BUG383 { #function fill_odf { -# mkdir $ODF_DIR/ic +# mkdir $ODF_DIR/ic # mkdir $ODF_DIR/ns # mkdir $ODF_DIR/reclaim # mkdir $ODF_DIR/sr diff --git a/t-flock.sh b/t-flock.sh index 53a1bfd..7a62d68 100755 --- a/t-flock.sh +++ b/t-flock.sh @@ -36,6 +36,7 @@ f $LOWER_DIR1/a FILES } + if [ $ODF -eq 1 ]; then POPULATE_ODF=0 fi diff --git a/t-lookup.sh b/t-lookup.sh index f70ec80..8ae1b30 100755 --- a/t-lookup.sh +++ b/t-lookup.sh @@ -72,7 +72,6 @@ if [ $ODF -eq 1 ]; then discard_odf else ( files ; beforefiles ) | check_hierarchy $TOP_LOWER_DIR -fi +fi complete_test - -- 2.43.0