Move PSEUDO_LOCALSTATEDIR outside rootfs
cover Move PSEUDO_LOCALSTATEDIR outside rootfs
There's a race condition in one of our (non-poky) builds which involves a rootfs getting deleted while a pseudo process has a db in it open. This caused me to realize that there existed a pseudo database in a target filesystem, which made me panic. And we have a few really strange reports I've never been able to reproduce where target filesystems under qemu went pear-shaped in ways that look like pseudo suddenly got really, really, confused.
Like say what would happen if a target could wipe out its own filesystem permissions, because they were in its rootfs. :P
I haven't tested this super thoroughly, but I can still complete builds and SDK builds with it, and it makes sense.
The following changes since commit 4ef8960c8d2876914bb78cbdce5fae3c5297e942:
Khem Raj (1):
gcc-cross-intermediate, gcc-crosssdk-intermediate: Remove
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib seebs/varpseudo
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=seebs/varpseudo
Peter Seebach (1):
runqemu-export-rootfs and friends: don't put pseudo db in target fs
.../installer/adt-installer/scripts/extract_rootfs | 7 +++---- scripts/runqemu-export-rootfs | 2 +- scripts/runqemu-extract-sdk | 13 +++++++------ 3 files changed, 11 insertions(+), 11 deletions(-)
PATCH 1/1 runqemu-export-rootfs and friends: don't put pseudo db in target fs
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.
--- .../installer/adt-installer/scripts/extract_rootfs | 7 +++---- scripts/runqemu-export-rootfs | 2 +- scripts/runqemu-extract-sdk | 13 +++++++------ 3 files changed, 11 insertions(+), 11 deletions(-)
meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs +3 -4
@@ -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..."
scripts/runqemu-export-rootfs +1 -1
@@ -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
scripts/runqemu-extract-sdk +7 -6
@@ -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..."
Signature · 1 line
1.7.0.4
Re: [PATCH 1/1] runqemu-export-rootfs and friends: don't put pseudo db in target fs
Quoted 26 lines · Peter Seebach
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 <[email protected]>--- .../installer/adt-installer/scripts/extract_rootfs | 7 +++---- scripts/runqemu-export-rootfs | 2 +- scripts/runqemu-extract-sdk | 13 +++++++------ 3 files changed, 11 insertions(+), 11 deletions(-)meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs +0
-1@@ -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"
meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs extract_rootfs() · line 51
Quoted 10 lines
meta/recipes-devtools/installer/adt-installer/scripts/extract_rootfs +3
-3@@ -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
Signature · 3 lines
Scott Garman Embedded Linux Engineer - Yocto Project Intel Open Source Technology Center
Re: [PATCH 1/1] runqemu-export-rootfs and friends: don't put pseudo db in target fs
Quoted 5 lines · On Wed, 22 Aug 2012 09:34:35 -0700 Scott Garman <[email protected]>…
This would mean that if someone tried to put multiple rootfs directories in the same subdirectory, they could clobber each other's
pseudo_statedata, 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.
Quoted 4 lines
If you appended the top-level rootfs directory name
to ../pseudo_state, e.g, ../pseudo_state_<dirname>, that would keep thepseudo_statedirectories separate and make it fairly obvious what rootfs they belonged to.
Good idea.
Quoted 2 lines
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
Signature · 1 line
Listen, get this. Nobody with a good compiler needs to be justified.
Re: [PATCH 1/1] runqemu-export-rootfs and friends: don't put pseudo db in target fs
In reply to Scott GarmanQuoted 9 lines · Scott Garman
This would mean that if someone tried to put multiple rootfs directories in the same subdirectory, they could clobber each other's
pseudo_statedata, 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_statedirectories 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
Re: [PATCH 1/1] runqemu-export-rootfs and friends: don't put pseudo db in target fs
Quoted 3 lines · On Wed, 22 Aug 2012 20:39:24 +0100 Richard Purdie…
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
Signature · 1 line
Listen, get this. Nobody with a good compiler needs to be justified.