Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÏÂCÓïÑÔ±à³Ì ÎļþµÄ²Ù×÷

Ç°ÑÔ: 
    ÎÒÃÇÔÚÕâÒ»½Ú½«ÒªÌÖÂÛlinuxÏÂÎļþ²Ù×÷µÄ¸÷¸öº¯Êý. 
1.ÎļþµÄ´´½¨ºÍ¶Áд 
2.ÎļþµÄ¸÷¸öÊôÐÔ 
3.Ŀ¼ÎļþµÄ²Ù×÷ 
4.¹ÜµÀÎļþ 
--------------------------------------------------------------------------------
1¡£ÎļþµÄ´´½¨ºÍ¶Áд 
    ÎÒ¼ÙÉèÄãÒѾ­ÖªµÀÁ˱ê×¼¼¶µÄÎļþ²Ù×÷µÄ¸÷¸öº¯Êý(fopen,fread,fwriteµÈµÈ).µ±È»Èç¹ûÄã²»Çå³þµÄ»°Ò²²»Òª×ż±.ÎÒÃÇÌÖÂÛµÄϵͳ¼¶µÄÎļþ²Ù×÷ʵ¼ÊÉÏÊÇΪ±ê×¼¼¶Îļþ²Ù×÷·þÎñµÄ. 
µ±ÎÒÃÇÐèÒª´ò¿ªÒ»¸öÎļþ½øÐжÁд²Ù×÷µÄʱºò,ÎÒÃÇ¿ÉÒÔʹÓÃϵͳµ÷Óú¯Êýopen.ʹÓÃÍê³ÉÒÔºóÎÒÃǵ÷ÓÃÁíÍâÒ»¸öcloseº¯Êý½øÐйرղÙ×÷. 
#include 
#include 
#include 
#include 
int open(const char *pathname,int flags);
int open(const char *pathname,int flags,mode_t mode);
int close(int fd);
openº¯ÊýÓÐÁ½¸öÐÎʽ.ÆäÖÐpathnameÊÇÎÒÃÇÒª´ò¿ªµÄÎļþÃû(°üº¬Â·¾¶Ãû³Æ,ȱʡÊÇÈÏΪÔÚµ±Ç°Â·¾¶ÏÂÃæ).flags¿ÉÒÔÈ¥ÏÂÃæµÄÒ»¸öÖµ»òÕßÊǼ¸¸öÖµµÄ×éºÏ. 
O_RDONLY:ÒÔÖ»¶ÁµÄ·½Ê½´ò¿ªÎļþ. 
O_WRONLY:ÒÔֻдµÄ·½Ê½´ò¿ªÎļþ. 
O_RDWR:ÒÔ¶ÁдµÄ·½Ê½´ò¿ªÎļþ. 
O_APPEND:ÒÔ×·¼ÓµÄ·½Ê½´ò¿ªÎļþ. 
O_CREAT:´´½¨Ò»¸öÎļþ. 
O_EXEC:Èç¹ûʹÓÃÁËO_CREAT¶øÇÒÎļþÒѾ­´æÔÚ,¾Í»á·¢ÉúÒ»¸ö´íÎó. 
O_NOBLOCK:ÒÔ·Ç×èÈûµÄ·½Ê½´ò¿ªÒ»¸öÎļþ. 
O_TRUNC:Èç¹ûÎļþÒѾ­´æÔÚ,Ôòɾ³ýÎļþµÄÄÚÈÝ. 
Ç°ÃæÈý¸ö±êÖ¾Ö»ÄÜʹÓÃÈÎÒâµÄÒ»¸ö.Èç¹ûʹÓÃÁËO_CREATE±êÖ¾,ÄÇôÎÒÃÇҪʹÓÃopenµÄµÚ¶þÖÖÐÎʽ.»¹ÒªÖ¸¶¨mode±êÖ¾,ÓÃÀ´±íʾÎļþµÄ·ÃÎÊȨÏÞ.mode¿ÉÒÔÊÇÒÔÏÂÇé¿öµÄ×éºÏ. 
-----------------------------------------------------------------
S_IRUSR Óû§¿ÉÒÔ¶Á S_IWUSR Óû§¿ÉÒÔд
S_IXUSR Óû§¿ÉÒÔÖ´ÐÐ S_IRWXU Óû§¿ÉÒÔ¶ÁдִÐÐ
-----------------------------------------------------------------
S_IRGRP ×é¿ÉÒÔ¶Á S_IWGRP ×é¿ÉÒÔд
S_IXGRP ×é¿ÉÒÔÖ´ÐÐ S_IRWXG ×é¿ÉÒÔ¶ÁдִÐÐ
-----------------------------------------------------------------
S_IROTH         ÆäËûÈË¿ÉÒÔ¶Á    S_IWOTH  


Ïà¹ØÎĵµ£º

Book Note: Linux Device Driver Dos and Don'ts

Book Note: Linux Device Driver Dos and Don'ts
http://janitor.kernelnewbies.org/docs/driver-howto.html
what a hardened (robust) device
driver should mean and how it should be implemented and measured.
1.3 Robust device drivers
-Follows the Linux CodingStyle.
-Efficient in managing faults and ha ......

C unsigned int and int

Ê×ÏȽøÐÐÒ»¸öʵÑ飬·Ö±ð¶¨ÒåÒ»¸ösigned intÐÍÊý¾ÝºÍunsigned intÐÍÊý¾Ý£¬È»ºó½øÐдóС±È½Ï£º
unsigned int a=20;
signed int b=-130;
a>b?»¹ÊÇb>a£¿ÊµÑéÖ¤Ã÷b>a£¬Ò²¾ÍÊÇ˵£­130>20,Ϊʲô»á³öÏÖÕâÑùµÄ½á¹ûÄØ£¿
ÕâÊÇÒòΪÔÚCÓïÑÔ²Ù×÷ÖУ¬Èç¹ûÓöµ½ÎÞ·ûºÅÊýÓëÓзûºÅÊýÖ®¼äµÄ²Ù×÷£¬±àÒëÆ÷»á×Ô¶¯×ª»¯ÎªÎÞ·ûºÅ ......

C/C++ÓïÑÔʵÏÖ¶¯Ì¬Êý×é


CÊý×éµÄСÎÊÌâ
     ÕâÀï˵µÄ¶¯Ì¬Êý×éÊÇ¿ÉÒÔ¸ù¾ÝÐèÒª¶¯Ì¬Ôö³¤Õ¼ÓÃÄÚ´æµÄÊý×飬±ÈÈç³ÌÐò³õʼ·ÖÅäÁË100¸öÔªËØ£¬¿ÉÊÇÔËÐÐÁËÒ»¶Îʱ¼äºóÇøÇø100¸ö¿Õ¼ä²»ÄÜÂú×ãÁË£¬ÏÖÔÚÐèÒª400¸ö£¬Ôõô°ìÄØ£»Äǿ϶¨ÐèÒªÔÙ¶îÍâ·ÖÅä300¸ö¡£
     CÓïÑÔÓÐrealloc()º¯ÊýÀ´½â¾ö¿Õ¼äÀ©³äµÄÎÊÌ⣬µ«ÊDz»ÒªÍ ......

½«Àà³ÉÔ±º¯ÊýÓÃ×öC»Øµ÷º¯Êý

½«Àà³ÉÔ±º¯ÊýÓÃ×öC»Øµ÷º¯Êý Ìá³öÎÊÌ⣺ »Øµ÷º¯ÊýÊÇ»ùÓÚC±à³ÌµÄWindows SDKµÄ¼¼Êõ£¬²»ÊÇÕë¶ÔC++µÄ£¬³ÌÐòÔ±¿ÉÒÔ½«Ò»¸öCº¯ÊýÖ±½Ó×÷Ϊ»Øµ÷º¯Êý£¬µ«ÊÇÈç¹ûÊÔͼֱ½ÓʹÓÃC++µÄ³ÉÔ±º¯Êý×÷Ϊ»Øµ÷º¯Êý½«·¢Éú´íÎó£¬ÉõÖÁ±àÒë¾Í²»ÄÜͨ¹ý¡£·ÖÎöÔ­Òò£ºÆÕͨµÄC++³ÉÔ±º¯Êý¶¼Òþº¬ÁËÒ»¸ö´«µÝº¯Êý×÷Ϊ²ÎÊý£¬Ò༴“this”Ö¸Õ룬C++ͨ¹ý ......

Linux I2CºËÐÄ¡¢×ÜÏßÓëÉ豸Çý¶¯

Linux I2CºËÐÄ¡¢×ÜÏßÓëÉ豸Çý¶¯
×¢:
 ÔÚlinux2.6.32°æ±¾ÖÐÓÐÕâÑùµÄ´úÂëÓë×¢ÊÍ:
struct i2c_driver {
    unsigned int class;
    /* Notifies the driver that a new bus has appeared or is about to be
     * removed. You should avoid using this if y ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ