More cleanups to the ODF code
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 14 Oct 2007 18:21:44 +0000 (14:21 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 14 Oct 2007 18:21:44 +0000 (14:21 -0400)
odf.conf
progs/Makefile
progs/make_sb.c [deleted file]
progs/mkodf_sb.c [new file with mode: 0644]
run-tests
scaffold

index b8257aadd98bb0acf497f86876d8dd2ae12ef61c..22f30d3807668117127aa5e9196870cbf9a84b0c 100644 (file)
--- 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
index 3fad4b75d5a5848622395d30055a0bc4a4a9dca0..659aca5523e00bee0dfcdb2c0fdd95750398e1b0 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 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 (file)
index b4ddf8e..0000000
+++ /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 <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <uuid/uuid.h>
-#include <string.h>
-
-#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 (file)
index 0000000..ac1f754
--- /dev/null
@@ -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 <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <uuid/uuid.h>
+#include <string.h>
+
+#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;
+}
index 1e9773649276df2850cbb9c4b955951429edd8e8..01376f7636be46b5fa7cb64d5ef4e68cfdd1b14f 100755 (executable)
--- 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
index a003c705839a1367a81dc389ba10e9c703780d87..c43afe7a09c5f5584e99704e24a85e54b19237d8 100644 (file)
--- 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 {