Patchwork [1/1] runqemu-export-rootfs and friends: don't put pseudo db in target fs

login
register
mail settings
Submitter Peter Seebach
Date Aug. 21, 2012, 6:31 p.m.
Message ID <511616ed1761453ec1323aa945c559ca6cafffd1.1345573717.git.peter.seebach@windriver.com>
Download mbox | patch
Permalink /patch/35085/
State New
Headers show

Comments

Peter Seebach - Aug. 21, 2012, 6:31 p.m.
In a few places, we have scripts which use <rootfs>/var/pseudo for
the pseudo state directory controlling a given filesystem. This
seems possibly risky because it means that stuff running under
qemu or whatnot could wipe out the data being used to handle that
rootfs.

Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
---
 .../installer/adt-installer/scripts/extract_rootfs |    7 +++----
 scripts/runqemu-export-rootfs                      |    2 +-
 scripts/runqemu-extract-sdk                        |   13 +++++++------
 3 files changed, 11 insertions(+), 11 deletions(-)
Scott Garman - Aug. 22, 2012, 4:34 p.m.
On 08/21/2012 11:31 AM, Peter Seebach wrote:
> In a few places, we have scripts which use <rootfs>/var/pseudo for
> the pseudo state directory controlling a given filesystem. This
> seems possibly risky because it means that stuff running under
> qemu or whatnot could wipe out the data being used to handle that
> rootfs.
>
> Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
> ---
>   .../installer/adt-installer/scripts/extract_rootfs |    7 +++----
>   scripts/runqemu-export-rootfs                      |    2 +-
>   scripts/runqemu-extract-sdk                        |   13 +++++++------
>   3 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs b/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs
> index 62dc170..0bbbeef 100755
> --- a/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs
> +++ b/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs
> @@ -28,7 +28,6 @@ extract_rootfs()
>     native_sysroot=$3
>     target_sysroot=$2
>     PSEUDO_COMMAND="$native_sysroot/usr/bin/pseudo"
> -  PSEUDO_OPTS="-P $natvie_sysroot/usr"
>     TAR_OPTS="-xjf"
>     PSEUDO_OPTS="-P $native_sysroot/usr"
>
> @@ -46,9 +45,9 @@ extract_rootfs()
>       mkdir -p "$target_sysroot"
>     fi
>
> -  mkdir -p "$target_sysroot/var/pseudo"
> -  touch "$target_sysroot/var/pseudo/pseudo.pid"
> -  PSEUDO_LOCALSTATEDIR="$target_sysroot/var/pseudo"
> +  mkdir -p "$target_sysroot/../pseudo_state"
> +  touch "$target_sysroot/../pseudo_state/pseudo.pid"
> +  PSEUDO_LOCALSTATEDIR="$target_sysroot/../pseudo_state"
>     export PSEUDO_LOCALSTATEDIR

This would mean that if someone tried to put multiple rootfs directories 
in the same subdirectory, they could clobber each other's pseudo_state 
data, correct? Putting multiple rootfs directories in the same subdir is 
a common use case already, I don't think we could break that.

If you appended the top-level rootfs directory name to ../pseudo_state, 
e.g, ../pseudo_state_<dirname>, that would keep the pseudo_state 
directories separate and make it fairly obvious what rootfs they 
belonged to.

Also, neither of these schemes would support having $target_sysroot 
directly under / (though I'm not sure why someone would do that).

Scott
Peter Seebach - Aug. 22, 2012, 7:20 p.m.
On Wed, 22 Aug 2012 09:34:35 -0700
Scott Garman <scott.a.garman@intel.com> wrote:

> This would mean that if someone tried to put multiple rootfs
> directories in the same subdirectory, they could clobber each other's
> pseudo_state data, correct? Putting multiple rootfs directories in
> the same subdir is a common use case already, I don't think we could
> break that.

Good catch!

I didn't realize this was a common use case.

> If you appended the top-level rootfs directory name
> to ../pseudo_state, e.g, ../pseudo_state_<dirname>, that would keep
> the pseudo_state directories separate and make it fairly obvious what
> rootfs they belonged to.

Good idea.

> Also, neither of these schemes would support having $target_sysroot 
> directly under / (though I'm not sure why someone would do that).

Yeah. I don't really like having the pseudo stuff outside the
directory, but I dislike it less than I dislike having it in the
directory. :)

-s
Richard Purdie - Aug. 22, 2012, 7:39 p.m.
On Wed, 2012-08-22 at 09:34 -0700, Scott Garman wrote:

> This would mean that if someone tried to put multiple rootfs directories 
> in the same subdirectory, they could clobber each other's pseudo_state 
> data, correct? Putting multiple rootfs directories in the same subdir is 
> a common use case already, I don't think we could break that.
> 
> If you appended the top-level rootfs directory name to ../pseudo_state, 
> e.g, ../pseudo_state_<dirname>, that would keep the pseudo_state 
> directories separate and make it fairly obvious what rootfs they 
> belonged to.

I'd wondered about this too. Can you use <dirname>.pseudo_state to make
the list sort better and help people with tab completion and so on? :)

Cheers,

Richard
Peter Seebach - Aug. 27, 2012, 4:17 p.m.
On Wed, 22 Aug 2012 20:39:24 +0100
Richard Purdie <richard.purdie@linuxfoundation.org> wrote:

> I'd wondered about this too. Can you use <dirname>.pseudo_state to
> make the list sort better and help people with tab completion and so
> on? :)

This is even BETTER. And since my previous submission had a Hilarious
Typo in it, I'll revise with this too.

-s

Patch

diff --git a/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs b/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs
index 62dc170..0bbbeef 100755
--- a/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs
+++ b/meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs
@@ -28,7 +28,6 @@  extract_rootfs()
   native_sysroot=$3
   target_sysroot=$2
   PSEUDO_COMMAND="$native_sysroot/usr/bin/pseudo"
-  PSEUDO_OPTS="-P $natvie_sysroot/usr"
   TAR_OPTS="-xjf"
   PSEUDO_OPTS="-P $native_sysroot/usr"
 
@@ -46,9 +45,9 @@  extract_rootfs()
     mkdir -p "$target_sysroot"
   fi
 
-  mkdir -p "$target_sysroot/var/pseudo"
-  touch "$target_sysroot/var/pseudo/pseudo.pid"
-  PSEUDO_LOCALSTATEDIR="$target_sysroot/var/pseudo"
+  mkdir -p "$target_sysroot/../pseudo_state"
+  touch "$target_sysroot/../pseudo_state/pseudo.pid"
+  PSEUDO_LOCALSTATEDIR="$target_sysroot/../pseudo_state"
   export PSEUDO_LOCALSTATEDIR
 
   echo_info "Extracting rootfs: $1, using pseudo..."
diff --git a/scripts/runqemu-export-rootfs b/scripts/runqemu-export-rootfs
index f8213ba..9b7941b 100755
--- a/scripts/runqemu-export-rootfs
+++ b/scripts/runqemu-export-rootfs
@@ -68,7 +68,7 @@  NFSPID=~/.runqemu-sdk/nfs$NFS_INSTANCE.pid
 MOUNTPID=~/.runqemu-sdk/mount$NFS_INSTANCE.pid
 
 PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr"
-PSEUDO_LOCALSTATEDIR="$NFS_EXPORT_DIR/var/pseudo"
+PSEUDO_LOCALSTATEDIR="$NFS_EXPORT_DIR/../pseudo_state"
 export PSEUDO_LOCALSTATEDIR
 
 if [ ! -d "$PSEUDO_LOCALSTATEDIR" ]; then
diff --git a/scripts/runqemu-extract-sdk b/scripts/runqemu-extract-sdk
index 4b52475..8bab333 100755
--- a/scripts/runqemu-extract-sdk
+++ b/scripts/runqemu-extract-sdk
@@ -73,15 +73,16 @@  if [ ! -d "$SDK_ROOTFS_DIR" ]; then
 	mkdir -p "$SDK_ROOTFS_DIR"
 fi
 
-if [ -e "$SDK_ROOTFS_DIR/var/pseudo" ]; then
-	echo "Error: $SDK_ROOTFS_DIR/var/pseudo already exists!"
-	echo "Please delete the entire rootfs tree manually if this is really what you want"
+if [ -e "$SDK_ROOTFS_DIR/../pseudo_state" ]; then
+	echo "Error: $SDK_ROOTFS_DIR/../pseudo_state already exists!"
+	echo "Please delete the rootfs tree and pseudo directory manually"
+        echo "if this is really what you want."
 	exit 1
 fi
 
-mkdir -p "$SDK_ROOTFS_DIR/var/pseudo"
-touch "$SDK_ROOTFS_DIR/var/pseudo/pseudo.pid"
-PSEUDO_LOCALSTATEDIR="$SDK_ROOTFS_DIR/var/pseudo"
+mkdir -p "$SDK_ROOTFS_DIR/../pseudo_state"
+touch "$SDK_ROOTFS_DIR/../pseudo_state/pseudo.pid"
+PSEUDO_LOCALSTATEDIR="$SDK_ROOTFS_DIR/../pseudo_state"
 export PSEUDO_LOCALSTATEDIR
 
 echo "Extracting rootfs tarball using pseudo..."