common.sh: switch out echo -ne for printf and fix incorrect offset

echo -ne isn't portable but printf with octals is so this
makes the switch.

In addition, the current offset is off by 3 and is updating the UUID space.
This was from style cleanup and all functional test passed - of course.
This change fixes that too.

TEST=built and installed and checked ro enforcement works
BUG=chromium-os:7972

Change-Id: Ifb3cb2c6f3219af819baff5750453439e1ba6edf

Review URL: http://codereview.chromium.org/3997001
This commit is contained in:
Will Drewry 2010-10-20 18:11:24 -05:00
parent e38f90f309
commit 9b7cb51697

View File

@ -475,8 +475,8 @@ setup_symlinks_on_root() {
disable_rw_mount() {
local rootfs="$1"
local offset="${2-0}" # in bytes
local ro_compat_offset=$((0x467 + 3)) # Set 'highest' byte
echo -ne '\xff' |
local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte
printf '\377' |
sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \
conv=notrunc count=1 bs=1
}
@ -484,8 +484,8 @@ disable_rw_mount() {
enable_rw_mount() {
local rootfs="$1"
local offset="${2-0}"
local ro_compat_offset=$((0x467 + 3)) # Set 'highest' byte
echo -ne '\x00' |
local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte
printf '\000' |
sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \
conv=notrunc count=1 bs=1
}