linuxÄÚºËÄ£¿éºÍÇý¶¯³ÌÐòµÄ±àд
linuxÖеĴ󲿷ÖÇý¶¯³ÌÐò,ÊÇÒÔÄ£¿éµÄÐÎʽ±àдµÄ.ÕâЩÇý¶¯³ÌÐòÔ´Âë¿ÉÒÔÐ޸ĵ½ÄÚºËÖÐ,Ò²¿ÉÒÔ°ÑËûÃDZàÒë³ÉÄ£¿éÐÎÊÆ,ÔÚÐèÒªµÄʱºò¶¯Ì¬¼ÓÔØ.
Ò»¸öµäÐ͵ÄÇý¶¯³ÌÐò,´óÌåÉÏ¿ÉÒÔ·ÖΪÕâô¼¸¸ö²¿·Ö:
1¡¢×¢²áÉ豸
ÔÚϵͳ³õÆô,»òÕßÄ£¿é¼ÓÔØʱºò,±ØÐ뽫É豸µÇ¼Çµ½ÏàÓ¦µÄÉ豸Êý×é,²¢·µ»ØÉ豸µÄÖ÷Çý¶¯ºÅ,ÀýÈç:¶Ô¿ìÉ豸À´Ëµµ÷ÓÃrefister_blkdec()½«É豸Ìí¼Óµ½Êý×éblkdevÖÐ.²¢ÇÒ»ñµÃ¸ÃÉ豸ºÅ.²¢ÀûÓÃÕâЩÉ豸ºÅ¶Ô´ËÊý×é½øÐÐË÷Òý.¶ÔÓÚ×Ö·ûÇý¶¯É豸À´Ëµ,ҪʹÓÃmodule_register_chrdev()À´»ñµÃ×£É豸µÄÇý¶¯ºÅ.È»ºó¶ÔÕâ¸öÉ豸µÄËùÓе÷Óö¼ÓÃÕâ¸öÉ豸ºÅÀ´ÊµÏÖ
2¡¢¶¨Ò幦Äܺ¯Êý
¶ÔÓÚÿһ¸öÇý¶¯º¯ÊýÀ´Ëµ.¶¼ÓÐһЩºÍ´ËÉ豸ÃÜÇÐÏà¹ØµÄ¹¦Äܺ¯Êý.ÄÇ×î³£ÓõĿéÉ豸»òÕß×Ö·ûÉ豸À´Ëµ.¶¼´æÔÚ×ÅÖîÈç open() read() write() ioctrol()ÕâÒ»ÀàµÄ²Ù×÷.µ±ÏµÍ³ÉçÓÃÕâЩµ÷ÓÃʱ.½«×Ô¶¯µÄʹÓÃÇý¶¯º¯ÊýÖÐÌض¨µÄÄ£¿é.À´ÊµÏÖ¾ßÌåµÄ²Ù×÷.¶ø¶ÔÓÚÌض¨µÄÉ豸.ÉÏÃæµÄϵͳµ÷ÓöÔÓ¦µÄº¯ÊýÊÇÒ»¶¨µÄ.
Èç:ÔÚ¿éÇý¶¯É豸ÖÐ.µ±ÏµÍ³ÊÔͼ¶ÁÈ¡Õâ¸öÉ豸(¼´µ÷ÓÃread()ʱ),¾Í»áÔËÐÐÇý¶¯³ÌÐòÖеÄblock_read() Õâ¸öº¯Êý. ´ò¿ªÐÂÉ豸ʱ»áµ÷ÓÃÕâ¸öÉ豸Çý¶¯³ÌÐòµÄdevice_open() Õâ¸öº¯Êý.
3¡¢Ð¶ÔØÄ£¿é
ÔÚ²»ÓÃÕâ¸öÉ豸ʱ,¿ÉÒÔ½«ËûжÔØ.Ö÷ÒªÊÇ´Ó/proc ÖÐÈ¡ÏûÕâ¸öÉ豸µÄÌØÊâÎļþ.¿ÉÓÃÌض¨µÄº¯ÊýʵÏÖ.
ÏÂÃæÎÒÃÇÁоÙÒ»¸ö×Ö·ûÉ豸Çý¶¯³ÌÐòµÄ¿ò¼Ü.À´ËµÃ÷Õâ¸ö¹ý³Ì.
/* a module of a character device */
/* some include files*/
#include "param.h"
#include "user.h"
#include "tty.h"
#include "dir.h"
#include "fs.h"
/* the include files modules need*/
#include "linux/kernel.h"
#include "linux/module.h"
#if CONFIG_MODBERSIONS==1
define MODBERSIONS
#include" linux.modversions.h"
#endif
#difine devicename mydevice
/* the init funcion*/
int init_module()
{
int tag=module_register_chrdev(0,mydevice,&Fops);
if (tag<0)
{
printk("the device init is erro!\n");
return 1;
}
return 0;
}
/*the funcion which the device will be used */
int device_open ()
{
…….
}
int device_read ()
{
…….
}
int device_write ()
{
…….
}
int device_ioctl ()
{
…….
}
……
/* the deltter function of this module*/
int cleanup_module()
{
int re=module_unregister_chrde
Ïà¹ØÎĵµ£º
MySQL :: Linux ÏÂ×Ô¶¯±¸·ÝÊý¾Ý¿âµÄ shell ½Å±¾
Linux ·þÎñÆ÷ÉϵijÌÐòÿÌ춼ÔÚ¸üРMySQL Êý¾Ý¿â£¬ÓÚÊǾÍÏëÆðдһ¸ö shell ½Å±¾£¬½áºÏ crontab£¬¶¨Ê±±¸·ÝÊý¾Ý¿â¡£Æäʵ·Ç³£¼òµ¥£¬Ö÷Òª¾ÍÊÇʹÓà MySQL ×Ô´øµÄ mysqldump ÃüÁî¡£
½Å±¾ÄÚÈÝÈçÏ£º
#!/bin/sh
# File: /home/mysql/backup.sh
# Database info
DB_NAME=" ......
¿ÉÒÔ½«Õâ¸ö½Å±¾·Å½øcrontab£¬ËûµÄÅäÖÆÎļþÔÚ /etc/crontabÖÐÿÌìÁ賿ִÐÐÒ»´Î£¬×Ô¶¯±¸·Ý Õâ¸ö½Å±¾Ã¿Ìì×î¶àÖ»Ö´ÐÐÒ»´Î£¬¶øÇÒÖ»±£Áô×î½üÎåÌìµÄ±¸·ÝÔÚ·þÎñÆ÷ÉÏ¡£
#!/bin/bash
#This is a ShellScript For Auto DB Backup
#Powered by aspbiz
#2004-09
#Setting
#ÉèÖÃÊý¾Ý¿âÃû£¬Êý¾Ý¿âµÇ¼Ãû£¬ÃÜÂ룬±¸·Ý·¾¶£¬ÈÕ־ ......
Ð޸ı¾µØÓû§ÃÜÂ룺
1¡¢½»»¥ÅäÖñ¾µØÓû§£º
ÒÔrootÓû§£º
passwd <username>
Changing passWord
for user dewang.
New UNIX passWord
:
BAD PASSWord
: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
ÒÔ·ÇrootÓû§ÐÞ¸Ä×Ô¼ºµÄÃÜÂ루עºóÃæ²»Äܸ ......
ÍøÉϹØÓÚÖÐÎÄÊäÈëµÄÎÄÕºܶ࣬´Ë´¦Ö»ÊÇÏëÊèÀíһϼ¸¸ö¸ÅÄî¡£
1¡£ÊäÈ뷨ƽ̨£º
windowsÏÂÊäÈë·¨ÓëÊäÈ뷨ƽ̨ºÃÏñÊÇ·Ö²»ÇåµÄ£¬¶øÔÚLinuxÏÂËûÃǵĸÅÄÊÇ·Ö¿ªµÄºÃ£¬ÊäÈ뷨ƽ̨ÊÇÊäÈë·¨µÄ»ù´¡£¬ÓÐʱºòÄã°²×°ÁËij¸öÊäÈë·¨£¬È´ÔõôҲµ÷²»³öÀ´£¬ÔòÓпÉÄܾÍÊÇËüËùÐèÒªµÄƽ̨»¹Ã»Óн¨Á¢¡£
¼¸¸öÊäÈ뷨ƽ̨£º
xcin£¨x-ChineseInpu ......