1)Enables hand creation of the odf, odf sb creation, whiteout creation.
2)t-create test modified for ODF. Not compatible with non-ODF plain unionfs yet.
--- /dev/null
+# default Unionfs 2.0 regression configuration file
+# uses ext2 by default, which you can override using a $MYFS env var
+
+# names of all possible tests
+# Note: you can give full name of test (t-chmod.sh) or short (chmod)
+ALL_TESTS="
+ t-chmod.sh
+ t-creat-open.sh
+ t-create.sh
+ t-flock.sh
+ t-fsync.sh
+ t-ioctl.sh
+ t-link-rename.sh
+ t-link.sh
+ t-lookup-opaque.sh
+ t-lookup.sh
+ t-mkdir.sh
+ t-mknod.sh
+ t-mmap.sh
+ t-open-unlink.sh
+ t-open.sh
+ t-readdir.sh
+ t-rename-matrix.sh
+ t-rename-whiteout.sh
+ t-symlink.sh
+ t-truncate-all.sh
+ t-unlink-whiteout.sh
+"
+
+# The branch-management test is "broken" and needs to be rewritten to
+# support the new remount-style -ezk.
+BROKEN_TESTS="
+ t-branchman.sh
+ t-incgen.sh
+"
+# names of tests to run (change as you like)
+# Will take $MYTESTS list of tests from the environment
+TESTS2RUN=${MYTESTS:-$ALL_TESTS}
+
+# Running On-Disk Format (ODF) ? 1=yes, 0=no
+ODF=1
+
+#ODF related configs
+ODF_FS="ext2"
+ODF_DEV="/dev/loop4"
+ODF_DIR="/n/odf"
+
+# name of four devices to use
+DEV0=/dev/loop0
+DEV1=/dev/loop1
+DEV2=/dev/loop2
+DEV3=/dev/loop3
+
+# Name of file systems to format your device. Supported file systems
+# Include the following:
+# 1. Disk based: ext2, ext3, ext4, reiserfs, reiser4, and xfs.
+# 2. Network: nfs, nfs2, and nfs3 (nfs4 support pending).
+# 3. Special: jffs2, ramfs, tmpfs, cramfs, and squashfs.
+case ${MYFS} in
+ # jffs2 is special: only the leftmost filesystem uses it
+ jffs* | ramfs | tmpfs )
+ FS0=${MYFS}
+ FS1=ext2
+ FS2=ext2
+ FS3=ext2
+ ;;
+# cramfs is special: only the rightmost filesystem uses it but the cramfs
+# will be generated *inside* run-tests, because this is a read-only file
+# system and each test has a different configuration.
+ cramfs | squashfs )
+ SPECIAL_FS=${MYFS}
+ FS0=tmpfs
+ FS1=ext2
+ FS2=ext2
+ FS3=ext2
+ ;;
+ * )
+ FS0=${MYFS}
+ FS1=${MYFS}
+ FS2=${MYFS}
+ FS3=${MYFS}
+ ;;
+esac
+
+
+# delay between each test (in seconds or fractions thereof, optional)
+DELAY=0.1
+
+# Echo the command being executed to a file/device (optional) This is useful
+# when unionfs printk's some debugging output which may go to a log file,
+# console, or syslog. With this you can show command in your logs before it
+# runs.
+#ECHODEV=/var/log/all
+ECHODEV=/dev/console
+
+# ANSI color codes, concatenated by ';'
+#
+# 00 for normal display (or just 0)
+# 01 for bold on (or just 1)
+# 02 faint (or just 2)
+# 03 standout (or just 3)
+# 04 underline (or just 4)
+# 05 blink on (or just 5)
+# 07 reverse video on (or just 7)
+# 08 nondisplayed (invisible) (or just 8)
+# 22 normal
+# 23 no-standout
+# 24 no-underline
+# 25 no-blink
+# 27 no-reverse
+# 30 black foreground
+# 31 red foreground
+# 32 green foreground
+# 33 yellow foreground
+# 34 blue foreground
+# 35 magenta foreground
+# 36 cyan foreground
+# 37 white foreground
+# 39 default foreground
+# 40 black background
+# 41 red background
+# 42 green background
+# 43 yellow background
+# 44 blue background
+# 45 magenta background
+# 46 cyan background
+# 47 white background
+# 49 default background
+OUTPUT_COLOR="1;32"
+
+
+#Tests ported to ODF
+#1) chmod
+#2)t-creat-open.sh
+#3)t-flock
+#4)t-fsync.sh
+#5) create
+
+
+
+#Need more fixing
+#2) ioctl
+#3) link-rename
#
# This Copyright notice must be kept intact and distributed with all sources.
-CFLAGS=-g -Wall -Werror # -lefence
+CFLAGS=-g -Wall -Werror -L /usr/lib/ -luuid# -lefence
MOUNTPOINT=.
BINS=open-unlink flock-copyup fsync truncate bug418 rmdircheckinode \
- creat-open rename mapper queryfile
+ creat-open rename mapper queryfile make_sb
all: $(BINS)
--- /dev/null
+#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;
+}
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
test -z "$LOWER_DIR2" && LOWER_DIR2=$TOP_LOWER_DIR/b2
test -z "$LOWER_DIR3" && LOWER_DIR3=$TOP_LOWER_DIR/b3
+test -z "$ODF_DIR" && ODF_DIR=/n/odf
test -z "$NFS" && NFS=
test -z "$DEBUG" && DEBUG=0
function create_hierarchy {
- havechattr $LOWER_DIR0 && chattr -R -i $LOWER_DIR0
- havechattr $LOWER_DIR1 && chattr -R -i $LOWER_DIR1
- havechattr $LOWER_DIR2 && chattr -R -i $LOWER_DIR2
- havechattr $LOWER_DIR3 && chattr -R -i $LOWER_DIR3
+ if [ "$POPULATE_ODF" -eq "0" ]; then
+ havechattr $LOWER_DIR0 && chattr -R -i $LOWER_DIR0
+ havechattr $LOWER_DIR1 && chattr -R -i $LOWER_DIR1
+ havechattr $LOWER_DIR2 && chattr -R -i $LOWER_DIR2
+ havechattr $LOWER_DIR3 && chattr -R -i $LOWER_DIR3
- # delete all files, dirs, and hidden files below mount points
- # (we cannot delete the mounted mountpoints themselves (EBUSY)
- rm -fr $TOP_LOWER_DIR/b[0-3]/[a-zA-Z0-9_]*
- rm -fr $TOP_LOWER_DIR/b[0-3]/.[a-zA-Z0-9_]*
+ # delete all files, dirs, and hidden files below mount points
+ # (we cannot delete the mounted mountpoints themselves (EBUSY)
+ rm -fr $TOP_LOWER_DIR/b[0-3]/[a-zA-Z0-9_]*
+ rm -fr $TOP_LOWER_DIR/b[0-3]/.[a-zA-Z0-9_]*
+ fi
while read LINE
do
TYPE=`echo $LINE | cut -d' ' -f 1`
NAME=`echo $LINE | cut -d' ' -f 2`
- unset DIR FILE IMMUTABLE SOURCE SYMLINK
+ unset DIR FILE IMMUTABLE SOURCE SYMLINK WH
( echo $TYPE | grep -q d ) && DIR=1
( echo $TYPE | grep -q f ) && FILE=1
( echo $TYPE | grep -q i ) && IMMUTABLE=1
( echo $TYPE | grep -q s ) && SOURCE=1
( echo $TYPE | grep -q l ) && SYMLINK=1
+ ( echo $TYPE | grep -q w ) && WH=1
if [ ! -z "$SOURCE" ] ; then
if [ ! -z "$DIR" ] ; then
if [ ! -z "$SOURCE" ] ; then
echo "Source file." > $NAME || exit $?
else
- echo $NAME > $NAME || exit $?
+ if [ $POPULATE_ODF -eq 1 ]; then
+ touch $NAME || exit $?
+ else
+ echo $NAME > $NAME || exit $?
+ fi
fi
elif [ ! -z "$SYMLINK" ] ; then
ln -s "linktext:$NAME" $NAME
+ elif [ ! -z "$WH" ]; then
+ mkdir -p `dirname $NAME` || exit $?
+ ln $ODF_DIR/whiteout $NAME
else
echo "What type am i: $TYPE" 1>&2
exit $?
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 -printf 'f %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=$?
rm -f /tmp/check-$$
return $ERR
}
+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
+ fi
+ runcmd mount -t $ODF_FS $ODF_DEV $ODF_DIR
+
+}
+
function mount_union {
+
# support compressed ram/rom file systems
if test -n "$SPECIAL_FS" ; then
cramit $SPECIAL_FS $*
exit 1
fi
- if [ -z "$1" ] ; then
- OPTION="dirs="
+ if [ -z "$1" ] ; then
+ OPTION="dirs="
else
- OPTION="$1,dirs="
+ if [ -z "$2" ] ; then
+ OPTION="$1"
+ else
+ OPTION="$1,dirs="
+ fi
fi
- shift
+ shift
while [ "$#" -gt 0 ]
- do
- OPTION="$OPTION$1"
- if [ "$#" -ne "1" ] ; then
- OPTION="$OPTION"":"
- fi
- shift
- done
+ do
+ OPTION="$OPTION$1"
+ if [ "$#" -ne "1" ] ; then
+ OPTION="$OPTION"":"
+ fi
+ shift
+ done
mount -t unionfs -o $OPTION none $MOUNTPOINT
-
MOUNTS=$((MOUNTS + 1))
return $?
}
+function discard_odf
+{
+ runcmd umount $ODF_DIR
+ runcmd losetup -d $ODF_DEV
+
+ #this is if you dont wanna use this odf for susequent unionfs mounts
+ runcmd rm -rf /tmp/fs.odf
+ runcmd rm -rf $ODF_DIR/*
+}
+
function unmount_union {
- umount $MOUNTPOINT
+ umount $MOUNTPOINT
+
# support compressed ram/rom file systems
if test -n "$CRAMFS_BRANCHES" ; then
uncramit
d $LOWER_DIR1
d $LOWER_DIR1/d5
d $LOWER_DIR1/d1
-d $LOWER_DIR1/d1/x
+f $LOWER_DIR1/d1/x
d $LOWER_DIR1/d1/d2
d $LOWER_DIR1/d1/d2/d3
d $LOWER_DIR2
FILES
}
-# initial set of files
-function beforefiles {
+function odf_directories {
cat <<FILES
+d $ODF_DIR/ns
+d $ODF_DIR/ns/d1
+d $ODF_DIR/ns/d1/d2
+d $ODF_DIR/ns/d1/d2/d3
+f $ODF_DIR/ns/d1/d2/d3/a
+f $ODF_DIR/ns/d1/d2/d3/b
+f $ODF_DIR/ns/d1/d2/d3/c
+d $ODF_DIR/ns/d1/d2/d3/d4
+d $ODF_DIR/ns/d5
+d $ODF_DIR/ns/d6
+FILES
+}
-f $LOWER_DIR0/d1/.wh.x
-
-f $LOWER_DIR2/d1/d2/d3/d4/.wh.d
+# initial set of ODF files
+function odf_beforefiles {
+cat <<FILES
+w $ODF_DIR/ns/d1/x
+w $ODF_DIR/ns/d1/d2/d3/d4/d
FILES
}
f $LOWER_DIR1/y
FILES
}
+
+function odf_beforefiles_383 {
+cat <<FILES
+f $ODF_DIR/ns/y
+f $ODF_DIR/ns/d1/x
+FILES
+}
+
function afterfiles_383 {
cat <<FILES
f $LOWER_DIR0/y
FILES
}
+function odf_afterfiles_rw {
+cat <<FILES
+f $ODF_DIR/ns/y
+f $ODF_DIR/ns/d1/x
+f $ODF_DIR/ns/d1/d2/d3/d4/d
+FILES
+}
-function afterfiles_rw {
+function lower_afterfiles_rw {
cat <<FILES
f $LOWER_DIR0/y
f $LOWER_DIR0/d1/x
d $LOWER_DIR0/d1/d2/d3/d4
f $LOWER_DIR0/d1/d2/d3/d4/d
-f $LOWER_DIR2/d1/d2/d3/d4/.wh.d
-
FILES
}
+function odf_afterfiles_ro {
+cat <<FILES
+f $ODF_DIR/ns/y
+f $ODF_DIR/ns/d1/x
+f $ODF_DIR/ns/d1/d2/d3/d4/d
+FILES
+}
-function afterfiles_ro {
+function lower_afterfiles_ro {
cat <<FILES
f $LOWER_DIR0/y
d $LOWER_DIR0/d1/d2/d3
d $LOWER_DIR0/d1/d2/d3/d4
f $LOWER_DIR0/d1/d2/d3/d4/d
-f $LOWER_DIR2/d1/d2/d3/d4/.wh.d
FILES
}
function rw {
- ( directories ; beforefiles) | create_hierarchy
+ POPULATE_ODF=0
+ ( directories ; ) | create_hierarchy
+
+ setup_odf
+ fill_odf
+ ./progs/make_sb 3 $LOWER_DIR0 6 $LOWER_DIR1 6 $LOWER_DIR2 6
+
+ POPULATE_ODF=1
+ ( odf_beforefiles ; ) | create_hierarchy
- mount_union "" $LOWER_DIR0 $LOWER_DIR1 $LOWER_DIR2
+ mount_union "odf=$ODF_DIR"
touch $MOUNTPOINT/y
checktype $MOUNTPOINT/y 'f'
touch $MOUNTPOINT/d1/d2/d3/d4/d
checktype $MOUNTPOINT/d1/d2/d3/d4/d 'f'
+ ls -lR $MOUNTPOINT >/dev/null
unmount_union
- ( directories ; afterfiles_rw ) | check_hierarchy $TOP_LOWER_DIR
+
+ #Sanity check the lower level dirs/files
+ ( directories ; lower_afterfiles_rw ) | check_hierarchy $TOP_LOWER_DIR
+
+ #Sanity check ODF, and then discard it
+ ( odf_directories ; odf_afterfiles_rw ) | check_hierarchy $ODF_DIR/ns
+ discard_odf
}
function ro {
- ( directories ; beforefiles) | create_hierarchy
+ POPULATE_ODF=0
+ ( directories ; ) | create_hierarchy
+
+ setup_odf
+ fill_odf
+ ./progs/make_sb 3 $LOWER_DIR0 6 $LOWER_DIR1 4 $LOWER_DIR2 4
- mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
+ POPULATE_ODF=1
+ ( odf_beforefiles ; ) | create_hierarchy
+ mount_union "odf=$ODF_DIR"
touch $MOUNTPOINT/y
checktype $MOUNTPOINT/y 'f'
touch $MOUNTPOINT/d1/d2/d3/d4/d
checktype $MOUNTPOINT/d1/d2/d3/d4/d 'f'
+ ls -lR $MOUNTPOINT >/dev/null
unmount_union
- ( directories ; afterfiles_ro ) | check_hierarchy $TOP_LOWER_DIR
+ ( directories ; lower_afterfiles_ro ) | check_hierarchy $TOP_LOWER_DIR
+
+ #Sanity check (TODO) ODF, and then discard it
+ ( odf_directories ; odf_afterfiles_ro ) | check_hierarchy $ODF_DIR/ns
+ discard_odf
}
function BUG383 {
+ POPULATE_ODF=0
( directories ; beforefiles_383 ) | create_hierarchy
- mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro
+ setup_odf
+ fill_odf
+ ./progs/make_sb 3 $LOWER_DIR0 6 $LOWER_DIR1 4 $LOWER_DIR2 4
+
+ POPULATE_ODF=1
+ mount_union "odf=$ODF_DIR"
local SM=`umask`
umask 022
umask $SM
+ ls -lR $MOUNTPOINT >/dev/null
unmount_union
( directories ; afterfiles_383 ) | check_hierarchy $TOP_LOWER_DIR
+
+ #Sanity check (TODO) ODF, and then discard it
+ ( odf_directories ; odf_beforefiles_383 ) | check_hierarchy $ODF_DIR/ns
+ discard_odf
+}
+
+
+function fill_odf {
+ mkdir $ODF_DIR/ic
+ mkdir $ODF_DIR/ns
+ mkdir $ODF_DIR/reclaim
+ mkdir $ODF_DIR/sr
+ touch $ODF_DIR/whiteout
}
if [ -z "$FXNS" ] ; then