From edd7d1180a77b54367864607e537b47b5c5a8da3 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 11 Jan 2010 18:35:03 +0000 Subject: [PATCH 1/2] Recalc columns after module loading Due to KMS, the bootup tends to get out of whack sometimes. To remedy this, we'll try to recalculate the column width after each operation that has potential to change the display mode Signed-off-by: Aaron Griffin --- functions | 40 ++++++++++++++++++++++------------------ rc.multi | 8 ++++++-- rc.sysinit | 4 ++++ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/functions b/functions index 090f099..f8525d7 100644 --- a/functions +++ b/functions @@ -5,25 +5,29 @@ # width: STAT_COL=80 -if [[ ! -t 1 ]]; then - USECOLOR="" -elif [[ -t 0 ]]; then - # stty will fail when stdin isn't a terminal - STAT_COL="$(/bin/stty size)" - # stty gives "rows cols"; strip the rows number, we just want columns - STAT_COL="${STAT_COL##* }" -elif /bin/tput cols &>/dev/null; then - # is /usr/share/terminfo already mounted, and TERM recognized? - STAT_COL=$(/bin/tput cols) -fi -if ((STAT_COL==0)); then - # if output was 0 (serial console), set default width to 80 - STAT_COL=80 - USECOLOR="" -fi +calc_columns() { + if [[ ! -t 1 ]]; then + USECOLOR="" + elif [[ -t 0 ]]; then + # stty will fail when stdin isn't a terminal + STAT_COL="$(/bin/stty size)" + # stty gives "rows cols"; strip the rows number, we just want columns + STAT_COL="${STAT_COL##* }" + elif /bin/tput cols &>/dev/null; then + # is /usr/share/terminfo already mounted, and TERM recognized? + STAT_COL=$(/bin/tput cols) + fi + if ((STAT_COL==0)); then + # if output was 0 (serial console), set default width to 80 + STAT_COL=80 + USECOLOR="" + fi + + # we use 13 characters for our own stuff + STAT_COL=$(($STAT_COL - 13)) +} -# we use 13 characters for our own stuff -STAT_COL=$(($STAT_COL - 13)) +calc_columns # disable colors on broken terminals TERM_COLORS="$(/bin/tput colors 2>/dev/null)" diff --git a/rc.multi b/rc.multi index 693223d..bd98fad 100755 --- a/rc.multi +++ b/rc.multi @@ -15,8 +15,12 @@ run_hook multi_start for daemon in "${DAEMONS[@]}"; do case ${daemon:0:1} in '!') continue;; # Skip this daemon. - '@') start_daemon_bkgd "${daemon#@}";; - *) start_daemon "$daemon";; + '@') + start_daemon_bkgd "${daemon#@}" + calc_columns;; + *) + start_daemon "$daemon" + calc_columns;; esac done diff --git a/rc.sysinit b/rc.sysinit index 9d7c250..b0418dd 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -76,6 +76,7 @@ echo > /proc/sys/kernel/hotplug stat_busy "Starting UDev Daemon" /sbin/udevd --daemon +calc_columns stat_done run_hook sysinit_udevlaunched @@ -86,6 +87,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then /sbin/udevadm control --property=STARTUP=1 /sbin/udevadm trigger --action=add --type=devices /sbin/udevadm trigger --action=add --type=subsystems + calc_columns stat_done fi @@ -94,6 +96,7 @@ mods=${MODULES[@]/!*/} if [[ $load_modules != off && -f /proc/modules && $mods ]]; then stat_busy "Loading Modules" /sbin/modprobe --all $mods + calc_columns stat_done fi unset mods @@ -103,6 +106,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then stat_busy "Waiting for UDev uevents to be processed" /sbin/udevadm settle --quiet --timeout=${UDEV_TIMEOUT:-30} /sbin/udevadm control --property=STARTUP= + calc_columns stat_done fi -- 1.7.4.1