From 8fc6a161364dcc971b0eb3980c4bdd364d60ef79 Mon Sep 17 00:00:00 2001 From: Rachita Kothiyal Date: Sun, 14 Oct 2007 14:21:44 -0400 Subject: [PATCH] More cleanups to the ODF code --- odf.conf | 8 ++++---- progs/Makefile | 2 +- progs/{make_sb.c => mkodf_sb.c} | 8 ++++---- run-tests | 2 +- scaffold | 30 +++++++++++++++++++++++++++++- 5 files changed, 39 insertions(+), 11 deletions(-) rename progs/{make_sb.c => mkodf_sb.c} (88%) diff --git a/odf.conf b/odf.conf index b8257aa..22f30d3 100644 --- a/odf.conf +++ b/odf.conf @@ -35,10 +35,7 @@ BROKEN_TESTS=" " # names of tests to run (change as you like) # Will take $MYTESTS list of tests from the environment -#TESTS2RUN=${MYTESTS:-$ALL_TESTS} - -#Hardcoding this to test only 'create' -TESTS2RUN="create" +TESTS2RUN=${MYTESTS:-$ALL_TESTS} # Running On-Disk Format (ODF) ? 1=yes, 0=no ODF=1 @@ -47,6 +44,9 @@ ODF=1 ODF_FS="ext2" ODF_DEV="/dev/loop4" ODF_DIR="/n/odf" +#Branch permissions +ODF_BRANCH_RW=6 +ODF_BRANCH_RO=4 # name of four devices to use DEV0=/dev/loop0 diff --git a/progs/Makefile b/progs/Makefile index 3fad4b7..659aca5 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -19,7 +19,7 @@ CFLAGS=-g -Wall -Werror -luuid MOUNTPOINT=. BINS=open-unlink flock-copyup fsync truncate bug418 rmdircheckinode \ - creat-open rename mapper queryfile make_sb + creat-open rename mapper queryfile mkodf_sb all: $(BINS) diff --git a/progs/make_sb.c b/progs/mkodf_sb.c similarity index 88% rename from progs/make_sb.c rename to progs/mkodf_sb.c index b4ddf8e..ac1f754 100644 --- a/progs/make_sb.c +++ b/progs/mkodf_sb.c @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) { int fd; unsigned int version = 2; - unsigned int no_branches = atoi(argv[1]); + unsigned int no_branches = atoi(argv[2]); unsigned int bid[MAX_NO_BRANCHES]; unsigned int pathlength[MAX_NO_BRANCHES]; char path[MAX_NO_BRANCHES][100]; @@ -38,13 +38,13 @@ int main(int argc, char *argv[]) for (i = 0; i < no_branches; i++) { - strcpy(path[i], argv[2*i+2]); + strcpy(path[i], argv[2*i+3]); pathlength[i] = strlen(path[i]); - permission[i] = atoi(argv[2*i+3]); + permission[i] = atoi(argv[2*i+4]); bid[i] = i; } - fd = open("/n/odf/sb", O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO); + fd = open(argv[1], O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO); bytes = write(fd, (char *)&version, 4); bytes = write(fd, (char *)&no_branches, 4); diff --git a/run-tests b/run-tests index 1e97736..01376f7 100755 --- a/run-tests +++ b/run-tests @@ -262,7 +262,7 @@ do # Export the type of file systems, as some tests need to know. # For example: jffs2, cramfs, and squashfs. export FS0 FS1 FS2 FS3 DEV0 DEV1 DEV2 DEV3 SPECIAL_FS delay OUTPUT_COLOR - export ODF ODF_FS ODF_DEV ODF_DIR POPULATE_ODF + export ODF ODF_FS ODF_DEV ODF_DIR POPULATE_ODF ODF_BRANCH_RW ODF_BRANCH_RO # run actual test and abort on error (test script tries to umount unionfs) runcmd bash $t diff --git a/scaffold b/scaffold index a003c70..c43afe7 100644 --- a/scaffold +++ b/scaffold @@ -212,7 +212,12 @@ function check_hierarchy { return $ERR } -function setup_odf { +function init_odf { + # Noop for Non ODF unionfs + if [ $ODF -eq 0 ]; then + return + fi + 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 @@ -222,6 +227,29 @@ function setup_odf { fi runcmd mount -t $ODF_FS $ODF_DEV $ODF_DIR + if [ "$#" -gt 0 ]; then + fill_odf + no_branches="$#" + ARG_LIST=$ODF_DIR"/sb "$no_branches + while [ "$#" -gt 0 ]; do + branch=`echo $1 | cut -d= -f 1` + ( echo $1 | grep '=' >/dev/null ) + ERR=$? + if [ $ERR -eq 0 ]; then + perm=`echo $1 | cut -d= -f 2` + else + perm="rw" + fi + if [ "$perm" == "ro" ]; then + perm="$ODF_BRANCH_RO" + elif [ "$perm" == "rw" ]; then + perm="$ODF_BRANCH_RW" + fi + ARG_LIST=$ARG_LIST" "$branch" "$perm + shift + done + ./progs/mkodf_sb $ARG_LIST + fi } function fill_odf { -- 2.43.0