OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # This script can be called to switch from kernel slot A / sda3 | 6 # This script can be called to switch from kernel slot A / sda3 |
7 # to kernel slot B / sda5 and vice versa. | 7 # to kernel slot B / sda5 and vice versa. |
8 | 8 |
9 ROOT_DEV=$(rootdev) | 9 ROOT_DEV=$(rootdev -s) |
10 OTHER_ROOT_DEV=$(echo $ROOT_DEV | tr '35' '53') | 10 OTHER_ROOT_DEV=$(echo $ROOT_DEV | tr '35' '53') |
11 | 11 |
12 if [ "${ROOT_DEV}" = "${OTHER_ROOT_DEV}" ] | 12 if [ "${ROOT_DEV}" = "${OTHER_ROOT_DEV}" ] |
13 then | 13 then |
14 echo "Not a normal rootfs partition (3 or 5): ${ROOT_DEV}" | 14 echo "Not a normal rootfs partition (3 or 5): ${ROOT_DEV}" |
15 exit 1 | 15 exit 1 |
16 fi | 16 fi |
17 | 17 |
18 # Successfully being able to mount the other partition | 18 # Successfully being able to mount the other partition |
19 # and run postinst guarantees that there is a real partition there. | 19 # and run postinst guarantees that there is a real partition there. |
20 echo "Running postinst on $OTHER_ROOT_DEV" | 20 echo "Running postinst on $OTHER_ROOT_DEV" |
21 MOUNTPOINT=/tmp/newpart | 21 MOUNTPOINT=$(mktemp -d) |
22 mkdir -p "$MOUNTPOINT" | 22 mkdir -p "$MOUNTPOINT" |
23 mount "$OTHER_ROOT_DEV" "$MOUNTPOINT" | 23 mount -o ro "$OTHER_ROOT_DEV" "$MOUNTPOINT" |
24 "$MOUNTPOINT"/postinst "$OTHER_ROOT_DEV" | 24 "$MOUNTPOINT"/postinst "$OTHER_ROOT_DEV" |
25 POSTINST_RETURN_CODE=$? | 25 POSTINST_RETURN_CODE=$? |
26 umount "$MOUNTPOINT" | 26 umount "$MOUNTPOINT" |
27 rmdir "$MOUNTPOINT" | 27 rmdir "$MOUNTPOINT" |
28 | 28 |
29 exit $POSTINST_RETURN_CODE | 29 exit $POSTINST_RETURN_CODE |
OLD | NEW |