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

Side by Side Diff: bin/cros_make_image_bootable

Issue 5216003: cros_make_image_bootable: Do a final sanity check on the rootfs by running e2fsck (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: new change Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 # 6 #
7 # Script which ensures that a given image has an up-to-date 7 # Script which ensures that a given image has an up-to-date
8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs. 8 # kernel partition, rootfs integrity hashes, and legacy bootloader configs.
9 9
10 # Load common constants. This should be the first executable line. 10 # Load common constants. This should be the first executable line.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 --vmlinuz="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz \ 243 --vmlinuz="${FLAGS_rootfs_mountpoint}"/boot/vmlinuz \
244 --usb_disk="${usb_disk}" \ 244 --usb_disk="${usb_disk}" \
245 ${bootloader_to_flags} \ 245 ${bootloader_to_flags} \
246 $kernel_part 246 $kernel_part
247 247
248 trap - EXIT 248 trap - EXIT
249 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${FLAGS_rootfs_mountpoint}" \ 249 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${FLAGS_rootfs_mountpoint}" \
250 -s "${FLAGS_statefulfs_mountpoint}" 250 -s "${FLAGS_statefulfs_mountpoint}"
251 } 251 }
252 252
253 verify_image_rootfs() {
254 local image=$1
255 local rootfs_offset="$(partoffset ${image} 3)"
256 local rootfs_size="$(partsize ${image} 3)"
257
258 local rootfs_tmp_file=$(mktemp)
259 trap "rm $rootfs_tmp_file" EXIT
sosa 2010/11/24 18:16:15 Use {} around var names to be consistent with rest
gauravsh 2010/11/24 19:40:18 Done.
260 sudo dd if="$image" of="$rootfs_tmp_file" bs=512 skip="$rootfs_offset"
261
262 # This flips the read-inly compatibility flag, so that
sosa 2010/11/24 18:16:15 read-only*
gauravsh 2010/11/24 19:40:18 Done.
263 # e2fsck does not complain about unknown file system capabilities.
264 enable_rw_mount $rootfs_tmp_file
265 info "Running e2fsck to check root file system for errors"
266 sudo e2fsck -fn "$rootfs_tmp_file" ||
267 die "Root file system has errors, please ensure boot.desc and/or \
sosa 2010/11/24 18:16:15 Indent 2 here
gauravsh 2010/11/24 19:40:18 Done.
268 command line parameters are correct"
269 }
270
253 # Use default of current image location if the output dir doesn't exist. 271 # Use default of current image location if the output dir doesn't exist.
254 if [ ! -d ${FLAGS_output_dir} ]; then 272 if [ ! -d ${FLAGS_output_dir} ]; then
255 warn "Output dir not found, using ${IMAGE_DIR}." 273 warn "Output dir not found, using ${IMAGE_DIR}."
256 FLAGS_output_dir="${IMAGE_DIR}" 274 FLAGS_output_dir="${IMAGE_DIR}"
257 FLAGS_rootfs_hash="${IMAGE_DIR}/rootfs.hash" 275 FLAGS_rootfs_hash="${IMAGE_DIR}/rootfs.hash"
258 FLAGS_rootfs_mountpoint="${IMAGE_DIR}/rootfs_dir" 276 FLAGS_rootfs_mountpoint="${IMAGE_DIR}/rootfs_dir"
259 FLAGS_statefulfs_mountpoint="${IMAGE_DIR}/stateful_dir" 277 FLAGS_statefulfs_mountpoint="${IMAGE_DIR}/stateful_dir"
260 FLAGS_espfs_mountpoint="${IMAGE_DIR}/esp" 278 FLAGS_espfs_mountpoint="${IMAGE_DIR}/esp"
261 fi 279 fi
262 280
263 # Create the directories if they don't exist. 281 # Create the directories if they don't exist.
264 mkdir -p ${FLAGS_rootfs_mountpoint} 282 mkdir -p ${FLAGS_rootfs_mountpoint}
265 mkdir -p ${FLAGS_statefulfs_mountpoint} 283 mkdir -p ${FLAGS_statefulfs_mountpoint}
266 mkdir -p ${FLAGS_espfs_mountpoint} 284 mkdir -p ${FLAGS_espfs_mountpoint}
267 285
268 make_image_bootable ${IMAGE} 286 make_image_bootable ${IMAGE}
287 verify_image_rootfs ${IMAGE}
269 288
270 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then 289 if [ ${FLAGS_cleanup_dirs} -eq ${FLAGS_TRUE} ]; then
271 rmdir ${FLAGS_rootfs_mountpoint} 290 rmdir ${FLAGS_rootfs_mountpoint}
272 rmdir ${FLAGS_statefulfs_mountpoint} 291 rmdir ${FLAGS_statefulfs_mountpoint}
273 rmdir ${FLAGS_espfs_mountpoint} 292 rmdir ${FLAGS_espfs_mountpoint}
274 fi 293 fi
OLDNEW
« 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