进入busybox源代码目录,选择telnet,telnetd.后
确保在ramdisk的sbin目录下存在inetd和in.telnetd或telned。
在ramdisk中的mnt/etc目录中,确保存在文件fstab,service,inetd.conf,passwd文件
确保fstab文件中存在none /dev/pts devpts mode=0622 0 0这一行
确保services文件中存在
telnet 23/tcp 这一行
确保inetd.conf中存在
telnet stream tcp nowait root /sbin/in.telnetd in.telnetd
确保passwd文件中存在root::0:0:root:/:/bin/sh,表示没有密码的root帐号
在kernal的代码中,通过makemenuconfig,
在Character devices中选中Unix98 PTY support
在File systems中选中/dev/pts file system for Unix98 PTYs
退出后make zImage即可
在ramdisk的启动文件mnt/etc/init.d/rcS中,在mount –a的后面下一行加入inetd,使系统启动的时候就加载telnetd服
#
telnetstream tcp nowait root /usr/sbin/telnetd
dev/pts file system for Unix98 PTYs
Unix98 PTY support
(256) Maximum number of Unix98 PTYs in use (0-2048)
查看内核的Kconfig和Makefile文件,发现只要CONFIG_UNIX98_PTYS=y就会编译支持devpts文件系统和unix98的功能。而选择了嵌入式CPU内核会默认CONFIG_UNIX98_PTYS=y。所以我的内核已经支持telnet。
fstab文件中也加载了devpts文件系统:
devpts /dev/pts devpts defaults 00
inittab文件中也指明了telnet的动作:
tty0::askfirst:-/bin/sh
为什么还不行呢?
A pseudo terminal (PTY) is a software device consisting of two
halves: a master and a slave. The slave device behaves identical to
a physical terminal; the master device is used by a process to
read data from and write data to the slave, thereby emulating a
terminal. Typical programs for the master side are telnet servers
and xterms.
masters and /dev/ttyxx for slaves of pseudo terminals. This scheme
has a number of problems. The GNU C library glibc 2.1 and later,
however, supports the Unix98 naming standard: in order to acquire a
pseudo terminal, a process opens /dev/ptmx; the number of the pseudo
terminal is then made available to the process and the pseudo
terminal slave can be accessed as /dev/pts/. What was
traditionally /dev/ttyp2 will then be /dev/pts/2, for example.
mknod -m 666 ptmx c 5 2
再试试,OK可以telnet开发板了!
mount -t ramfs ramfs /var
mount -t sysfs sysfs /sys
mount -t devpts devpts /dev/pts
sync
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
/bin/sh
(256) Maximum number of legacy PTY in use
[*] Support standalone telnetd (not inetd only)td only)
BusyBox v1.6.0 (2007-08-16 16:03:29 CST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.