[Toybox] [New toy] rudimentary getty
ibid.ag at gmail.com
ibid.ag at gmail.com
Wed Dec 18 23:19:44 PST 2013
Here's a basic getty.
It just reopens the current tty in such a way as to allow blocking code
to work, then calls the login program of your choice (-l).
/etc/issue is ignored, so -i is a nop.
It does NOT modify the environment (including setting TERM), support
baud rate setting or autodetection, do anything with modems, prompt for
any user input, or open new ttys.
Supporting
getty ttyN $TERM
should be something like this...
char * prepend(char *arg, char *pfix)
{
if (!arg) return NULL;
int alen = strlen(arg), plen = strlen(pfix);
char * ret = xzalloc(alen + plen + 1);
strcpy(ret, pfix);
strcpy(ret+plen, arg);
return ret;
}
char *tty = prepend(toys.optargs[0], "/dev/")
if (!tty) tty = ttyname(0);
if (toys.optc > 1) {
char *termname = prepend(toys.optargs[1], "TERM=");
if (termname) putenv(termname);
}
--
With this, I can boot to a login prompt using only a shell and a toybox
binary (with several pending applets enabled, and a hacked version of
one of the many submissions for mount).
I also have a small applet (resolve_modalias) that is mainly useful for
testing, which I've sent a couple times to illustrate issues;
maybe sometime I should see about putting the core code into a library
function so modprobe and modinfo can share it....
Thanks,
Isaac Dunham
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getty.c
Type: text/x-csrc
Size: 820 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20131218/5f4beadf/attachment.c>
More information about the Toybox
mailing list