head	1.8;
access;
symbols
	UNIONFS-1_4:1.6
	LKML-branch:1.6.0.14
	LKML:1.6
	UNIONFS-1_3-branch:1.6.0.12
	UNIONFS-1_3:1.6
	UNIONFS-1_2:1.6
	UNIONFS-1_2-branch:1.6.0.10
	UNIONFS-1_2-branchpoint:1.6
	UNIONFS_branchman:1.6
	branchman:1.6.0.8
	UNIONFS-1_1_4:1.6
	UNIONFS-1_1-patches:1.6.0.6
	UNIONFS-1_1_3:1.6
	crc-submitted-to-ols2006:1.6
	remount:1.6.0.4
	UNIONFS-1_1_2:1.6
	BEFORE_MOUNTPOINT_CROSSING:1.6
	UNIONFS-1_1_1:1.6
	UNIONFS_PRE_1_1_1:1.6
	UNIONFS-1_1:1.6
	UNIONFS_PRE_1_1:1.6.0.2
	UNIONFS-1_0_14:1.6
	UNIONFS_PRE_DENTRY_LOCKING:1.6
	UNIONFS-1_0_13:1.6
	submitted-to-tos-2005:1.6
	UNIONFS-1_0_12:1.6
	UNIONFS-1_0_11:1.6
	UNIONFS-1_0_10:1.6
	UNIONFS-1_0_9:1.3
	UNIONFS-1_0_6:1.3
	UNIONFS-1_0_4:1.3
	UNIONFS-1_0_3:1.3
	SUBMITTED_TO_USENIX_2005:1.3
	UNIONFS-1_0:1.3
	before-new-rename:1.3;
locks; strict;
comment	@# @;


1.8
date	2007.01.16.19.06.13;	author yiannos;	state Exp;
branches;
next	1.7;

1.7
date	2007.01.16.18.53.51;	author yiannos;	state Exp;
branches;
next	1.6;

1.6
date	2005.03.10.14.20.03;	author cwright;	state Exp;
branches
	1.6.14.1;
next	1.5;

1.5
date	2005.03.07.14.58.34;	author cwright;	state Exp;
branches;
next	1.4;

1.4
date	2005.02.19.00.51.48;	author ezk;	state Exp;
branches;
next	1.3;

1.3
date	2004.08.13.15.59.12;	author cwright;	state Exp;
branches;
next	1.2;

1.2
date	2004.08.09.16.48.38;	author cwright;	state Exp;
branches;
next	1.1;

1.1
date	2004.08.05.19.44.57;	author cwright;	state Exp;
branches;
next	;

1.6.14.1
date	2006.07.26.02.50.32;	author dquigley;	state dead;
branches;
next	;


desc
@@


1.8
log
@another snapmerge bug fix
@
text
@#!/bin/sh
#vim:filetype=sh

if [ "$#" -lt "2" ]
then
cat 1>&2 <<HERE
$0 merges Unionfs snapshots onto the base.
$0 base snap0 [ snap1 ... ]

If you want to merge two or more consecutive snapshots to create a new
snapshot, as if snap1, snap0 are two branches that are mounted over base, you
can not directly call snapmerge because whiteouts are not handled.  Instead,
you should create a new Unionfs that merges an empty directory snap10 and base
(with base=ro).  Then you can run snapmerge /mnt/unionfs snap0 snap1.  snap10
will contain the merged snapshot, with only the proper number of whiteouts.
HERE
	exit 1
fi

BASE=$1

shift

WD=`pwd`
if [ ! `echo $BASE | cut -b1` = "/" ] ; then
	BASE="$WD/$BASE"
fi

while [ ! -z "$1" ]
do
	SNAP=$1
	if [ ! -d $SNAP ] ; then
		echo "$0: $SNAP not a directory" 1>&2
		exit 1
	fi

	cd $SNAP || exit 1

	echo "Merging $SNAP onto $BASE."

	# Directories
	find . -type d | tail -n +2 |  sed -e 's/\.\///' |
	while read N
	do
		mkdir -p $BASE/$N
		chmod $BASE/$N --reference=$N
		chown $BASE/$N --reference=$N
		touch $BASE/$N --reference=$N
	done

	# Copy Files
	find . -not \( -regex '.*/\.wh\.[^/]*' -type f \) -not -type d |  sed -e 's/\.\///' |
	while read N
	do
		cp -a --remove-destination $N $BASE/$N
	done

	# Handle Whiteouts
	find . \( -regex '.*/\.wh\.[^/]*' -type f \) | sed -e 's/\.\///;s/\.wh\.//' |
	while read N
	do
		rm -rf $BASE/$N
	done

	cd $WD
	shift
done

cd $WD

exit 0
@


1.7
log
@snapmerge ownership and links bug fix
@
text
@d42 1
a42 1
	find . -type d | tail +2 |  sed -e 's/\.\///' |
@


1.6
log
@* misc/snapmerge: Explain how to get two snapshots merged into one
snapshot.
@
text
@d47 1
d55 1
a55 1
		cp -a $N $BASE/$N
@


1.6.14.1
log
@Cleaning up the directory so we have less to make into patches
@
text
@@


1.5
log
@* misc/snapmerge: Fix permissions/times after copying files.
@
text
@d6 11
a16 2
	echo "$0 merges Unionfs snapshots onto the base."
	echo "$0 base snap0 [ snap1 ... ]" 1>&2
@


1.4
log
@minor NEWS updates. pesky trailing whitespace nuked
@
text
@d37 2
@


1.3
log
@Handle working directory better.
@
text
@d31 1
a31 1
	
d38 1
a38 1
	
@


1.2
log
@Snapmerge that actually merges.
@
text
@d16 3
d29 9
d40 1
a40 2
	echo "Merging $SNAP onto $BASE."
	find . -not \( -regex '.*/\.wh\.[^/]*' -type f \) |  sed -e 's/\.\///' |
d43 1
a43 1
		cp -a $N $WD/$BASE/$N
d50 1
a50 1
		rm -f $WD/BASE/$N
@


1.1
log
@Snapshot merging utility.
@
text
@d32 1
a32 1
		echo cp -a $N $BASE/$N
d39 1
a39 1
		echo rm -f $BASE/$N
@

