亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tty_io.c

?? <Linux1.0核心游記>電子書+書后源碼+Linux1.0源碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* *  linux/kernel/tty_io.c * *  Copyright (C) 1991, 1992  Linus Torvalds *//* * 'tty_io.c' gives an orthogonal feeling to tty's, be they consoles * or rs-channels. It also implements echoing, cooked mode etc. * * Kill-line thanks to John T Kohl, who also corrected VMIN = VTIME = 0. * * Modified by Theodore Ts'o, 9/14/92, to dynamically allocate the * tty_struct and tty_queue structures.  Previously there was a array * of 256 tty_struct's which was statically allocated, and the * tty_queue structures were allocated at boot time.  Both are now * dynamically allocated only when the tty is open. * * Also restructured routines so that there is more of a separation * between the high-level tty routines (tty_io.c and tty_ioctl.c) and * the low-level tty routines (serial.c, pty.c, console.c).  This * makes for cleaner and more compact code.  -TYT, 9/17/92  * * 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). * * NOTE: pay no attention to the line discpline code (yet); its * interface is still subject to change in this version... * -- TYT, 1/31/92 * * Added functionality to the OPOST tty handling.  No delays, but all * other bits should be there. *	-- Nick Holloway <alfie@dcs.warwick.ac.uk>, 27th May 1993. * * Rewrote canonical mode and added more termios flags. * 	-- julian@uhunix.uhcc.hawaii.edu (J. Cowley), 13Jan94 */#include <linux/types.h>#include <linux/major.h>#include <linux/errno.h>#include <linux/signal.h>#include <linux/fcntl.h>#include <linux/sched.h>#include <linux/tty.h>#include <linux/timer.h>#include <linux/ctype.h>#include <linux/kd.h>#include <linux/mm.h>#include <linux/string.h>#include <linux/malloc.h>#include <asm/segment.h>#include <asm/system.h>#include <asm/bitops.h>#include "kbd_kern.h"#include "vt_kern.h"#define CONSOLE_DEV MKDEV(TTY_MAJOR,0)#define MAX_TTYS 256struct tty_struct *tty_table[MAX_TTYS];struct termios *tty_termios[MAX_TTYS];	/* We need to keep the termios state */				  	/* around, even when a tty is closed */struct termios *termios_locked[MAX_TTYS]; /* Bitfield of locked termios flags*/struct tty_ldisc ldiscs[NR_LDISCS];	/* line disc dispatch table	*/int tty_check_write[MAX_TTYS/32];	/* bitfield for the bh handler *//* * fg_console is the current virtual console, * redirect is the pseudo-tty that console output * is redirected to if asked by TIOCCONS. */int fg_console = 0;struct tty_struct * redirect = NULL;struct wait_queue * keypress_wait = NULL;static void initialize_tty_struct(int line, struct tty_struct *tty);static void initialize_termios(int line, struct termios *tp);static int tty_read(struct inode *, struct file *, char *, int);static int tty_write(struct inode *, struct file *, char *, int);static int tty_select(struct inode *, struct file *, int, select_table *);static int tty_open(struct inode *, struct file *);static void tty_release(struct inode *, struct file *);int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc){	if (disc < N_TTY || disc >= NR_LDISCS)		return -EINVAL;		if (new_ldisc) {		ldiscs[disc] = *new_ldisc;		ldiscs[disc].flags |= LDISC_FLAG_DEFINED;	} else		memset(&ldiscs[disc], 0, sizeof(struct tty_ldisc));		return 0;}void put_tty_queue(unsigned char c, struct tty_queue * queue){	int head;	unsigned long flags;	save_flags(flags);	cli();	head = (queue->head + 1) & (TTY_BUF_SIZE-1);	if (head != queue->tail) {		queue->buf[queue->head] = c;		queue->head = head;	}	restore_flags(flags);}int get_tty_queue(struct tty_queue * queue){	int result = -1;	unsigned long flags;	save_flags(flags);	cli();	if (queue->tail != queue->head) {		result = queue->buf[queue->tail];		INC(queue->tail);	}	restore_flags(flags);	return result;}/* * This routine copies out a maximum of buflen characters from the * read_q; it is a convenience for line disciplines so they can grab a * large block of data without calling get_tty_char directly.  It * returns the number of characters actually read. Return terminates * if an error character is read from the queue and the return value * is negated. */int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, int buflen){	int	result = 0;	unsigned char	*p = bufp;	unsigned long flags;	int head, tail;	int ok = 1;	save_flags(flags);	cli();	tail = tty->read_q.tail;	head = tty->read_q.head;	while ((result < buflen) && (tail!=head) && ok) {		ok = !clear_bit (tail, &tty->readq_flags);		*p++ =  tty->read_q.buf[tail++];		tail &= TTY_BUF_SIZE-1;		result++;	}	tty->read_q.tail = tail;	restore_flags(flags);	return (ok) ? result : -result;}void tty_write_flush(struct tty_struct * tty){	if (!tty->write || EMPTY(&tty->write_q))		return;	if (set_bit(TTY_WRITE_BUSY,&tty->flags))		return;	tty->write(tty);	if (!clear_bit(TTY_WRITE_BUSY,&tty->flags))		printk("tty_write_flush: bit already cleared\n");}void tty_read_flush(struct tty_struct * tty){	if (!tty || EMPTY(&tty->read_q))		return;	if (set_bit(TTY_READ_BUSY, &tty->flags))		return;	ldiscs[tty->disc].handler(tty);	if (!clear_bit(TTY_READ_BUSY, &tty->flags))		printk("tty_read_flush: bit already cleared\n");}static int hung_up_tty_read(struct inode * inode, struct file * file, char * buf, int count){	return 0;}static int hung_up_tty_write(struct inode * inode, struct file * file, char * buf, int count){	return -EIO;}static int hung_up_tty_select(struct inode * inode, struct file * filp, int sel_type, select_table * wait){	return 1;}static int hung_up_tty_ioctl(struct inode * inode, struct file * file,			     unsigned int cmd, unsigned long arg){	return -EIO;}static int tty_lseek(struct inode * inode, struct file * file, off_t offset, int orig){	return -ESPIPE;}static struct file_operations tty_fops = {	tty_lseek,	tty_read,	tty_write,	NULL,		/* tty_readdir */	tty_select,	tty_ioctl,	NULL,		/* tty_mmap */	tty_open,	tty_release};static struct file_operations hung_up_tty_fops = {	tty_lseek,	hung_up_tty_read,	hung_up_tty_write,	NULL,		/* hung_up_tty_readdir */	hung_up_tty_select,	hung_up_tty_ioctl,	NULL,		/* hung_up_tty_mmap */	NULL,		/* hung_up_tty_open */	tty_release	/* hung_up_tty_release */};void do_tty_hangup(struct tty_struct * tty, struct file_operations *fops){	int i;	struct file * filp;	struct task_struct *p;	int dev;	if (!tty)		return;	dev = MKDEV(TTY_MAJOR,tty->line);	for (filp = first_file, i=0; i<nr_files; i++, filp = filp->f_next) {		if (!filp->f_count)			continue;		if (filp->f_rdev != dev)			continue;		if (filp->f_inode && filp->f_inode->i_rdev == CONSOLE_DEV)			continue;		if (filp->f_op != &tty_fops)			continue;		filp->f_op = fops;	}	flush_input(tty);	flush_output(tty);	wake_up_interruptible(&tty->secondary.proc_list);	if (tty->session > 0) {		kill_sl(tty->session,SIGHUP,1);		kill_sl(tty->session,SIGCONT,1);	}	tty->session = 0;	tty->pgrp = -1; 	for_each_task(p) {		if (p->tty == tty->line)			p->tty = -1;	}	if (tty->hangup)		(tty->hangup)(tty);}void tty_hangup(struct tty_struct * tty){#ifdef TTY_DEBUG_HANGUP	printk("tty%d hangup...\n", tty->line);#endif	do_tty_hangup(tty, &hung_up_tty_fops);}void tty_vhangup(struct tty_struct * tty){#ifdef TTY_DEBUG_HANGUP	printk("tty%d vhangup...\n", tty->line);#endif	do_tty_hangup(tty, &hung_up_tty_fops);}int tty_hung_up_p(struct file * filp){	return (filp->f_op == &hung_up_tty_fops);}/* * This function is typically called only by the session leader, when * it wants to dissassociate itself from its controlling tty. * * It performs the following functions: * 	(1)  Sends a SIGHUP and SIGCONT to the foreground process group * 	(2)  Clears the tty from being controlling the session * 	(3)  Clears the controlling tty for all processes in the * 		session group. */void disassociate_ctty(int priv){	struct tty_struct *tty;	struct task_struct *p;	if (current->tty >= 0) {		tty = tty_table[current->tty];		if (tty) {			if (tty->pgrp > 0) {				kill_pg(tty->pgrp, SIGHUP, priv);				kill_pg(tty->pgrp, SIGCONT, priv);			}			tty->session = 0;			tty->pgrp = -1;		} else			printk("disassociate_ctty: ctty is NULL?!?");	}	for_each_task(p)	  	if (p->session == current->session)			p->tty = -1;}/* * Sometimes we want to wait until a particular VT has been activated. We * do it in a very simple manner. Everybody waits on a single queue and * get woken up at once. Those that are satisfied go on with their business, * while those not ready go back to sleep. Seems overkill to add a wait * to each vt just for this - usually this does nothing! */static struct wait_queue *vt_activate_queue = NULL;/* * Sleeps until a vt is activated, or the task is interrupted. Returns * 0 if activation, -1 if interrupted. */int vt_waitactive(void){	interruptible_sleep_on(&vt_activate_queue);	return (current->signal & ~current->blocked) ? -1 : 0;}#define vt_wake_waitactive() wake_up(&vt_activate_queue)extern int kill_proc(int pid, int sig, int priv);/* * Performs the back end of a vt switch */void complete_change_console(unsigned int new_console){	unsigned char old_vc_mode;	if (new_console == fg_console || new_console >= NR_CONSOLES)		return;	/*	 * If we're switching, we could be going from KD_GRAPHICS to	 * KD_TEXT mode or vice versa, which means we need to blank or	 * unblank the screen later.	 */	old_vc_mode = vt_cons[fg_console].vc_mode;	update_screen(new_console);	/*	 * If this new console is under process control, send it a signal	 * telling it that it has acquired. Also check if it has died and	 * clean up (similar to logic employed in change_console())	 */	if (vt_cons[new_console].vt_mode.mode == VT_PROCESS)	{		/*		 * Send the signal as privileged - kill_proc() will		 * tell us if the process has gone or something else		 * is awry		 */		if (kill_proc(vt_cons[new_console].vt_pid,			      vt_cons[new_console].vt_mode.acqsig,			      1) != 0)		{		/*		 * The controlling process has died, so we revert back to		 * normal operation. In this case, we'll also change back		 * to KD_TEXT mode. I'm not sure if this is strictly correct		 * but it saves the agony when the X server dies and the screen		 * remains blanked due to KD_GRAPHICS! It would be nice to do		 * this outside of VT_PROCESS but there is no single process		 * to account for and tracking tty count may be undesirable.		 */			vt_cons[new_console].vc_mode = KD_TEXT;			clr_vc_kbd_mode(kbd_table + new_console, VC_RAW);			clr_vc_kbd_mode(kbd_table + new_console, VC_MEDIUMRAW); 			vt_cons[new_console].vt_mode.mode = VT_AUTO; 			vt_cons[new_console].vt_mode.waitv = 0; 			vt_cons[new_console].vt_mode.relsig = 0;			vt_cons[new_console].vt_mode.acqsig = 0;			vt_cons[new_console].vt_mode.frsig = 0;			vt_cons[new_console].vt_pid = -1;			vt_cons[new_console].vt_newvt = -1;		}	}	/*	 * We do this here because the controlling process above may have	 * gone, and so there is now a new vc_mode	 */	if (old_vc_mode != vt_cons[new_console].vc_mode)	{		if (vt_cons[new_console].vc_mode == KD_TEXT)			unblank_screen();		else {			timer_active &= ~(1<<BLANK_TIMER);			blank_screen();		}	}	/*	 * Wake anyone waiting for their VT to activate	 */	vt_wake_waitactive();	return;}/* * Performs the front-end of a vt switch */void change_console(unsigned int new_console){	if (new_console == fg_console || new_console >= NR_CONSOLES)		return;	/*	 * If this vt is in process mode, then we need to handshake with	 * that process before switching. Essentially, we store where that	 * vt wants to switch to and wait for it to tell us when it's done	 * (via VT_RELDISP ioctl).	 *	 * We also check to see if the controlling process still exists.	 * If it doesn't, we reset this vt to auto mode and continue.	 * This is a cheap way to track process control. The worst thing	 * that can happen is: we send a signal to a process, it dies, and	 * the switch gets "lost" waiting for a response; hopefully, the	 * user will try again, we'll detect the process is gone (unless	 * the user waits just the right amount of time :-) and revert the	 * vt to auto control.	 */	if (vt_cons[fg_console].vt_mode.mode == VT_PROCESS)	{		/*		 * Send the signal as privileged - kill_proc() will		 * tell us if the process has gone or something else		 * is awry		 */		if (kill_proc(vt_cons[fg_console].vt_pid,			      vt_cons[fg_console].vt_mode.relsig,			      1) == 0)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
盗摄精品av一区二区三区| av电影天堂一区二区在线观看| 亚洲精品国产一区二区三区四区在线| 色婷婷av一区二区三区gif| 人人精品人人爱| 最新热久久免费视频| 欧美一区欧美二区| 北条麻妃国产九九精品视频| 日韩国产在线观看一区| 亚洲视频香蕉人妖| 久久综合九色综合97_久久久 | 日本不卡的三区四区五区| 日本一区二区成人| 日韩免费一区二区| 欧美日韩国产乱码电影| 91美女精品福利| 国产a视频精品免费观看| 美腿丝袜亚洲色图| 亚洲国产成人精品视频| 17c精品麻豆一区二区免费| 欧美mv日韩mv国产网站app| 欧美日韩久久一区二区| 色噜噜狠狠成人网p站| 丁香婷婷综合网| 久久99精品久久久久久久久久久久| 夜夜嗨av一区二区三区四季av| 中文字幕一区二区5566日韩| 26uuu亚洲| 日韩美女在线视频| 欧美一级免费大片| 欧美另类高清zo欧美| 欧美在线免费视屏| 91蜜桃网址入口| 9人人澡人人爽人人精品| 成人听书哪个软件好| 国产又粗又猛又爽又黄91精品| 麻豆精品一区二区三区| 日本美女视频一区二区| 视频一区在线播放| 性做久久久久久久久| 五月综合激情日本mⅴ| 亚洲成a人在线观看| 亚洲国产欧美日韩另类综合| 一区二区三区高清| 亚洲综合久久久久| 午夜久久久久久久久久一区二区| 亚洲国产精品欧美一二99| 亚洲综合色成人| 水野朝阳av一区二区三区| 青青草97国产精品免费观看无弹窗版| 亚洲午夜av在线| 亚洲午夜在线电影| 日本aⅴ精品一区二区三区| 蜜桃视频在线观看一区| 理论片日本一区| 国产麻豆欧美日韩一区| 国产盗摄精品一区二区三区在线 | 色欧美乱欧美15图片| 91久久国产最好的精华液| 日韩免费一区二区| 日本一区二区免费在线| 亚洲视频在线观看三级| 亚洲一区视频在线| 久久国产福利国产秒拍| 国产激情一区二区三区四区 | 国产精品视频在线看| 亚洲国产高清aⅴ视频| 亚洲美女视频一区| 性欧美疯狂xxxxbbbb| 久久99这里只有精品| a4yy欧美一区二区三区| 欧美日韩一区二区电影| 日韩免费高清电影| 亚洲欧洲国产日韩| 性欧美大战久久久久久久久| 国产原创一区二区三区| 91蜜桃在线观看| 日韩天堂在线观看| 亚洲少妇最新在线视频| 婷婷开心激情综合| 成人一级视频在线观看| 欧美日韩一区二区三区在线看| 日韩午夜中文字幕| 日韩久久一区二区| 久久国产精品露脸对白| 91在线高清观看| 日韩精品资源二区在线| 亚洲欧美日韩在线不卡| 精品一区二区三区日韩| 97精品电影院| 精品美女一区二区| 亚洲综合在线第一页| 国产精品一区三区| 欧美日韩成人在线| 国产精品久久久久久亚洲伦| 天天爽夜夜爽夜夜爽精品视频| 国产xxx精品视频大全| 欧美日韩久久久一区| 国产精品妹子av| 另类中文字幕网| 91国偷自产一区二区开放时间| 精品国产乱码久久久久久牛牛| 亚洲蜜臀av乱码久久精品蜜桃| 国产综合成人久久大片91| 欧美午夜精品理论片a级按摩| 国产欧美日韩不卡| 蜜桃久久久久久久| 色网综合在线观看| 国产精品色哟哟| 国内精品写真在线观看| 欧美乱妇15p| 亚洲综合另类小说| 99精品黄色片免费大全| 国产视频一区在线观看 | 97se狠狠狠综合亚洲狠狠| 精品国精品国产| 日韩不卡一区二区三区| 在线视频你懂得一区| 中文字幕av资源一区| 国产一区亚洲一区| 日韩三级在线免费观看| 日韩激情在线观看| 欧美三级资源在线| 一级女性全黄久久生活片免费| 欧美精品在线一区二区| 亚洲精品日产精品乱码不卡| 成人av午夜影院| 国产精品视频一二三| 国产精品一区二区黑丝| 精品国产精品一区二区夜夜嗨| 日韩av一级电影| 91精品久久久久久久99蜜桃| 婷婷国产v国产偷v亚洲高清| 欧美日韩一区二区不卡| 亚洲第一精品在线| 欧美久久免费观看| 日韩精品欧美成人高清一区二区| 欧美亚洲综合色| 亚洲国产欧美在线人成| 欧美日韩黄色一区二区| 天天av天天翘天天综合网| 欧美日韩中字一区| 天天综合网 天天综合色| 91精品一区二区三区久久久久久| 日韩电影网1区2区| 欧美成人午夜电影| 国产一区二区三区蝌蚪| 国产欧美日产一区| 99精品视频在线免费观看| 亚洲精品乱码久久久久久| 欧美性大战久久| 日本不卡123| 久久久夜色精品亚洲| av中文字幕不卡| 亚洲乱码中文字幕| 欧美午夜一区二区三区免费大片| 亚洲va国产天堂va久久en| 日韩一区二区在线观看| 极品少妇xxxx精品少妇| 国产精品激情偷乱一区二区∴| 91伊人久久大香线蕉| 亚洲大型综合色站| 日韩美女一区二区三区四区| 国产美女av一区二区三区| 亚洲欧洲另类国产综合| 欧美中文字幕一区二区三区| 日本视频在线一区| 国产视频一区在线播放| 日本韩国一区二区三区| 日本大胆欧美人术艺术动态| 国产日韩欧美精品在线| 在线亚洲免费视频| 美国精品在线观看| 国产精品久久久久一区| 欧美日韩午夜在线| 国产成人在线观看免费网站| 伊人婷婷欧美激情| 精品国产一区二区在线观看| 国产乱子轮精品视频| 亚洲精品成人精品456| 欧美tickle裸体挠脚心vk| 91色综合久久久久婷婷| 免费成人在线影院| 亚洲日本在线a| 欧美大片免费久久精品三p| 成人h动漫精品一区二| 日韩影院免费视频| 国产精品乱码一区二区三区软件| 欧美日韩亚洲国产综合| 懂色av一区二区三区免费观看| 五月婷婷久久丁香| 国产精品无人区| 91精品国产综合久久久久久| www.欧美日韩| 久久99蜜桃精品| 亚洲一区二区三区中文字幕| 国产色产综合色产在线视频 | 99久久精品情趣| 久久国产三级精品| 亚洲高清一区二区三区|