Chromium Code Reviews| Index: mount_gpt_image.sh |
| diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh |
| index 3156c1586e647f1d210f143fec47cf4aa9fb3bd6..f55f55f8c05fa2c9bcdd583d1f233b5e402bfb8c 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. |
| @@ -126,7 +138,8 @@ function mount_image() { |
| "${FLAGS_rootfs_mountpt}/usr/local" |
| # Setup symlinks in /usr/local so you can emerge packages into /usr/local. |
| - if [ ${FLAGS_read_only} -eq ${FLAGS_FALSE} ]; then |
| + if [ ${FLAGS_read_only} -eq ${FLAGS_FALSE} -a \ |
|
sosa
2010/11/16 23:04:24
Should be -o FLAGS_safe = true ... if the stateful
Nick Sanders
2010/11/17 00:15:33
What does this do exactly, why do we want to write
sosa
2010/11/17 00:32:38
In a nutshell, there are symlinks in /usr/local (i
Nick Sanders
2010/11/17 01:00:26
Ok, that makes sense, thanks!
|
| + ${FLAGS_safe} -eq ${FLAGS_FALSE} ]; then |
| setup_symlinks_on_root "${FLAGS_stateful_mountpt}/dev_image" \ |
| "${FLAGS_stateful_mountpt}/var" "${FLAGS_stateful_mountpt}" |
| fi |