From: Rachita Kothiyal Date: Sun, 14 Oct 2007 18:21:44 +0000 (-0400) Subject: More cleanups to the ODF code X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=8fc6a161364dcc971b0eb3980c4bdd364d60ef79;p=unionfs-regression-odf.git More cleanups to the ODF code --- 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/make_sb.c deleted file mode 100644 index b4ddf8e..0000000 --- a/progs/make_sb.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include - -#define UUID_LEN 16 -#define MAX_NO_BRANCHES 4 -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]; - char path[MAX_NO_BRANCHES][100]; - unsigned int permission[MAX_NO_BRANCHES]; - unsigned char uuid[MAX_NO_BRANCHES*UUID_LEN]; - int i; - size_t bytes; - - - for (i = 0; i < no_branches; i++) { - strcpy(path[i], argv[2*i+2]); - pathlength[i] = strlen(path[i]); - permission[i] = atoi(argv[2*i+3]); - 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); - - for (i = 0; i < no_branches; i++) { - bytes = write(fd, (char *)&bid[i], 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); - bytes = write(fd, uuid + i*UUID_LEN, UUID_LEN); - } - - close(fd); - return 0; -} diff --git a/progs/mkodf_sb.c b/progs/mkodf_sb.c new file mode 100644 index 0000000..ac1f754 --- /dev/null +++ b/progs/mkodf_sb.c @@ -0,0 +1,62 @@ +/* + * 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 +#include +#include +#include +#include +#include + +#define UUID_LEN 16 +#define MAX_NO_BRANCHES 4 +int main(int argc, char *argv[]) +{ + int fd; + unsigned int version = 2; + 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]; + unsigned int permission[MAX_NO_BRANCHES]; + unsigned char uuid[MAX_NO_BRANCHES*UUID_LEN]; + int i; + size_t bytes; + + + for (i = 0; i < no_branches; i++) { + strcpy(path[i], argv[2*i+3]); + pathlength[i] = strlen(path[i]); + permission[i] = atoi(argv[2*i+4]); + bid[i] = i; + } + + 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); + + for (i = 0; i < no_branches; i++) { + bytes = write(fd, (char *)&bid[i], 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); + bytes = write(fd, uuid + i*UUID_LEN, UUID_LEN); + } + + close(fd); + return 0; +} 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 {