-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the use of device mapper for root filesystem mounts
This makes it possible to detect the physical block device that the root filesystem uses even if Linux's device mapper is being used for encrypted partitions or overlays or anything else.
- Loading branch information
Showing
8 changed files
with
389 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Tests that the "require-path-on-device" feature works. This allows one to | ||
# update firmware images based on where the filesystem is mounted. | ||
# | ||
|
||
. "$(cd "$(dirname "$0")" && pwd)/common.sh" | ||
|
||
$HAS_MOUNT_SHIM || exit 77 | ||
|
||
cat >$CONFIG <<EOF | ||
task test.correct { | ||
require-path-on-device("/", "/dev/rootdisk0p1") | ||
on-init { info("correct") } | ||
} | ||
task test.fail { | ||
on-init { error("something else!") } | ||
} | ||
EOF | ||
cat >$WORK/expected_output.txt <<EOF | ||
fwup: correct | ||
EOF | ||
|
||
# Create the firmware file the normal way | ||
$FWUP_CREATE -c -f $CONFIG -o $FWFILE | ||
|
||
# Use the mount shim instead of the write shim | ||
LD_PRELOAD="$MOUNT_LD_PRELOAD" DYLD_INSERT_LIBRARIES="$MOUNT_DYLD_INSERT_LIBRARIES" $FWUP_APPLY -a -q -d $IMGFILE -i $FWFILE -t test > $WORK/actual_output.txt | ||
diff -w $WORK/expected_output.txt $WORK/actual_output.txt | ||
|
||
# Check that the verify logic works on this file | ||
$FWUP_VERIFY -V -i $FWFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Tests that the "require-path-on-device" feature can traverse through | ||
# device mapper mounts. | ||
# | ||
|
||
. "$(cd "$(dirname "$0")" && pwd)/common.sh" | ||
|
||
$HAS_MOUNT_SHIM || exit 77 | ||
|
||
if [ "$HOST_OS" != "Linux" ]; then | ||
echo "Skipping since device mapper logic only on Linux-specific fwup code." | ||
exit 77 | ||
fi | ||
|
||
cat >$CONFIG <<EOF | ||
task test.correct { | ||
require-path-on-device("/boot", "/dev/mmcblk0p2") | ||
on-init { info("correct") } | ||
} | ||
task test.fail { | ||
on-init { error("something else!") } | ||
} | ||
EOF | ||
cat >$WORK/expected_output.txt <<EOF | ||
fwup: correct | ||
EOF | ||
|
||
# Create the firmware file the normal way | ||
$FWUP_CREATE -c -f $CONFIG -o $FWFILE | ||
|
||
# Set up some fake /sys/dev/block directories similar to device mapper | ||
mkdir -p $WORK/sys/dev/block/254:0/slaves/mmcblk0p1 # Fake entry to test scanning | ||
mkdir -p $WORK/sys/dev/block/254:0/slaves/mmcblk0p2 | ||
mkdir -p $WORK/sys/dev/block/254:0/slaves/mmcblk0p3 # Fake entry to test scanning | ||
echo "1:1" > $WORK/sys/dev/block/254:0/slaves/mmcblk0p1/dev | ||
echo "179:2" > $WORK/sys/dev/block/254:0/slaves/mmcblk0p2/dev | ||
echo "1:1" > $WORK/sys/dev/block/254:0/slaves/mmcblk0p3/dev | ||
|
||
# Use the mount shim instead of the write shim | ||
LD_PRELOAD="$MOUNT_LD_PRELOAD" DYLD_INSERT_LIBRARIES="$MOUNT_DYLD_INSERT_LIBRARIES" $FWUP_APPLY -a -q -d $IMGFILE -i $FWFILE -t test > $WORK/actual_output.txt | ||
diff -w $WORK/expected_output.txt $WORK/actual_output.txt | ||
|
||
# Check that the verify logic works on this file | ||
$FWUP_VERIFY -V -i $FWFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/verify-syscalls | ||
/.libs | ||
/libwrite_shim* | ||
/libmount_shim* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.