Bug 195

Summary: init does not correctly detect console as a serial port on some platform
Product: Busybox Reporter: Fred Germain <frederic.germain>
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: busybox-cvs
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: PC ubuntu 8.4 Target: sh4-linux
Build:
Attachments: Test for Linux console in a more generic and sensible way

Description Fred Germain 2009-03-18 17:58:46 UTC
in console_init (init/init.c), the ioctl TIOCGSERIAL might always fails on some platform.
This is because init.c has its own definition of struct serial_struct, and some architecture (sh to give one) defines TIOCGSERIAL this way :
#define TIOCGSERIAL     _IOR('T', 30, struct serial_struct)
So TIOCGSERIAL depends of sizeof(struct serial_struct), which is different in the kernel and init.c.

One solution would be to include the header #include <linux/serial.h> in init.c, but i understand that this would create a build dependency of busybox to the kernel headers.
Another one would be to use another serial port specific ioctl. Maybe TIOCSERGWILD or TIOCSERCONFIG would do the trick ?
And one would be to change the kernel headers, but that's seems quite extreme :-)




And one little remark, it is not possible to give a console= environment variable from the kernel cmdline to busybox, as it is already a standard option for the kernel. So it is only possible to use it from an initramfs.
Would it be possible to change the console= option in console_init() by a init_console= ?...
Comment 1 Denys Vlasenko 2009-03-19 02:33:50 UTC
Created attachment 161 [details]
Test for Linux console in a more generic and sensible way

Please try attached patch.
Comment 2 Denys Vlasenko 2009-03-19 02:36:16 UTC
Applied as rev 25747, please confirm it works for you.
Comment 3 Fred Germain 2009-03-19 10:50:57 UTC
This patch works fine in my environment.
Thank you !