The litefile options have been updated to what we wished in design;

also the documents related with "statelite" and "genimage" are updated;
the description for "litefile" options are updated in Schema.pm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7527 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mxi1 2010-09-20 17:16:25 +00:00
parent 798d09c5fa
commit 8b22241384
10 changed files with 277 additions and 143 deletions

View File

@ -142,13 +142,14 @@ litefile => {
image => "The name of the image that will use these files, as specified in the osimage table. 'ALL' means use it for all images.",
file => "The full pathname of the file. e.g: /etc/hosts. If the path is a directory, then it should be terminated with a '/'. ",
options => "Options for the file:\n\n".
" blank, tmpfs, or ALL - the file is readwrite and will be placed in tmpfs on the booted node. 'All' implies tmpfs,rw. When searching for the file, the first one to be found in the litetree hierarchy will be used. When the node is rebooted, this file will be reinitialized.\n\n".
" bind instead of using symbolic links, 'mount --bind' is used to mount the file to the root image, and the permission for the file will be the same as the original.\n\n".
" bind,persistent - the file will be persistent across reboots, and the file will be mounted with '--bind' option. \n\n".
" con - The contents of the pathname are concatenated to the contents of the existing file. For this directive the searching in the litetree hierarchy does not stop when the first match is found. Con is similar to tmpfs, but all files found in the hierarchy will be concatenated to the file when found.\n\n".
" persistent - This means that the file is readwrite and will be persistent across reboots. If the file does not exist at first, it will be created during initialization. If the file exists, it will be left alone. (Requires the statelite table to be filled out with a spot for persistent storage).\n\n".
" persistent,con - readwrite file that is concatenated initially and then placed in the persistent mount point.\n\n".
" ro - file will be read only. This file will be located in the directory hierarchy specified in the litetree table. The directory will be mounted on the node while the node is running (not just during the boot process), and the file will be linked to this directory. Changes made to this file on the server will be immediately seen in this file on the node.",
" blank, tempfs or rw - \"mount --bind\" is used to mount the file/directory to the root image, and the permission for the file/directory will be the same as the original.\n\n".
" persistent - the file/directory will be persistent across reboots, and the file/directory will be mounted with \"--bind\" option. If the file/directory doesnot exist at first, it will be created during initialization. If the file/directory exists, it will be left alone. ( Requires the statelite table to be filled out with a spot for persistent storage).\n\n".
" con - the contents of the pathname are concatenated to the contents of the existing file. For this directive the searching in the litetree hierarchy doesn not stop when the first match is found. Con is similiar to bind, but all files found in the hierarchy will be concatenated to the file when found. (which is re-designed to use bind option).\n\n".
" ro - file will be read only. This file will be located in the directory hierarchy specified in the litetree table. The directory will be mounted on the node while the node is running, and the file will be mounted to this directory with \"--bind -o ro\" opton.\n\n".
" link - the file is readwrite and will be placed in tmpfs on the booted node. When searching for the file, the first one to be found in the litetree hierarchy will be used. When the node is rebooted, this file will be reinitialized.\n\n".
" link, con - The contents of the pathname are concatenated to the contents of the existing file. For this directive the searching in the litetree hierarchy does not stop when the first match is found. Con is similar to tmpfs, but all files found in the hierarchy will be concatenated to the file when found.\n\n".
" link, persistent - This means that the file is readwrite and will be persistent across reboots. If the file does not exist at first, it will be created during initialization. If the file exists, it will be left alone. (Requires the statelite table to be filled out with a spot for persistent storage).\n\n".
" link, ro - file will be read only. This file will be located in the directory hierarchy specified in the litetree table. The directory will be mounted on the node while the node is running (not just during the boot process), and the file will be linked to this directory. Changes made to this file on the server will be immediately seen in this file on the node.",
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
}

View File

@ -369,7 +369,7 @@ sub mergeArrays {
foreach(@$arr){
next if($_->{file} eq '');
my $o = $_->{options};
$o = "bind" unless ($o);
$o = "tempfs" unless ($o);
# TODO: put some logic in here to make sure that ro is alone.
# if type is ro and con, then this is wrong silly!
#if($p eq "ro" and $t eq "con"){

View File

@ -178,9 +178,9 @@ sub process_request {
my $filename = $tmp[1];
my $fileopt = $tmp[0];
if ($fileopt eq "tmpfs,rw" or $fileopt eq "ro") {
if ($fileopt =~ m/link/) {
# backup them into .statebackup dirctory
# restore the files with "tmpfs" options
# restore the files with "link" options
if ($filename =~ m/\/$/) {
chop $filename;
}
@ -378,7 +378,7 @@ sub process_request {
my @tmp = split /\s+/, $entry;
my $filename = $tmp[1];
my $fileopt = $tmp[0];
if ($fileopt eq "tmpfs,rw" or $fileopt eq "ro") {
if ($fileopt =~ m/link/) {
chop $filename if ($filename =~ m/\/$/);
xCAT::Utils->runcmd("rm -rf $rootimg_dir$filename", 0, 1);
xCAT::Utils->runcmd("mv $rootimg_dir/.statebackup$filename $rootimg_dir$filename", 0, 1);

View File

@ -222,7 +222,7 @@ sub process_request {
foreach my $entry (keys %hashNew) {
my @tmp = split (/\s+/, $entry);
if ($hashNew{$entry}) {
if ( $tmp[0] eq "ro" or $tmp[0] eq "con") {
if ( $tmp[0] =~ m/ro/ or $tmp[0] =~ m/con/) {
$callback->({error=>[qq{the parent directory should not be with "ro" or "con" as its option}], errorcode=>[1]});
return;
}
@ -230,12 +230,12 @@ sub process_request {
my @tmpc = split (/\s+/, $child);
my $f = $tmp[1];
my $fc = $tmpc[1];
if ( ($tmp[0] eq "tmpfs,rw") and ( $tmpc[0] ne "tmpfs,rw" or $tmpc[0] ne "ro") ) {
$callback->({error=>[qq{$fc can only use "tmpfs,rw" or "ro" as its option based on the option of $f}], errorcode=> [ 1]});
if ( ($tmp[0] =~ m/link/) and ( $tmpc[0] !~ m/link/) ) {
$callback->({error=>[qq{Based on the option of $f, $fc can only use "link"-headed options}], errorcode=> [ 1]});
return;
}
if ( ($tmp[0] ne "tmpfs,rw") and ($tmpc[0] eq "tmpfs,rw" or $tmpc[0] eq "ro") ) {
$callback->({error=>[qq{$fc shouldnot use "tmpfs,rw" options }], errorcode=> [ 1]});
if ( ($tmp[0] !~ m/link/) and ($tmpc[0] =~ m/link/) ) {
$callback->({error=>[qq{$fc shouldnot use "link"-headed options }], errorcode=> [ 1]});
return;
}
if ( ($tmp[0] eq qq{persistent}) and ($tmpc[0] ne qq{persistent}) ) {
@ -551,7 +551,7 @@ sub liteItem {
my $rif = $rootimg_dir . $f;
my $d = dirname($f);
if (($entry[0] eq "tmpfs,rw") or ($entry[0] eq "ro")) {
if ($entry[0] =~ m/link/) {
# 1. copy original contents if they exist to .default directory
# 2. remove file
# 3. create symbolic link to .statelite

View File

@ -236,7 +236,7 @@ ProcessType () {
fi
case "${3}" in
tmpfs,rw)
link) # the previous name is tmpfs,rw
if [ -d ${TMPFS}${2} ]; then
cp -r -a ${1}* ${TMPFS}${2}
echo "cp -r -a ${1}* ${TMPFS}${2}" >>$LOG
@ -246,12 +246,111 @@ ProcessType () {
fi
# the link will already be in place on the image, so nothing else to do!
;;
link,ro)
# need to make sure directory exists:
if [ ! -d ${TMPFS}${PPATH} ]; then
mkdir -p ${TMPFS}${PPATH} >>$LOG 2>&1
fi
TARGET=`echo ${TMPFS}${2} | sed -e 's/\/$//'`
LINK=`echo ${1} | sed -e "s/^\/sysroot//"`
echo "ln -sf ${LINK} ${TARGET}" >>$LOG 2>&1
ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
;;
link,persistent)
# everything from root image points to tmpfs
# so have tmpfs point to persistent
# make tree in persistent and tmpfs
# need to check whether the option of its parent direcotry is persistent or not
TMPDIR=`dirname ${2}`
if [ ! -e ${PERSISTENT}${TMPDIR} ]; then
mkdir -p ${PERSISTENT}${TMPDIR} >>$LOG 2>&1
echo "mkdir -p ${PERSISTENT}${TMPDIR}" >>$LOG 2>&1
fi
if [ "$isChild" = "1" ]; then
num=${#PLIST[@]}
for ((i=0;i<$num; i++)); do
set -- ${PLIST[$i]}
itype=$1
ipath=$2
if [ "$PPATH" = "$ipath" ]; then
if [[ ! "$itype" =~ "persistent*" ]]; then
if [ ! -e ${PERSISTENT}${2} ]; then
echo "cp -r -a ${1} ${PERSISTENT}${2}" >>$LOG 2>&1
cp -r -a ${1} ${PERSISTENT}${2} 2>&1 >>$LOG
fi
# mount it to ${TARGET}
echo "mount --bind ${PERSISTENT}${2} ${TARGET}" >>$LOG 2>&1
mount --bind ${PERSISTENT}${2} ${TARGET}
fi
fi
done
else
if [[ ! -d ${PERSISTENT}${PPATH} && ! -d `readlink -m ${PERSISTENT}${PPERS}` ]]; then
# unless the entry is one directory or one link to the directory
rm -rf ${PERSISTENT}${PPERS} >>$LOG 2>&1
mkdir -p ${PERSISTENT}${PPERS} >>$LOG 2>&1
echo "mkdir -p ${PERSISTENT}${PPERS}" >>$LOG 2>&1
fi
# if the file doesn't exist, then copy it over to persistent
if [ ! -e ${PERSISTENT}${2} ]; then
# if its not there, then take it from something else
echo "cp -r -a ${1} ${PERSISTENT}${2}" >>$LOG 2>&1
cp -r -a ${1} ${PERSISTENT}${2} 2>&1 >>$LOG 2>&1
fi
# if target is a directory, then remove it first,
# otherwise, the link will be created under this dir instead of replacing it.
# whack of trailing / for persistent directories:
TARGET=`echo ${TMPFS}${2} | sed -e 's/\/$//'`
if [ -d ${TARGET} ]; then
echo "rm -Rf ${TARGET}" >>$LOG 2>&1
rm -Rf ${TARGET} 2>&1 >>$LOG
fi
# finally make the tmpfs link point to the persistent file
# you have to get rid of the /sysroot in the beginning
# so that when the chroot happens the link is valid.
LINK=`echo ${PERSISTENT}${2} | sed -e 's/^\/sysroot//'`
echo "ln -sf ${LINK} ${TARGET}" >>$LOG
ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
fi
;;
link,con)
echo "cat ${1} >>${TMPFS}${2}" >>$LOG 2>&1
cat ${1} >>${TMPFS}${2} >>$LOG 2>&1
;;
con)
# cons go in bind # TODO ???
cat ${1} >>${TMPFS}${2}
echo "cat ${1} >>${TMPFS}${2}" >>$LOG
# there's one more option to indicate the con is at the end
if [ "${5}" -eq "1" ]; then
# mount the file with "--bind" option
echo "mount --bind ${TMPFS}${2} /sysroot${2}" >>$LOG
mount --bind ${TMPFS}${2} /sysroot${2} >> $LOG 2>&1
else
echo "cat ${1} >>${TMPFS}${2}" >>$LOG 2>&1
cat ${1} >>${TMPFS}${2} >>$LOG 2>&1
fi
;;
bind)
tempfs) # the default option, same as "tempfs" and "NULL"
ORIG=`echo ${2} | sed -e 's/\/$//'`
TARGET=`echo ${1}`
if [ -d ${TMPFS}${2} ]; then
cp -r -a ${1}* ${TMPFS}${2}
echo "cp -r -a ${1}* ${TMPFS}${2}" >>$LOG
else
cp -r -a ${1} ${TMPFS}${2}
echo "cp -r -a ${1} ${TMPFS}${2}" >>$LOG
fi
if [ "$isChild" = "0" ]; then
echo "mount --bind ${TMPFS}${2} /sysroot${ORIG}" >>$LOG
mount --bind ${TMPFS}${2} /sysroot${ORIG}>>$LOG 2>&1
fi
;;
rw) # the default option, same as "tempfs" and "NULL"
ORIG=`echo ${2} | sed -e 's/\/$//'`
TARGET=`echo ${1}`
@ -286,17 +385,19 @@ ProcessType () {
echo "mount --bind ${TARGET} /sysroot/${ORIG}" >>$LOG
mount --bind ${TARGET} /sysroot/${ORIG}>>$LOG 2>&1
;;
ro)
ro) # TODO: change to bind style
# need to make sure directory exists:
if [ ! -d ${TMPFS}${PPATH} ]; then
mkdir -p ${TMPFS}${PPATH} >>$LOG 2>&1
fi
TARGET=`echo ${TMPFS}${2} | sed -e 's/\/$//'`
#LINK=`echo ${1} | sed -e "s/^${MNTDIR}//"`
LINK=`echo ${1} | sed -e "s/^\/sysroot//"`
DEST=`echo ${1} | sed -e "s/^\/sysroot//"`
echo "ln -sf ${LINK} ${TARGET}" >>$LOG 2>&1
ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
#echo "ln -sf ${LINK} ${TARGET}" >>$LOG 2>&1
#ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
echo "mout --bind -o ro ${TARGET} ${DEST}" >>$LOG 2>&1
mount --bind -o ro ${TARGET} ${DEST} >>$LOG 2>&1
;;
*)
;;
@ -305,41 +406,45 @@ ProcessType () {
FindFile () {
# $1 = Pathname to locate
# $2 = Type of file
# $1 = Pathname to locate
# $2 = Type of file
# $3 = 0 or 1: 0 means parent, 1 means child
path=$1
type=$2
path=$1
type=$2
isChild=$3
FOUND=0
for DIR in `cat ${SYNCTREE}`
do
FOUND=0
for DIR in `cat ${SYNCTREE}` ;do
DIR=${DIR/:/}
if [ -e ${TREEMOUNT}/${DIR}${path} ]; then
FOUND=1 # we found it!
if [ -e ${TREEMOUNT}/${DIR}${path} ]; then
FOUND=1 # we found it!
if [ -d ${TREEMOUNT}/${DIR}${path} ] && [ "0" -eq `ls -A ${TREEMOUNT}/${DIR}${path} |wc -l` ]; then
FOUND=0
else
ProcessType ${TREEMOUNT}/${DIR}${path} ${path} ${type} ${isChild}
if [[ "${2}" =~ "con" ]]; then
continue
else
break
fi
ProcessType ${TREEMOUNT}/${DIR}${path} ${path} ${type} ${isChild}
if [[ "${2}" -eq "link,con" ]]; then
continue
else
break
fi
fi
fi
done
fi
done
## for "con" option
if [[ "$FOUND" -eq "1" ]] && [[ "${type}" -eq "con" ]]; then
ProcessType ${TREEMOUNT}/${DIR}${path} ${path} ${type} ${isChild} 1
fi
## Default behavior is to get from the image
if [ "$FOUND" = "0" ]; then
if [ -e "${DEFAULT}${path}" ]; then
ProcessType ${DEFAULT}${path} ${path} ${type} ${isChild}
else
echo "Could not find ${path} in defaults or any other place" >/dev/console
fi
# if it wasn't found, mount rw in tmpfs
fi
## Default behavior is to get from the image
if [ "$FOUND" = "0" ]; then
if [ -e "${DEFAULT}${path}" ]; then
ProcessType ${DEFAULT}${path} ${path} ${type} ${isChild}
else
echo "Could not find ${path} in defaults or any other place" >/dev/console
fi
# if it wasn't found, mount rw in tmpfs
fi
}

View File

@ -169,18 +169,6 @@ MountTrees () {
done
}
ResolveLinksOld () {
# go through each file and do the right thing to it.
cat $SYNCLIST | grep -v "^#" | \
while read type path
do
FindFile ${path} ${type}
done
}
ResolveLinks () {
exec <$SYNCLIST
i=0
@ -238,9 +226,9 @@ ProcessType () {
#PATH=$2 # file
#TYPE=$3 # type of file
#isChild=$4 # child = 1, parent = 0
PPATH=`dirname ${2}`
PPATH=`dirname ${2}`
# every type has to have a base dir in tmpfs
if [ ! -d ${TMPFS}${PPATH} ] && [ ! -L ${TMPFS}${PPATH} ]; then
mkdir -p ${TMPFS}${PPATH}
@ -248,7 +236,7 @@ ProcessType () {
fi
case "${3}" in
tmpfs,rw)
link) # the previous name is tmpfs,rw
if [ -d ${TMPFS}${2} ]; then
cp -r -a ${1}* ${TMPFS}${2}
echo "cp -r -a ${1}* ${TMPFS}${2}" >>$LOG
@ -258,12 +246,94 @@ ProcessType () {
fi
# the link will already be in place on the image, so nothing else to do!
;;
link,ro)
# need to make sure directory exists:
if [ ! -d ${TMPFS}${PPATH} ]; then
mkdir -p ${TMPFS}${PPATH} >>$LOG 2>&1
fi
TARGET=`echo ${TMPFS}${2} | sed -e 's/\/$//'`
LINK=`echo ${1} | sed -e "s/^\/sysroot//"`
echo "ln -sf ${LINK} ${TARGET}" >>$LOG 2>&1
ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
;;
link,persistent)
# everything from root image points to tmpfs
# so have tmpfs point to persistent
# make tree in persistent and tmpfs
# need to check whether the option of its parent direcotry is persistent or not
TMPDIR=`dirname ${2}`
if [ ! -e ${PERSISTENT}${TMPDIR} ]; then
mkdir -p ${PERSISTENT}${TMPDIR} >>$LOG 2>&1
echo "mkdir -p ${PERSISTENT}${TMPDIR}" >>$LOG 2>&1
fi
if [ "$isChild" = "1" ]; then
num=${#PLIST[@]}
for ((i=0;i<$num; i++)); do
set -- ${PLIST[$i]}
itype=$1
ipath=$2
if [ "$PPATH" = "$ipath" ]; then
if [[ ! "$itype" =~ "persistent*" ]]; then
if [ ! -e ${PERSISTENT}${2} ]; then
echo "cp -r -a ${1} ${PERSISTENT}${2}" >>$LOG 2>&1
cp -r -a ${1} ${PERSISTENT}${2} 2>&1 >>$LOG
fi
# mount it to ${TARGET}
echo "mount --bind ${PERSISTENT}${2} ${TARGET}" >>$LOG 2>&1
mount --bind ${PERSISTENT}${2} ${TARGET}
fi
fi
done
else
if [[ ! -d ${PERSISTENT}${PPATH} && ! -d `readlink -m ${PERSISTENT}${PPERS}` ]]; then
# unless the entry is one directory or one link to the directory
rm -rf ${PERSISTENT}${PPERS} >>$LOG 2>&1
mkdir -p ${PERSISTENT}${PPERS} >>$LOG 2>&1
echo "mkdir -p ${PERSISTENT}${PPERS}" >>$LOG 2>&1
fi
# if the file doesn't exist, then copy it over to persistent
if [ ! -e ${PERSISTENT}${2} ]; then
# if its not there, then take it from something else
echo "cp -r -a ${1} ${PERSISTENT}${2}" >>$LOG 2>&1
cp -r -a ${1} ${PERSISTENT}${2} 2>&1 >>$LOG 2>&1
fi
# if target is a directory, then remove it first,
# otherwise, the link will be created under this dir instead of replacing it.
# whack of trailing / for persistent directories:
TARGET=`echo ${TMPFS}${2} | sed -e 's/\/$//'`
if [ -d ${TARGET} ]; then
echo "rm -Rf ${TARGET}" >>$LOG 2>&1
rm -Rf ${TARGET} 2>&1 >>$LOG
fi
# finally make the tmpfs link point to the persistent file
# you have to get rid of the /sysroot in the beginning
# so that when the chroot happens the link is valid.
LINK=`echo ${PERSISTENT}${2} | sed -e 's/^\/sysroot//'`
echo "ln -sf ${LINK} ${TARGET}" >>$LOG
ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
fi
;;
link,con)
echo "cat ${1} >>${TMPFS}${2}" >>$LOG 2>&1
cat ${1} >>${TMPFS}${2} >>$LOG 2>&1
;;
con)
# cons go in tmpfs
cat ${1} >>${TMPFS}${2}
echo "cat ${1} >>${TMPFS}${2}" >>$LOG
# cons go in bind # TODO ???
# there's one more option to indicate the con is at the end
if [ "${5}" -eq "1" ]; then
# mount the file with "--bind" option
echo "mount --bind ${TMPFS}${2} /sysroot${2}" >>$LOG
mount --bind ${TMPFS}${2} /sysroot${2} >> $LOG 2>&1
else
echo "cat ${1} >>${TMPFS}${2}" >>$LOG 2>&1
cat ${1} >>${TMPFS}${2} >>$LOG 2>&1
fi
;;
bind)
tempfs) # the default option, same as "tempfs" and "NULL"
ORIG=`echo ${2} | sed -e 's/\/$//'`
TARGET=`echo ${1}`
@ -280,7 +350,24 @@ ProcessType () {
mount --bind ${TMPFS}${2} /sysroot${ORIG}>>$LOG 2>&1
fi
;;
bind,persistent)
rw) # the default option, same as "tempfs" and "NULL"
ORIG=`echo ${2} | sed -e 's/\/$//'`
TARGET=`echo ${1}`
if [ -d ${TMPFS}${2} ]; then
cp -r -a ${1}* ${TMPFS}${2}
echo "cp -r -a ${1}* ${TMPFS}${2}" >>$LOG
else
cp -r -a ${1} ${TMPFS}${2}
echo "cp -r -a ${1} ${TMPFS}${2}" >>$LOG
fi
if [ "$isChild" = "0" ]; then
echo "mount --bind ${TMPFS}${2} /sysroot${ORIG}" >>$LOG
mount --bind ${TMPFS}${2} /sysroot${ORIG}>>$LOG 2>&1
fi
;;
persistent)
if [ ! -d ${PERSISTENT}${PPATH} ]; then
mkdir -p ${PERSISTENT}${PPATH}
echo "mkdir -p ${PERSISTENT}${PPATH}" >>$LOG
@ -298,83 +385,19 @@ ProcessType () {
echo "mount --bind ${TARGET} /sysroot/${ORIG}" >>$LOG
mount --bind ${TARGET} /sysroot/${ORIG}>>$LOG 2>&1
;;
persistent*)
# everything from root image points to tmpfs
# so have tmpfs point to persistent
# make tree in persistent and tmpfs
# need to check whether the option of its parent direcotry is persistent or not
TMPDIR=`dirname ${2}`
if [ ! -e ${PERSISTENT}${TMPDIR} ]; then
mkdir -p ${PERSISTENT}${TMPDIR}
echo "mkdir -p ${PERSISTENT}${TMPDIR}" >>$LOG
fi
if [ "$isChild" = "1" ]; then
num=${#PLIST[@]}
for ((i=0;i<$num; i++)); do
set -- ${PLIST[$i]}
itype=$1
ipath=$2
if [ "$PPATH" = "$ipath" ]; then
if [[ ! "$itype" =~ "persistent*" ]]; then
if [ ! -e ${PERSISTENT}${2} ]; then
echo "cp -r -a ${1} ${PERSISTENT}${2}" >>$LOG
cp -r -a ${1} ${PERSISTENT}${2} 2>&1 >>$LOG
fi
# mount it to ${TARGET}
echo "mount --bind ${PERSISTENT}${2} ${TARGET}" >>$LOG
mount --bind ${PERSISTENT}${2} ${TARGET}
fi
fi
done
else
if [ ! -d ${PERSISTENT}${PPATH} ] && [! -d `readlink -m ${PERSISTENT}${PPERS}`]; then
# unless the entry is one directory or one link to the directory
rm -rf ${PERSISTENT}${PPERS}
mkdir -p ${PERSISTENT}${PPERS}
echo "mkdir -p ${PERSISTENT}${PPERS}" >>$LOG
fi
# if the file doesn't exist, then copy it over to persistent
if [ ! -e ${PERSISTENT}${2} ]; then
# if its not there, then take it from something else
echo "cp -r -a ${1} ${PERSISTENT}${2}" >>$LOG
cp -r -a ${1} ${PERSISTENT}${2} 2>&1 >>$LOG
fi
#if target is a directory, then remove it first,
#otherwise, the link will be created under this dir instead of replacing it.
# whack of trailing / for persistent directories:
TARGET=`echo ${TMPFS}${2} | sed -e 's/\/$//'`
if [ -d ${TARGET} ]; then
echo "rm -Rf ${TARGET}" >>$LOG
rm -Rf ${TARGET} 2>&1 >>$LOG
fi
# finally make the tmpfs link point to the persistent file
# you have to get rid of the /sysroot in the beginning
# so that when the chroot happens the link is valid.
LINK=`echo ${PERSISTENT}${2} | sed -e 's/^\/sysroot//'`
echo "ln -sf ${LINK} ${TARGET}" >>$LOG
ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
fi
;;
ro)
ro) # TODO: change to bind style
# need to make sure directory exists:
if [ ! -d ${TMPFS}${PPATH} ]; then
mkdir -p ${TMPFS}${PPATH} >>$LOG 2>&1
fi
TARGET=`echo ${TMPFS}${2} | sed -e 's/\/$//'`
#LINK=`echo ${1} | sed -e "s/^${MNTDIR}//"`
LINK=`echo ${1} | sed -e "s/^\/sysroot//"`
DEST=`echo ${1} | sed -e "s/^\/sysroot//"`
echo "ln -sf ${LINK} ${TARGET}" >>$LOG 2>&1
ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
#echo "ln -sf ${LINK} ${TARGET}" >>$LOG 2>&1
#ln -sf ${LINK} ${TARGET} >>$LOG 2>&1
echo "mout --bind -o ro ${TARGET} ${DEST}" >>$LOG 2>&1
mount --bind -o ro ${TARGET} ${DEST} >>$LOG 2>&1
;;
*)
;;
@ -399,15 +422,20 @@ FindFile () {
FOUND=0
else
ProcessType ${TREEMOUNT}/${DIR}${path} ${path} ${type} ${isChild}
if [ "${2}" = "con" ]; then
if [[ "${2}" -eq "link,con" ]]; then
continue
else
break
fi
fi
fi
fi
done
## for "con" option
if [[ "$FOUND" -eq "1" ]] && [[ "${type}" -eq "con" ]]; then
ProcessType ${TREEMOUNT}/${DIR}${path} ${path} ${type} ${isChild} 1
fi
## Default behavior is to get from the image
if [ "$FOUND" = "0" ]; then