From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Lezcano Subject: Re: [PATCH] liblxc: lxc-debian expects missing directories Date: Thu, 05 Feb 2009 10:20:55 +0100 Message-ID: <498AAF77.20906@free.fr> References: <1233824717.28338.8.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1233824717.28338.8.camel@localhost> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Matt Helsley Cc: Containers List-Id: containers.vger.kernel.org Matt Helsley wrote: > lxc-debian fails unless the directories a given rootfs needs already > exist. To fix this without relying on any particular function call order > we can do: mkdir -p `dirname PATH/TO/FILE` > before actually making the file. > > Signed-off-by: Matt Helsley > --- > Do you have an example on how that happens ? When the script is called for creation, the rootfs is created with debootstrap, making sure the expected directories are there, no ? It is not a big deal to make sure the directories are there, but I would like to understand :) > scripts/lxc-debian.in | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > Index: lxc/scripts/lxc-debian.in > =================================================================== > --- lxc.orig/scripts/lxc-debian.in > +++ lxc/scripts/lxc-debian.in > @@ -24,13 +24,14 @@ SSHD_CONFIG="/etc/ssh/sshd_config" > # custom selinux > > write_debian_selinux() { > - mkdir $ROOTFS/selinux > + mkdir -p $ROOTFS/selinux > echo 0 > $ROOTFS/selinux/enforce > } > > # custom fstab > > write_debian_fstab() { > +mkdir -p `dirname $ROOTFS/$FSTAB` > cat < $ROOTFS/$FSTAB > tmpfs /dev/shm tmpfs defaults 0 0 > EOF > @@ -39,6 +40,7 @@ EOF > # custom inittab > > write_debian_inittab() { > +mkdir -p `dirname $ROOTFS/$INITTAB` > cat < $ROOTFS/$INITTAB > id:3:initdefault: > si::sysinit:/etc/init.d/rcS > @@ -62,6 +64,7 @@ EOF > # custom network configuration > > write_debian_network() { > +mkdir -p `dirname $ROOTFS/$INTERFACES` > cat < $ROOTFS/$INTERFACES > auto eth0 lo > iface eth0 inet static > @@ -76,6 +79,7 @@ EOF > # custom hostname > > write_debian_hostname() { > +mkdir -p `dirname $ROOTFS/$HOSTNAME` > cat < $ROOTFS/$HOSTNAME > $UTSNAME > EOF > @@ -84,6 +88,7 @@ EOF > # custom sshd configuration file > > write_debian_sshd_config() { > +mkdir -p `dirname $ROOTFS/$SSHD_CONFIG` > cat < $ROOTFS/$SSHD_CONFIG > Port 22 > Protocol 2 > > > > >