summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Cernekee <cernekee@gmail.com>2011-07-13 16:29:55 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2011-08-16 21:29:54 (GMT)
commit816cd16a4ce81ec8d2989a356256f813fc91475d (patch)
tree4be90720f30ae019bd104908ce2a9a995525aed6
parent9176f6c52cb60f9de72a1c8e6b4dafc7c29ec1bf (diff)
downloadbusybox-816cd16a4ce81ec8d2989a356256f813fc91475d.tar.gz
busybox-816cd16a4ce81ec8d2989a356256f813fc91475d.tar.bz2
cttyhack: remove the trailing newline when reading console name from sysfs
Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/cttyhack.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/shell/cttyhack.c b/shell/cttyhack.c
index 4261289..37ea137 100644
--- a/shell/cttyhack.c
+++ b/shell/cttyhack.c
@@ -122,10 +122,12 @@ int cttyhack_main(int argc UNUSED_PARAM, char **argv)
do {
#ifdef __linux__
int s = open_read_close("/sys/class/tty/console/active",
- console + 5, sizeof(console) - 5 - 1);
+ console + 5, sizeof(console) - 5);
if (s > 0) {
- /* found active console via sysfs (Linux 2.6.38+) */
- console[5 + s] = '\0';
+ /* found active console via sysfs (Linux 2.6.38+)
+ * sysfs string looks like "ttyS0\n" so zap the newline:
+ */
+ console[4 + s] = '\0';
break;
}