linuxÉ豸Çý¶¯Ö®¿ØÖÆÌ¨Çý¶¯
¡¡Ò»:ǰÑÔ
¡¡¡¡ÎÒÃÇÔÚ֮ǰ·ÖÎö¹ýinput×ÓϵͳºÍttyÉ豸Çý¶¯¼Ü¹¹.½ñÌìÐèÒª½«Á½Õß½áºÏÆðÀ´.¿´¿´linuxÖеĿØÖÆÌ¨ÊÇÔõôÑùʵÏÖµÄ.
¡¡¡¡¶þ:¿ØÖÆÌ¨Çý¶¯µÄ³õʼ»¯
¡¡¡¡Ö®Ç°ÔÚ·ÖÎöttyÇý¶¯¼Ü¹¹µÄʱºòÔø·ÖÎöµ½.Ö÷É豸Ϊ4,´ÎÉ豸Ϊ0µÄÉ豸½Úµã,¼´/dev/tty0Ϊµ±Ç°µÄ¿ØÖÆÖÕ¶Ë.
¡¡¡¡ÓÐtty_init()ÖÐ,ÓÐÒÔÏ´úÂë¶Î:
¡¡¡¡static int __init tty_init(void)
¡¡¡¡{
¡¡¡¡……
¡¡¡¡……
¡¡¡¡#ifdef CONFIG_VT
¡¡¡¡cdev_init(&vc0_cdev, &console_fops);
¡¡¡¡if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
¡¡¡¡register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
¡¡¡¡panic("Couldn't register /dev/tty0 driver\n");
¡¡¡¡device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
¡¡¡¡vty_init();
¡¡¡¡#endif
¡¡¡¡return 0;
¡¡¡¡}
¡¡¡¡CONFIG_VT:ÊÇÖ¸ÅäÖÃÐéÄâÖÕ¶Ë.¼´ÎÒÃÇËù˵µÄ¿ØÖÆÌ¨.ÔÚ´Ë¿ÉÒÔ¿´µ½TTY_MAJOR(4),0¶ÔÓ¦µÄÉ豸½Úµã²Ù×÷¼¯Îªconsole_fops.
¡¡¡¡¼ÌÐø¸ú½øvty_init()
¡¡¡¡int __init vty_init(void)
¡¡¡¡{
¡¡¡¡vcs_init();
¡¡¡¡console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
¡¡¡¡if (!console_driver)
¡¡¡¡panic("Couldn't allocate console driver\n");
¡¡¡¡console_driver->owner = THIS_MODULE;
¡¡¡¡console_driver->name = "tty";
¡¡¡¡console_driver->name_base = 1;
¡¡¡¡console_driver->major = TTY_MAJOR;
¡¡¡¡console_driver->minor_start = 1;
¡¡¡¡console_driver->type = TTY_DRIVER_TYPE_CONSOLE;
¡¡¡¡console_driver->init_termios = tty_std_termios;
¡¡¡¡console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
¡¡¡¡tty_set_operations(console_driver, &con_ops);
¡¡¡¡if (tty_register_driver(console_driver))
¡¡¡¡panic("Couldn't register console driver\n");
¡¡¡¡kbd_init();
¡¡¡¡console_map_init();
¡¡¡¡#ifdef CONFIG_PROM_CONSOLE
¡¡¡¡prom_con_init();
¡¡¡¡#endif
¡¡¡¡#ifdef CONFIG_MDA_CONSOLE
¡¡¡¡mda_console_init();
¡¡¡¡#endif
¡¡¡¡return 0;
¡¡¡¡}
¡¡¡¡¾¹ýÎÒÃÇ֮ǰµÄttyÇý¶¯¼Ü¹¹·ÖÎö,Õâ¶Î´úÂë¿´ÆðÀ´¾Í±È½Ï¼òµ¥ÁË,Ëü¾ÍÊÇ×¢²áÁËÒ»¸öttyÇý¶¯.Õâ¸öÇý¶¯¶ÔÓ¦µÄ²Ù×÷¼¯ÊÇλÓÚcon_opsÀïÃæµÄ.
¡¡¡¡×Ðϸ¿´.ÔÚÖ®ºó»¹»áµ÷ÓÃkbd_init().¹ËÃû˼Òå,Õâ¸öÊÇÒ»¸öÓй
Ïà¹ØÎĵµ£º
ÌåÑéÒ»ÏÂlinuxϱàдºÍʹÓö¯Ì¬¿âÓ뾲̬¿â£¬·¶Àý£ºhelloworld³ÌÐò¡£
Ê×Ïȱàд¾²Ì¬¿â£º
hellos.h
#ifndef _HELLO_S_H
#define _HELLO_S_H
void prints(char *str);
#endif
hellos.c
#include "hellos.h"
#include <stdio.h>
void prints(char *str)
{
printf("print in sta ......
¼Ç¼ÔÚlinuxÏ¿ª·¢Óöµ½µÄ¸÷ÖÖÎÊÌ⣬·½±ãÒÔºó²éÕÒ¡£
1.¹ØÓÚshellÖнű¾µÄÖ´Ðз½Ê½£ºÔÚµ±Ç°½Å±¾Ö´Ðл¹ÊÇÆô¶¯Ò»¸öеÄshell½ø³ÌÀ´Ö´Ðнű¾¡£
¼ÙÉ赱ǰĿ¼ÏÂÓнű¾script.sh¡£
Æô¶¯Ò»¸öеÄshell½ø³ÌÀ´Ö´ÐУº
ÕâÊÇshellÖÐĬÈϵÄÖ´Ðз½Ê½ÊÇÆô¶¯Ò»¸öеÄshell½ø³Ì£¨×Ó½ø³Ì£©À´Ö´Ðнű¾£¬¼´sh script.sh»òÕ߸³Ó ......
1.µãºÅ½ø¶ÈÏÔʾcode 1
#!/bin/sh
#Êä³ö"."½ø¶ÈÌõº¯Êý£¬¼æÈÝbsh¡¢ksh¡¢bash
#Ê×ÏÈtrap 1 2 3 15Ðźţ¬ÖØÒª
trap 'kill $BG_PID;echo;exit' 1 2 3 15
function dots
{
stty -echo >/dev/null 2>&1
  ......
×°ÁËÒ»¸öVMWARE£¬ÆäÖÐÔËÐеÄÊÇLINUX-FC11¡£ÎªÁËÄܹ»Í¬Window Host¹²ÏíÎļþ£¬´òËãÔÚLinuxÉÏ×°Samba·þÎñ¡£Ö®Ç°Ò²ÊÔ×ÅÓÃVMWARE Tools£¬²»¹ýûÄܳɹ¦¡£ËµÎÒµÄFC11ÓÐÎÊÌâ¡£¿ÉÄÜÊDZàÒë»·¾³»òÕß°æ±¾µÄÎÊÌâ¡£ÓÚÊÇÓÃSamba¡£
ÓÃSambaµÄGUI½çÃæÉèÖÃÁ˹²ÏíĿ¼¡£¿ÉÊÇWindows»¹ÊÇÕÒ²»µ½ÎҵĹ²ÏíĿ¼¡£½Ó×Ű´ÍøÉϵÄÌáʾ£¬´ò¿ªÁË·À»ðǽ½«S ......