diff options
author | Dave Reisner <dreisner@archlinux.org> | 2013-06-20 15:45:40 +0200 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-06-25 23:16:41 +0200 |
commit | 8c40f930f6b491e95abd1e853c31330b2e6ca6af (patch) | |
tree | 7d75b436bad7d5929b5b99c6944180f9b1b369a0 | |
parent | c61d4791d34591bb0fed558494a52d517d900b44 (diff) | |
download | mkinitcpio-8c40f930f6b491e95abd1e853c31330b2e6ca6af.tar.gz mkinitcpio-8c40f930f6b491e95abd1e853c31330b2e6ca6af.tar.xz |
init: merge duped code, use bitfield_has_bit in fsck_root
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r-- | init_functions | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/init_functions b/init_functions index 7e591fc..3fa2128 100644 --- a/init_functions +++ b/init_functions @@ -204,16 +204,10 @@ fsck_root() { fsck_device "$root" fsckret=$? - fsck_ret() { - [ -z "$fsckret" ] && return 1 - [ "$fsckret" -eq "$1" ] && return 0 - [ "$(( fsckret & $1 ))" -eq "$1" ] - } - - if [ "$fsckret" -ne 255 ]; then - if [ "$fsckret" = '0' ] || fsck_ret 1; then + if [ -n "$fsckret" ] && [ "$fsckret" -ne 255 ]; then + if [ "$fsckret" -eq 0 ] || bitfield_has_bit $fsckret 1; then echo "$fsckret" > /run/initramfs/root-fsck - elif fsck_ret 4; then + elif bitfield_has_bit "$fsckret" 4; then err "Bailing out. Run 'fsck $root' manually" printf '%s\n' \ "********** FILESYSTEM CHECK FAILED **********" \ @@ -227,7 +221,7 @@ fsck_root() { echo ":: Automatic reboot in progress" sleep 2 reboot -f - elif fsck_ret 2; then + elif bitfield_has_bit "$fsckret" 2; then printf '%s\n' \ "************** REBOOT REQUIRED **************" \ "* *" \ @@ -236,13 +230,13 @@ fsck_root() { "*********************************************" sleep 10 reboot -f - elif fsck_ret 8; then + elif bitfield_has_bit "$fsckret" 8; then err "fsck failed on '$root'" - elif fsck_ret 16; then + elif bitfield_has_bit "$fsckret" 16; then err "Failed to invoke fsck: usage or syntax error" - elif fsck_ret 32; then + elif bitfield_has_bit "$fsckret" 32; then echo ":: fsck cancelled on user request" - elif fsck_ret 128; then + elif bitfield_has_bit "$fsckret" 128; then err "fatal error invoking fsck" fi fi |