Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Unified Diff: mount_gpt_image.sh

Issue 4974006: Allow RO rootfs and writeable stateful. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: add back sumlinks Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mount_gpt_image.sh
diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh
index 3156c1586e647f1d210f143fec47cf4aa9fb3bd6..1c95a91eb17ab5d2c7b4e5af23511ef454d6eb5d 100755
--- a/mount_gpt_image.sh
+++ b/mount_gpt_image.sh
@@ -20,6 +20,8 @@ DEFINE_string board "$DEFAULT_BOARD" \
"The board for which the image was built." b
DEFINE_boolean read_only $FLAGS_FALSE \
"Mount in read only mode -- skips stateful items."
+DEFINE_boolean safe $FLAGS_FALSE \
+ "Mount rootfs in read only mode."
DEFINE_boolean unmount $FLAGS_FALSE \
"Unmount previously mounted dir." u
DEFINE_string from "/dev/sdc" \
@@ -64,9 +66,12 @@ function unmount_image() {
function get_usb_partitions() {
local ro_flag=""
+ local safe_flag=""
[ ${FLAGS_read_only} -eq ${FLAGS_TRUE} ] && ro_flag="-o ro"
+ [ ${FLAGS_read_only} -eq ${FLAGS_TRUE} -o \
+ ${FLAGS_safe} -eq ${FLAGS_TRUE} ] && safe_flag="-o ro -t ext2"
- sudo mount ${ro_flag} "${FLAGS_from}3" "${FLAGS_rootfs_mountpt}"
+ sudo mount ${safe_flag} "${FLAGS_from}3" "${FLAGS_rootfs_mountpt}"
sudo mount ${ro_flag} "${FLAGS_from}1" "${FLAGS_stateful_mountpt}"
if [[ -n "${FLAGS_esp_mountpt}" ]]; then
sudo mount ${ro_flag} "${FLAGS_from}12" "${FLAGS_esp_mountpt}"
@@ -79,8 +84,15 @@ function get_gpt_partitions() {
# Mount the rootfs partition using a loopback device.
local offset=$(partoffset "${FLAGS_from}/${filename}" 3)
local ro_flag=""
+ local safe_flag=""
+
if [ ${FLAGS_read_only} -eq ${FLAGS_TRUE} ]; then
ro_flag="-o ro"
+ fi
+
+ if [ ${FLAGS_read_only} -eq ${FLAGS_TRUE} -o \
+ ${FLAGS_safe} -eq ${FLAGS_TRUE} ]; then
+ safe_flag="-o ro -t ext2"
else
# Make sure any callers can actually mount and modify the fs
# if desired.
@@ -88,7 +100,7 @@ function get_gpt_partitions() {
enable_rw_mount "${FLAGS_from}/${filename}" "$(( offset * 512 ))"
fi
- sudo mount ${ro_flag} -o loop,offset=$(( offset * 512 )) \
+ sudo mount ${safe_flag} -o loop,offset=$(( offset * 512 )) \
"${FLAGS_from}/${filename}" "${FLAGS_rootfs_mountpt}"
# Mount the stateful partition using a loopback device.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698