[arch-dev-public] [PATCH] Recalc columns after module loading

Aaron Griffin aaronmgriffin at gmail.com
Mon Jan 11 13:49:34 EST 2010


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 <aaronmgriffin at gmail.com>
---
 functions  |   45 ++++++++++++++++++++++++---------------------
 rc.sysinit |    4 ++++
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/functions b/functions
index 4dca333..3fc5744 100644
--- a/functions
+++ b/functions
@@ -5,30 +5,33 @@
 # width:
 
 STAT_COL=80
-if [ ! -t 1 ]; then
-  USECOLOR=""
+calc_columns() {
+  if [ ! -t 1 ]; then
+    USECOLOR=""
+  # stty will fail when stdin isn't a terminal
+  elif [ -t 0 ]; then
+    STAT_COL="$(/bin/stty size)"
+    # stty gives "rows cols"; strip the rows number, we just want columns
+    STAT_COL="${STAT_COL##* }"
 
-# stty will fail when stdin isn't a terminal
-elif [ -t 0 ]; then
-  STAT_COL="$(/bin/stty size)"
-  # stty gives "rows cols"; strip the rows number, we just want columns
-  STAT_COL="${STAT_COL##* }"
-
-else
-  # is /usr/share/terminfo already mounted, and TERM recognized?
-  /bin/tput cols &>/dev/null
-  if [ $? -eq 0 ]; then
-    STAT_COL=$(/bin/tput cols)
+  else
+    # is /usr/share/terminfo already mounted, and TERM recognized?
+    /bin/tput cols &>/dev/null
+    if [ $? -eq 0 ]; then
+      STAT_COL=$(/bin/tput cols)
+    fi
   fi
-fi
-if [ "0$STAT_COL" -eq 0 ]; then
-  # if output was 0 (serial console), set default width to 80
-  STAT_COL=80
-  USECOLOR=""
-fi
+  if [ "0$STAT_COL" -eq 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.sysinit b/rc.sysinit
index 4e079ad..cc35fe1 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -71,6 +71,7 @@ echo > /proc/sys/kernel/hotplug
 
 stat_busy "Starting UDev Daemon"
 /sbin/udevd --daemon
+calc_columns
 stat_done
 
 run_hook sysinit_udevlaunched
@@ -80,6 +81,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
   stat_busy "Triggering UDev uevents"
   /sbin/udevadm control --property=STARTUP=1
   /sbin/udevadm trigger
+  calc_columns
   stat_done
 fi
 
@@ -92,6 +94,7 @@ if ! [ "$load_modules" = "off" ]; then
 				/sbin/modprobe $mod
 			fi
 		done
+    calc_columns
 		stat_done
 	fi
 fi
@@ -101,6 +104,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
 	stat_busy "Waiting for UDev uevents to be processed"
 	/sbin/udevadm settle
 	/sbin/udevadm control --property=STARTUP=
+  calc_columns
 	stat_done
 fi
 
-- 
1.6.5.2



More information about the arch-dev-public mailing list