Subject: Re: Attack of the clones: turning sl*, strip*, ppp* into cloners.
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Andrew Brown <email@example.com>
Date: 02/25/2002 14:08:01
>> 2) the line discipline open routine needs to know the requested unit
>> 2) two options:
>> a) we change the signature of (struct linesw)'s l_open routine to
>> take a third "int" parameter.
>> b) we add an "int t_lunit;" field to "struct tty", defaulting to
>> "-1"; TIOCSLINED fills it in before calling the line discipline's
>> l_open routine if one was specified.
>For what it's worth, speaking with my interface design aesthetics hat
>on, I definitely prefer b. That extra int is just too special-case,
>used only for the one instance of TIOCSETD to PPP.
not just ppp. slip and strip also. and perhaps plip, if that ever
gets away from the pc532.
what about changing the l_open to take a char* that is the line
discipline as passed in via the ioctl? that would mean that:
(1) ttyldisc_lookup() would have to be taught only to compare up to a
certain point, instead of using just strcmp() to see if a particular
line disciplince is being selected. perhaps
for (i = 0; i < nlinesw; i++)
if (linesw[i] && (strncmp(name, linesw[i]->l_name,
strlen(linesw[i]->l_name)) == 0))
would work there.
(2) all the l_open functions could use the string, not just slip, ppp,
and strip. they could also parse it in their own way. for example:
tbopen() currently does this:
tbp->tbflags = TBTIGER|TBPOINT; /* default */
and selecting a line discipline of "tablet0x0008" (or just "tablet8")
tbp->tbflags = TBRUN|TBDIGIHIRES;
instead. the char* could also be NULL meaning (a) no special offers,
please, and (b) changing existing code would be easier.
>I'm not sure I really like (b) itself all that much, though. I'd
>rather add something like "void *t_ldcookie" and "size_t t_ldcooksz",
>an opaque cookie block with meaning only to the line discipline and the
>code setting the line discipline.
that would require work to setup said cookie, and that seems like even
more work than required to just add the aforementioned "int"
parameter. it might make more sense to copy the line discipline
structure from the array ttyldisc_lookup() currently uses to scan and
do ref counting on it, so the requested unit number could be stuffed
in there. that would make more sense, imho, than putting a sometimes
unuseful unit number in the struct tty.
|-----< "CODE WARRIOR" >-----|
firstname.lastname@example.org * "ah! i see you have the internet
email@example.com (Andrew Brown) that goes *ping*!"
firstname.lastname@example.org * "information is power -- share the wealth."