#! /bin/sh ### BEGIN INIT INFO # Provides: checkroot mtab # Required-Start: mountdevsubfs hostname # Required-Stop: # Should-Start: keymap hwclockfirst hdparm bootlogd # Should-stop: # Default-Start: S # Default-Stop: # X-Interactive: true # Short-Description: Check to root file system. ### END INIT INFO # Include /usr/bin in path to find on_ac_power if /usr/ is on the root # partition. global PATH := '/sbin:/bin:/usr/bin' global FSCK_LOGFILE := '/var/log/fsck/checkroot' test $FSCKFIX || global FSCKFIX := 'no' test $SULOGIN || global SULOGIN := 'no' source /lib/init/vars.sh source /lib/lsb/init-functions source /lib/init/mount-functions.sh proc do_start { # Trap SIGINT so that we can handle user interrupt of fsck. trap "" INT # # Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to # be spawned from this script *before anything else* with a timeout, # like sysv does. # test $SULOGIN = yes && sulogin -t 30 $CONSOLE global KERNEL := $[uname -s] global MACHINE := $[uname -m] read_fstab # # Activate the swap device(s) in /etc/fstab. This needs to be done # before fsck, since fsck can be quite memory-hungry. # global ENABLE_SWAP := 'no' matchstr $KERNEL { Linux { if test $NOSWAP = yes { test $VERBOSE = no || log_warning_msg "Not activating swap as requested via bootoption noswap." global ENABLE_SWAP := 'no' } else { if test $swap_on_lv = yes { test $VERBOSE = no || log_warning_msg "Not activating swap on logical volume." } elif test $swap_on_file = yes { test $VERBOSE = no || log_warning_msg "Not activating swap on swapfile." } else { global ENABLE_SWAP := 'yes' } } } * { global ENABLE_SWAP := 'yes' } } if test $ENABLE_SWAP = yes { if test $VERBOSE = no { log_action_begin_msg "Activating swap" swapon -a -e >/dev/null !2 > !1 log_action_end_msg $Status } else { log_daemon_msg "Activating swap" swapon -a -v log_end_msg $Status } } # # Does the root device in /etc/fstab match with the actual device ? # If not we try to use the /dev/root alias device, and if that # fails we create a temporary node in /run. # # Do this only on Linux. Neither kFreeBSD nor Hurd have # /dev/root and the device ids used here are specific to # Linux. global KERNEL := $[uname] if test $rootcheck = yes && test $KERNEL = Linux { global ddev := $[mountpoint -qx $rootdev] global rdev := $[mountpoint -d /] if test $ddev != $rdev && test $ddev != "4:0" { if test $[mountpoint -qx /dev/root] = "4:0" { global rootdev := '/dev/root' } else { if \ rm -f /run/rootdev \ && mknod -m 600 /run/rootdev b $(rdev%:*) $(rdev#*:) \ && test -e /run/rootdev { global rootdev := '/run/rootdev' } else { global rootfatal := 'yes' } } } } # # Bother, said Pooh. # if test $rootfatal = yes { log_failure_msg "The device node $rootdev for the root filesystem is missing or incorrect or there is no entry for the root filesystem listed in /etc/fstab. The system is also unable to create a temporary node in /run. This means you have to fix the problem manually." log_warning_msg "A maintenance shell will now be started. CONTROL-D will terminate this shell and restart the system." # Start a single user shell on the console if ! sulogin $CONSOLE { log_failure_msg "Attempt to start maintenance shell failed. Will restart in 5 seconds." sleep 5 } test $VERBOSE = no || log_action_msg "Will now restart" reboot -f } # See if we're on AC Power. If not, we're not gonna run our # check. If on_ac_power (in /usr/) is unavailable, behave as # before and check all file systems needing it. # Disabled AC power check until fsck can be told to only check the # file system if it is corrupt when running on battery. (bug #526398) # if which on_ac_power >/dev/null 2>&1 && [ "$rootcheck" = yes ] # then # on_ac_power >/dev/null 2>&1 # if [ "$?" -eq 1 ] # then # log_warning_msg "On battery power, so skipping file system check." # rootcheck=no # fi # fi # # See if we want to check the root file system. # global FSCKCODE := '0' if test -e /run/initramfs/fsck-root { global rootcheck := 'no' } if is_fastboot_active { test $rootcheck = yes && log_warning_msg "Fast boot enabled, so skipping root file system check." global rootcheck := 'no' } if which findmnt >/dev/null !2 > !1 { if test $[findmnt -f -n -o FSTYPE /] = "btrfs" { test $rootcheck = yes && log_warning_msg "btrfs root detected, so skipping root file system check." global rootcheck := 'no' } } if test $rootcheck = yes { # # Ensure that root is quiescent and read-only before fsck'ing. # # mount -n -o remount,ro / would be the correct syntax but # mount can get confused when there is a "bind" mount defined # in fstab that bind-mounts "/" somewhere else. # # So we use mount -n -o remount,ro $rootdev / but that can # fail on older kernels on sparc64/alpha architectures due # to a bug in sys_mount(). # # As a compromise we try both. # if \ ! mount -n -o remount,ro $rootdev / \ && ! mount -n -o remount,ro -t dummytype $rootdev / !2 >/dev/null \ && ! mount -n -o remount,ro / !2 >/dev/null { log_failure_msg "Cannot check root file system because it is not mounted read-only." global rootcheck := 'no' } } # # The actual checking is done here. # if test $rootcheck = yes { if test -f /forcefsck || grep -q -s -w -i "forcefsck" /proc/cmdline { global force := '"-f'" } else { global force := ''"" } if test $FSCKFIX = yes { global fix := '"-y'" } else { global fix := '"-a'" } global spinner := '"-C'" matchstr $TERM { dumb|network|unknown|"" { global spinner := ''"" } } # This Linux/s390x special case should go away. if test "$(KERNEL):$(MACHINE)" = Linux:s390x { global spinner := ''"" } if test $VERBOSE = no { log_action_begin_msg "Checking root file system" logsave -s $FSCK_LOGFILE fsck $spinner $force $fix -t $roottype $rootdev global FSCKCODE := $Status if test $FSCKCODE = 0 { log_action_end_msg 0 } else { log_action_end_msg 1 "code $FSCKCODE" } } else { log_daemon_msg "Will now check root file system" logsave -s $FSCK_LOGFILE fsck $spinner $force $fix -V -t $roottype $rootdev global FSCKCODE := $Status log_end_msg $FSCKCODE } } # # If there was a failure, drop into single-user mode. # # NOTE: "failure" is defined as exiting with a return code of # 4 or larger. A return code of 1 indicates that file system # errors were corrected but that the boot may proceed. A return # code of 2 or 3 indicates that the system should immediately reboot. # if test $FSCKCODE -eq 32 { log_warning_msg "File system check was interrupted by user" } elif test $FSCKCODE -gt 3 { # Surprise! Re-directing from a HERE document (as in "cat << EOF") # does not work because the root is currently read-only. log_failure_msg "An automatic file system check (fsck) of the root filesystem failed. A manual fsck must be performed, then the system restarted. The fsck should be performed in maintenance mode with the root filesystem mounted in read-only mode." log_warning_msg "The root filesystem is currently mounted in read-only mode. A maintenance shell will now be started. After performing system maintenance, press CONTROL-D to terminate the maintenance shell and restart the system." # Start a single user shell on the console if ! sulogin $CONSOLE { log_failure_msg "Attempt to start maintenance shell failed. Will restart in 5 seconds." sleep 5 } test $VERBOSE = no || log_action_msg "Will now restart" reboot -f } elif test $FSCKCODE -gt 1 { log_failure_msg "The file system check corrected errors on the root partition but requested that the system be restarted." log_warning_msg "The system will be restarted in 5 seconds." sleep 5 test $VERBOSE = no || log_action_msg "Will now restart" reboot -f } # # Remount root to final mode (rw or ro). # # See the comments above at the previous "mount -o remount" # for an explanation why we try this twice. # if ! mount -n -o remount,$rootopts,$rootmode $fstabroot / !2 >/dev/null { mount -n -o remount,$rootopts,$rootmode / } # If possible, migrate /etc/mtab to be a symlink to # /proc/mounts. Note that not all systems e.g. Hurd currently # support this. if test $rootmode != "ro" { mtab_migrate } if selinux_enabled && test -x /sbin/restorecon && test -r /etc/mtab { restorecon /etc/mtab } # # Remove /run/rootdev if we created it. # rm -f /run/rootdev # Update mount options for mounts created in early boot # S01mountkernfs.sh /etc/init.d/mountkernfs.sh reload # S03mountdevsubfs.sh /etc/init.d/mountdevsubfs.sh reload } proc do_status { # If / is read-write or swap is enabled, this script have done # its job. global rootrw := 'false' global swapon := 'false' if test -f /etc/mtab { if grep " / " /etc/mtab |grep -q rw { global rootrw := 'true' } } if test -f /proc/swaps { if test $[cat /proc/swaps |grep -v ^Filename] { global swapon := 'true' } } if test true = $rootrw || test true = $swapon { return 0 } else { return 4 } } matchstr $1 { start|"" { do_start } restart|reload|force-reload { echo "Error: argument '$1' not supported" > !2 exit 3 } stop { # No-op } status { do_status exit $Status } * { echo "Usage: checkroot.sh [start|stop]" > !2 exit 3 } } : (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PATH) op: Equal rhs: {(/sbin) (Lit_Other ":") (/bin) (Lit_Other ":") (/usr/bin)} spids: [43] ) ] spids: [43] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FSCK_LOGFILE) op: Equal rhs: {(/var/log/fsck/checkroot)} spids: [50] ) ] spids: [50] ) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$FSCKFIX"))} {(Lit_Other "]")}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:FSCKFIX) op:Equal rhs:{(no)} spids:[63])] spids: [63] ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$SULOGIN"))} {(Lit_Other "]")}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:SULOGIN) op:Equal rhs:{(no)} spids:[76])] spids: [76] ) ] op_id: Op_DPipe ) (C {(.)} {(/lib/init/vars.sh)}) (C {(.)} {(/lib/lsb/init-functions)}) (C {(.)} {(/lib/init/mount-functions.sh)}) (FuncDef name: do_start body: (BraceGroup children: [ (C {(trap)} {(DQ )} {(INT)}) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$SULOGIN"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) (C {(sulogin)} {(-t)} {(30)} {($ VSub_Name "$CONSOLE")}) ] op_id: Op_DAmp ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KERNEL) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)} {(-s)})]) left_token: spids: [160 164] ) ) } spids: [158] ) ] spids: [158] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MACHINE) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)} {(-m)})]) left_token: spids: [170 174] ) ) } spids: [168] ) ] spids: [168] ) (C {(read_fstab)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ENABLE_SWAP) op:Equal rhs:{(no)} spids:[199])] spids: [199] ) (Case to_match: {(DQ ($ VSub_Name "$KERNEL"))} arms: [ (case_arm pat_list: [{(Linux)}] action: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$NOSWAP"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) (C {(log_warning_msg)} {(DQ ("Not activating swap as requested via bootoption noswap."))} ) ] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ENABLE_SWAP) op: Equal rhs: {(no)} spids: [255] ) ] spids: [255] ) ] spids: [-1 231] ) ] else_action: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$swap_on_lv"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) (C {(log_warning_msg)} {(DQ ("Not activating swap on logical volume."))} ) ] op_id: Op_DPipe ) ] spids: [-1 277] ) (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$swap_on_file"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) (C {(log_warning_msg)} {(DQ ("Not activating swap on swapfile."))}) ] op_id: Op_DPipe ) ] spids: [301 316] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ENABLE_SWAP) op: Equal rhs: {(yes)} spids: [343] ) ] spids: [343] ) ] spids: [340 347] ) ] spids: [259 350] ) ] spids: [212 213 353 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ENABLE_SWAP) op: Equal rhs: {(yes)} spids: [360] ) ] spids: [360] ) ] spids: [356 357 364 -1] ) ] spids: [203 209 367] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$ENABLE_SWAP"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) ] action: [ (C {(log_action_begin_msg)} {(DQ ("Activating swap"))}) (SimpleCommand words: [{(swapon)} {(-a)} {(-e)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [419] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [422] ) ] ) (C {(log_action_end_msg)} {($ VSub_QMark "$?")}) ] spids: [-1 403] ) ] else_action: [ (C {(log_daemon_msg)} {(DQ ("Activating swap"))}) (C {(swapon)} {(-a)} {(-v)}) (C {(log_end_msg)} {($ VSub_QMark "$?")}) ] spids: [431 453] ) ] spids: [-1 385] ) ] spids: [-1 456] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KERNEL) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [494 496] ) ) } spids: [492] ) ] spids: [492] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$rootcheck"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$KERNEL"))} {(Lit_Other "=")} {(Linux)} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ddev) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [(C {(mountpoint)} {(-qx)} {($ VSub_Name "$rootdev")})] ) left_token: spids: [534 540] ) ) } spids: [532] ) ] spids: [532] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rdev) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [(C {(mountpoint)} {(-d)} {(/)})] ) left_token: spids: [546 552] ) ) } spids: [544] ) ] spids: [544] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$ddev"))} {(KW_Bang "!") (Lit_Other "=")} {(DQ ($ VSub_Name "$rdev"))} {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$ddev"))} {(KW_Bang "!") (Lit_Other "=")} {(DQ ("4:0"))} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) ] action: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(mountpoint)} {(-qx)} {(/dev/root)})] ) left_token: spids: [599 605] ) ) } {(Lit_Other "=")} {(DQ ("4:0"))} {(Lit_Other "]")} ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootdev) op: Equal rhs: {(/dev/root)} spids: [620] ) ] spids: [620] ) ] spids: [-1 617] ) ] else_action: [ (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(rm)} {(-f)} {(/run/rootdev)}) (AndOr children: [ (C {(mknod)} {(-m)} {(600)} {(/run/rootdev)} {(b)} { (BracedVarSub token: suffix_op: (StringUnary op_id: VOp1_Percent arg_word: {(":*")} ) spids: [651 655] ) } { (BracedVarSub token: suffix_op: (StringUnary op_id: VOp1_Pound arg_word: {("*:")} ) spids: [657 661] ) } ) (C {(Lit_Other "[")} {(-e)} {(/run/rootdev)} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootdev) op: Equal rhs: {(/run/rootdev)} spids: [679] ) ] spids: [679] ) ] spids: [-1 676] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootfatal) op: Equal rhs: {(yes)} spids: [686] ) ] spids: [686] ) ] spids: [683 690] ) ] spids: [624 693] ) ] spids: [-1 591] ) ] spids: [-1 696] ) ] spids: [-1 529] ) ] spids: [-1 699] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$rootfatal"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (C {(log_failure_msg)} { (DQ ("The device node ") ($ VSub_Name "$rootdev") (" for the root filesystem is missing or incorrect \n") ("or there is no entry for the root filesystem listed in /etc/fstab. \n") ("The system is also unable to create a temporary node in /run. \n") ("This means you have to fix the problem manually.") ) } ) (C {(log_warning_msg)} { (DQ ("A maintenance shell will now be started. \n") ("CONTROL-D will terminate this shell and restart the system.") ) } ) (If arms: [ (if_arm cond: [ (Pipeline children: [(C {(sulogin)} {($ VSub_Name "$CONSOLE")})] negated: True ) ] action: [ (C {(log_failure_msg)} { (DQ ("Attempt to start maintenance shell failed. \n") ("Will restart in 5 seconds.") ) } ) (C {(sleep)} {(5)}) ] spids: [-1 766] ) ] spids: [-1 782] ) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) (C {(log_action_msg)} {(DQ ("Will now restart"))}) ] op_id: Op_DPipe ) (C {(reboot)} {(-f)}) ] spids: [-1 730] ) ] spids: [-1 811] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:FSCKCODE) op:Equal rhs:{(0)} spids:[873])] spids: [873] ) (If arms: [ (if_arm cond: [(C {(Lit_Other "[")} {(-e)} {(/run/initramfs/fsck-root)} {(Lit_Other "]")})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootcheck) op: Equal rhs: {(no)} spids: [892] ) ] spids: [892] ) ] spids: [-1 889] ) ] spids: [-1 896] ) (If arms: [ (if_arm cond: [(C {(is_fastboot_active)})] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$rootcheck"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) (C {(log_warning_msg)} {(DQ ("Fast boot enabled, so skipping root file system check."))} ) ] op_id: Op_DAmp ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootcheck) op: Equal rhs: {(no)} spids: [929] ) ] spids: [929] ) ] spids: [-1 905] ) ] spids: [-1 933] ) (If arms: [ (if_arm cond: [ (SimpleCommand words: [{(which)} {(findmnt)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [943] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [946] ) ] ) ] action: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(findmnt)} {(-f)} {(-n)} {(-o)} {(FSTYPE)} {(/)}) ] ) left_token: spids: [958 970] ) ) } {(Lit_Other "=")} {(DQ (btrfs))} {(Lit_Other "]")} ) ] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$rootcheck"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) (C {(log_warning_msg)} {(DQ ("btrfs root detected, so skipping root file system check."))} ) ] op_id: Op_DAmp ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootcheck) op: Equal rhs: {(no)} spids: [1006] ) ] spids: [1006] ) ] spids: [-1 982] ) ] spids: [-1 1010] ) ] spids: [-1 950] ) ] spids: [-1 1013] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$rootcheck"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (If arms: [ (if_arm cond: [ (AndOr children: [ (Pipeline children: [ (C {(mount)} {(-n)} {(-o)} {(remount) (Lit_Comma ",") (ro)} {($ VSub_Name "$rootdev")} {(/)} ) ] negated: True ) (AndOr children: [ (Pipeline children: [ (SimpleCommand words: [ {(mount)} {(-n)} {(-o)} {(remount) (Lit_Comma ",") (ro)} {(-t)} {(dummytype)} {($ VSub_Name "$rootdev")} {(/)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1131] ) ] ) ] negated: True ) (Pipeline children: [ (SimpleCommand words: [ {(mount)} {(-n)} {(-o)} {(remount) (Lit_Comma ",") (ro)} {(/)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1152] ) ] ) ] negated: True ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] action: [ (C {(log_failure_msg)} { (DQ ( "Cannot check root file system because it is not mounted read-only." ) ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootcheck) op: Equal rhs: {(no)} spids: [1166] ) ] spids: [1166] ) ] spids: [-1 1156] ) ] spids: [-1 1170] ) ] spids: [-1 1032] ) ] spids: [-1 1173] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$rootcheck"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(Lit_Other "[")} {(-f)} {(/forcefsck)} {(Lit_Other "]")}) (C {(grep)} {(-q)} {(-s)} {(-w)} {(-i)} {(DQ (forcefsck))} {(/proc/cmdline)}) ] op_id: Op_DPipe ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:force) op: Equal rhs: {(DQ (-f))} spids: [1239] ) ] spids: [1239] ) ] spids: [-1 1236] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:force) op: Equal rhs: {(DQ )} spids: [1248] ) ] spids: [1248] ) ] spids: [1245 1253] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$FSCKFIX"))} {(Lit_Other "=")} {(yes)} {(Lit_Other "]")} ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:fix) op: Equal rhs: {(DQ (-y))} spids: [1275] ) ] spids: [1275] ) ] spids: [-1 1272] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:fix) op: Equal rhs: {(DQ (-a))} spids: [1284] ) ] spids: [1284] ) ] spids: [1281 1290] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:spinner) op: Equal rhs: {(DQ (-C))} spids: [1294] ) ] spids: [1294] ) (Case to_match: {(DQ ($ VSub_Name "$TERM"))} arms: [ (case_arm pat_list: [{(dumb)} {(network)} {(unknown)} {(DQ )}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:spinner) op: Equal rhs: {(DQ )} spids: [1320] ) ] spids: [1320] ) ] spids: [1309 1317 1324 -1] ) ] spids: [1300 1306 1327] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ (${ VSub_Name KERNEL) (":") (${ VSub_Name MACHINE))} {(Lit_Other "=")} {(Linux) (Lit_Other ":") (s390x)} {(Lit_Other "]")} ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:spinner) op: Equal rhs: {(DQ )} spids: [1360] ) ] spids: [1360] ) ] spids: [-1 1357] ) ] spids: [-1 1365] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) ] action: [ (C {(log_action_begin_msg)} {(DQ ("Checking root file system"))}) (C {(logsave)} {(-s)} {($ VSub_Name "$FSCK_LOGFILE")} {(fsck)} {($ VSub_Name "$spinner")} {($ VSub_Name "$force")} {($ VSub_Name "$fix")} {(-t)} {($ VSub_Name "$roottype")} {($ VSub_Name "$rootdev")} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FSCKCODE) op: Equal rhs: {($ VSub_QMark "$?")} spids: [1416] ) ] spids: [1416] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$FSCKCODE"))} {(Lit_Other "=")} {(0)} {(Lit_Other "]")} ) ] action: [(C {(log_action_end_msg)} {(0)})] spids: [-1 1435] ) ] else_action: [ (C {(log_action_end_msg)} {(1)} {(DQ ("code ") ($ VSub_Name "$FSCKCODE"))} ) ] spids: [1443 1456] ) ] spids: [-1 1385] ) ] else_action: [ (C {(log_daemon_msg)} {(DQ ("Will now check root file system"))}) (C {(logsave)} {(-s)} {($ VSub_Name "$FSCK_LOGFILE")} {(fsck)} {($ VSub_Name "$spinner")} {($ VSub_Name "$force")} {($ VSub_Name "$fix")} {(-V)} {(-t)} {($ VSub_Name "$roottype")} {($ VSub_Name "$rootdev")} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FSCKCODE) op: Equal rhs: {($ VSub_QMark "$?")} spids: [1492] ) ] spids: [1492] ) (C {(log_end_msg)} {($ VSub_Name "$FSCKCODE")}) ] spids: [1459 1501] ) ] spids: [-1 1204] ) ] spids: [-1 1504] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$FSCKCODE"))} {(-eq)} {(32)} {(Lit_Other "]")}) ] action: [(C {(log_warning_msg)} {(DQ ("File system check was interrupted by user"))})] spids: [-1 1555] ) (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$FSCKCODE"))} {(-gt)} {(3)} {(Lit_Other "]")}) ] action: [ (C {(log_failure_msg)} { (DQ ( "An automatic file system check (fsck) of the root filesystem failed. \n" ) ("A manual fsck must be performed, then the system restarted. \n") ("The fsck should be performed in maintenance mode with the \n") ("root filesystem mounted in read-only mode.") ) } ) (C {(log_warning_msg)} { (DQ ("The root filesystem is currently mounted in read-only mode. \n") ("A maintenance shell will now be started. \n") ("After performing system maintenance, press CONTROL-D \n") ("to terminate the maintenance shell and restart the system.") ) } ) (If arms: [ (if_arm cond: [ (Pipeline children: [(C {(sulogin)} {($ VSub_Name "$CONSOLE")})] negated: True ) ] action: [ (C {(log_failure_msg)} { (DQ ("Attempt to start maintenance shell failed. \n") ("Will restart in 5 seconds.") ) } ) (C {(sleep)} {(5)}) ] spids: [-1 1624] ) ] spids: [-1 1640] ) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) (C {(log_action_msg)} {(DQ ("Will now restart"))}) ] op_id: Op_DPipe ) (C {(reboot)} {(-f)}) ] spids: [1565 1580] ) (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$FSCKCODE"))} {(-gt)} {(1)} {(Lit_Other "]")}) ] action: [ (C {(log_failure_msg)} { (DQ ("The file system check corrected errors on the root partition \n") ("but requested that the system be restarted.") ) } ) (C {(log_warning_msg)} {(DQ ("The system will be restarted in 5 seconds."))}) (C {(sleep)} {(5)}) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(Lit_Other "=")} {(no)} {(Lit_Other "]")} ) (C {(log_action_msg)} {(DQ ("Will now restart"))}) ] op_id: Op_DPipe ) (C {(reboot)} {(-f)}) ] spids: [1669 1684] ) ] spids: [-1 1733] ) (If arms: [ (if_arm cond: [ (Pipeline children: [ (SimpleCommand words: [ {(mount)} {(-n)} {(-o)} {(remount) (Lit_Comma ",") ($ VSub_Name "$rootopts") (Lit_Comma ",") ($ VSub_Name "$rootmode") } {($ VSub_Name "$fstabroot")} {(/)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1781] ) ] ) ] negated: True ) ] action: [ (C {(mount)} {(-n)} {(-o)} {(remount) (Lit_Comma ",") ($ VSub_Name "$rootopts") (Lit_Comma ",") ($ VSub_Name "$rootmode") } {(/)} ) ] spids: [-1 1785] ) ] spids: [-1 1803] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$rootmode"))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (ro))} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(mtab_migrate)})] spids: [-1 1837] ) ] spids: [-1 1843] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(selinux_enabled)}) (AndOr children: [ (C {(Lit_Other "[")} {(-x)} {(/sbin/restorecon)} {(Lit_Other "]")}) (C {(Lit_Other "[")} {(-r)} {(/etc/mtab)} {(Lit_Other "]")}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] action: [(C {(restorecon)} {(/etc/mtab)})] spids: [-1 1872] ) ] spids: [-1 1880] ) (C {(rm)} {(-f)} {(/run/rootdev)}) (C {(/etc/init.d/mountkernfs.sh)} {(reload)}) (C {(/etc/init.d/mountdevsubfs.sh)} {(reload)}) ] spids: [98] ) spids: [93 97] ) (FuncDef name: do_status body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:rootrw) op:Equal rhs:{(false)} spids:[1945])] spids: [1945] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:swapon) op:Equal rhs:{(false)} spids:[1949])] spids: [1949] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(/etc/mtab)} {(Lit_Other "]")}) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (C {(grep)} {(DQ (" / "))} {(/etc/mtab)}) (C {(grep)} {(-q)} {(rw)}) ] negated: False ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:rootrw) op: Equal rhs: {(true)} spids: [1990] ) ] spids: [1990] ) ] spids: [-1 1987] ) ] spids: [-1 1994] ) ] spids: [-1 1965] ) ] spids: [-1 1997] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(/proc/swaps)} {(Lit_Other "]")}) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(cat)} {(/proc/swaps)}) (C {(grep)} {(-v)} {(Lit_Other "^") (Filename)}) ] negated: False ) ] ) left_token: spids: [2020 2032] ) ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:swapon) op: Equal rhs: {(true)} spids: [2042] ) ] spids: [2042] ) ] spids: [-1 2039] ) ] spids: [-1 2046] ) ] spids: [-1 2012] ) ] spids: [-1 2049] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} {(true)} {(Lit_Other "=")} {(DQ ($ VSub_Name "$rootrw"))} {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(true)} {(Lit_Other "=")} {(DQ ($ VSub_Name "$swapon"))} {(Lit_Other "]")} ) ] op_id: Op_DPipe ) terminator: ) ] action: [(ControlFlow token: arg_word:{(0)})] spids: [-1 2082] ) ] else_action: [(ControlFlow token: arg_word:{(4)})] spids: [2090 2098] ) ] spids: [1934] ) spids: [1929 1933] ) (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(start)} {(DQ )}] action: [(C {(do_start)})] spids: [2112 2116 2122 -1] ) (case_arm pat_list: [{(restart)} {(reload)} {(force-reload)}] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: argument '") ($ VSub_Number "$1") ("' not supported"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[2141])] ) (C {(exit)} {(3)}) ] spids: [2125 2130 2150 -1] ) (case_arm pat_list:[{(stop)}] spids:[215321542161-1]) (case_arm pat_list: [{(status)}] action: [(C {(do_status)}) (C {(exit)} {($ VSub_QMark "$?")})] spids: [2164 2165 2176 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Usage: checkroot.sh [start|stop]"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[2189])] ) (C {(exit)} {(3)}) ] spids: [2179 2180 2198 -1] ) ] spids: [2103 2109 2200] ) (C {(Lit_Other ":")}) ] )