tty_ioctl.c
/* w tym pliku zdefiniowana jest funkcja tty_ioctl dla dyscypliny
* linii N_TTY - funkcja n_tty_ioctl */
/*
* linux/drivers/char/tty_ioctl.c
*
* Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
*
* Modified by Fred N. van Kempen, 01/29/93, to add line disciplines
* which can be dynamically activated and de-activated by the line
* discipline handling modules (like SLIP).
*/
#include <linux/types.h>
#include <linux/termios.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/tty.h>
#include <linux/fcntl.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <asm/io.h>
#include <asm/bitops.h>
#include <asm/segment.h>
#include <asm/system.h>
#undef TTY_DEBUG_WAIT_UNTIL_SENT
#undef DEBUG
#ifdef DEBUG
# define PRINTK(x) printk (x)
#else
# define PRINTK(x) /**/
#endif
/*
* Internal flag options for termios setting behavior
*/
/* wewnetrzne flagi ustawienia struktury termios */
#define TERMIOS_FLUSH 1
#define TERMIOS_WAIT 2
#define TERMIOS_TERMIO 4
void tty_wait_until_sent(struct tty_struct * tty, int timeout)
{
struct wait_queue wait = { current, NULL };
#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
printk("%s wait until sent...\n", tty_name(tty));
#endif
/* jeeli nie ma nic w buforze sterownika, to nic nie robi */
if (!tty->driver.chars_in_buffer ||
!tty->driver.chars_in_buffer(tty))
return;
/* proces sam wstawia si do kolejki czekajcych na pisanie do
* terminala */
add_wait_queue(&tty->write_wait, &wait);
current->counter = 0; /* make us low-priority */
if (timeout)
current->timeout = timeout + jiffies;
else
current->timeout = (unsigned) -1;
do {
#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
printk("waiting %s...(%d)\n", tty_name(tty), tty->driver.chars_in_buffer(tty));
#endif
current->state = TASK_INTERRUPTIBLE;
if (current->signal & ~current->blocked)
break;
if (!tty->driver.chars_in_buffer(tty))
break;
schedule();
/* odczekuje odpowiedni ilo czasu (timeout) */
} while (current->timeout);
/* zmiana stanu na TASK_RUNNING i usunicie si z kolejki */
current->state = TASK_RUNNING;
remove_wait_queue(&tty->write_wait, &wait);
}
/* ustawienie flag i znakw sterujcych w termios tak jak byy ustawione
* w old pod warunkiem, e termios_locked gwarantuje takie ustawienie */
static void unset_locked_termios(struct termios *termios,
struct termios *old,
struct termios *locked)
{
int i;
#define NOSET_MASK(x,y,z) (x = ((x) & ~(z)) | ((y) & (z)))
if (!locked) {
printk("Warning?!? termios_locked is NULL.\n");
return;
}
/* zmiana flag */
NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag);
NOSET_MASK(termios->c_oflag, old->c_oflag, locked->c_oflag);
NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag);
NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag);
termios->c_line = locked->c_line ? old->c_line : termios->c_line;
/* zmiana znakw sterujcych */
for (i=0; i < NCCS; i++)
termios->c_cc[i] = locked->c_cc[i] ?
old->c_cc[i] : termios->c_cc[i];
}
/* zamienie struktur termios w tty_struct */
static void change_termios(struct tty_struct * tty, struct termios * new_termios)
{
int canon_change;
struct termios old_termios = *tty->termios;
/* wyczenie przerwa */
cli();
*tty->termios =N_Gs>р?zB'9c؟U?K;.m=Fz4{1^P!no($}&?l~N6~LXy+Qpб}t";EHy;68}݅XF68/rAz{fT PAO/ɹ
8 2!b@8eo^Y
8"hcMԹA螮sQ 8@1i31T
fFdda*&<4O`?OI<ͪ
Oy∀rgSi5NgO?W'Ԝ<}]M0$h:Rg4aS/ s(7kRY
Ę(mT[E/֝tY#rk5o7Єn颕0m i-\l`{=$.nvq(X}G˨SP9hCDх
Dqލ Ec.`\3Ï6!뎠OZ!@?@NdHdć81pD61s6MtMn[&Wyr|44Jz]D2SƣܣB`K(Ēg4NC\%(t` 72!5;
a`$NPcDy(f IARӲ=d%~HcbGCAwk,0UJ sLt<|O<%=Em&lSB/nAceas
4&3PAec+1!'p380ށ|qɲ|KA.XY`;G(bϠwxv$Gz!