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

LinuxÇý¶¯Ö®ioctl

ÔÚÓû§¿Õ¼ä£¬Ê¹ÓÃioctlϵͳµ÷ÓÃÀ´¿ØÖÆÉ豸£¬Ô­ÐÍÈçÏ£º
int ioctl(int fd, unsigned long cmd, ...);
µÚÈý¸ö²ÎÊý²»±íʾһ¸ö±äÊýÄ¿µÄ²ÎÊý£¬¶øÊÇÒ»¸öÀàÐÍ¿ÉÑ¡µÄ²ÎÊý¡£µÚÈý¸ö²ÎÊýÒÀÀµÓÚ¿ØÖÆÃüÁһЩÃüÁî²»ÓòÎÊý£¬Ò»Ð©ÓÃÒ»¸öÕûÊýÖµ£¬Ò»Ð©Ê¹ÓÃÖ¸Õë
1¡¢ioctlº¯Êý¶¨ÒåÃüÁî
ÔÚ±àдioctl´úÂë֮ǰ£¬Ê×ÏÈÐèÒª¶¨ÒåÃüÁΪÁË·ÀÖ¹¶Ô´íÎóµÄÉ豸ʹÓÃÕýÈ·µÄÃüÁÃüÁîºÅÓ¦¸ÃÔÚϵͳ·¶Î§ÄÚÊÂΨһµÄ
ioctlÃüÁî±àÂë±»»®·ÖΪ¼¸¸ö¶Î£¬include/asm/ioctl.hÖж¨ÒåÁËÕâЩ×ֶΣºÀàÐÍ£¨»ÃÊý£©£¬»ùÊý£¬´«ËÍ·½Ïò£¬²ÎÊý´óСµÈ¡£Documentation/ioctl-number.txtÎļþÖÐÂÞÁÐÁËÔÙÄÚºËÖÐÒѾ­Ê¹ÓÃÁ˵ĻÃÊý¡£
¶¨ÒåioctlÃüÁîµÄÕýÈ··½·¨ÊÇʹÓÃ4¸öλ¶Î£¬Õâ¸öÁбíÖнéÉܵķûºÅ¶¨ÒåÔÚ<linux/ioctl.h>ÖУº
Type£º
»ÃÊý£¨ÀàÐÍ£©£º±íÃ÷ÄĸöÉ豸µÄÃüÁÔڲο¼ÁËioctl-number.txtÖ®ºóÑ¡³ö£¬8λ¿í¡£
Number£º
ÐòºÅ£¬±íÃ÷É豸ÃüÁîÖеĵڼ¸¸ö£¬8λ¿í
ÄÚºËÌṩÁËÏÂÁкêÀ´°ïÖú¶¨ÒåÃüÁîºÅ£¬ÈçÏÂ
_IO(type, nr)£ºÃ»ÓвÎÊýµÄÃüÁî
_IOR(type, nr, datatype)£º´ÓÇý¶¯ÖжÁÊý¾Ý
_IOW(type, nr, datatype)£ºÐ´Êý¾Ýµ½Çý¶¯
_IOWR(type, nr, datatype)£ºË«Ïò´«ËÍ£¬typeºÍnumber×÷Ϊ²ÎÊý±»´«µÝ
2¡¢ioctlº¯ÊýµÄʵÏÖ
·ÖÈý¸ö¼¼Êõ»·½Ú£º
1¡¢·µ»ØÖµ
ioctlº¯ÊýµÄʵÏÖͨ³£ÊǸù¾ÝÃüÁîÖ´ÐеÄÒ»¸öswitchÓï¾ä¡£µ«Êǵ±ÃüÁî²»ÄÜÆ¥ÅäÈκÎÒ»¸öÉ豸ËùÖ§³ÖµÄÃüÁîʱ£¬Í¨³£·µ»Ø-EINVAL£¨“·Ç·¨²ÎÊý”£©
2¡¢²ÎÊýʹÓÃ
Èç¹ûÊÇÒ»¸öÕûÊý£¬¿ÉÒÔÖ±½ÓʹÓá£Èç¹ûÊÇÖ¸Õ룬ÎÒÃDZØÐëÈ·±£Õâ¸öÓû§µØÖ·ÊÇÓÐЧµÄ£¬Òò´ËʹÓÃÇ°Ðè½øÐÐÕýÈ·µÄ¼ì²é
ʹÓÃint access_ok(int type, const void *addr, unsigned long size)À´¼ì²éÒ»¸öÖ¸ÕëµØÖ·ÊÇ·ñ¿ÉÒÔ·ÃÎÊ
µÚÒ»¸ö²ÎÊýÊÇVERIFY_READ»òÕßÊÇVERIFY_WRITE£¬ÓÃÀ´±íÃ÷¶ÁÓû§Äڴ滹ÊÇдÓû§ÄÚ´æ¡£addr²ÎÊýʱҪ²Ù×÷µÄÓû§ÄÚ´æµØÖ·£¬sizeÊDzÙ×÷µÄ³¤¶È¡£Èç¹ûioctlÐèÒª´ÓÓû§¿Õ¼ä¶ÁÒ»¸öÕûÊý£¬ÄÇôsize = sizeof(int)¡£Èç¹ûÐèҪͬʱ¶ÁºÍд£¬ÔòʹÓÃVERIFY_WRITE¡£
access_ok·µ»ØÒ»¸ö²¼¶ûÖµ£º1Êdzɹ¦£¨´æȡûÎÊÌ⣩ºÍ0ÊÇʧ°Ü£¨´æÈ¡ÓÐÎÊÌ⣩£¬Èç¹û¸Ãº¯Êý·µ»Øʧ°Ü£¬ÔòioctlÓ¦µ±·µ»Ø-EFAULT£¬È磺
if(_IOC_DIR(cmd) & _IOC_READ)// Ϊʲô_IOC_READ¶ÔÓ¦VERIFY_WRITE£¿£¿£¿
    err = !access_ok(VERIFY_WRITE, (void  __user *)arg, _IOC_SIZE(cmd));
else if(_IOC_DIR(cmd) & _IOC_WRITE)
       err = ! access_ok(VERI


Ïà¹ØÎĵµ£º

Linux iptableÎĵµ

×ÜÀÀ
ÓÃiptables -ADC À´Ö¸¶¨Á´µÄ¹æ
Ôò
£¬-AÌí¼Ó -Dɾ³ý -C ÐÞ¸Ä
iptables - [RI] chain rule num rule-specification[option]
ÓÃiptables - RI ͨ¹ý¹æÔòµÄ˳ÐòÖ¸¶¨
iptables -D chain rule num[option]
ɾ³ýÖ¸¶¨¹æÔò
iptables -[LFZ] [chain][option]
ÓÃiptables -LFZ Á´Ãû [Ñ¡Ïî]
iptables -[NX] chain
ÓÃ -NX ......

Éî¶ÈÍÚ¾òLinux²Ù×÷ϵͳÃüÁî¡°man¡±

manÊÇmanual£¨ÊֲᣩµÄËõд
man¿ÉÒÔÔÚ²»Í¬µÄ°æ±¾ÖÐʹÓã¬Ö÷Òª·ÖΪÁ½Àà¡£Red HatºÍÐí¶àÆäËû»ùÓÚRPMµÄ°æ±¾Ê¹Óô«Í³µÄman³ÌÐò£¬¶ø»ùÓÚDebianµÄ°æ±¾Ê¹ÓÃÒ»¸öÃûΪman-dbµÄÈí¼þ°ü¡£
man£¨1£©
ÔÚÎı¾´°¿ÚÖÐä¯ÀÀÎļþµÄ·½Ê½ÔÚÆÕ±éʹÓÃHTMLºÍPDFµÄʱ´úÖÐËƺõÓÐЩ¹ýʱÁË£¬µ«ÔÚÖն˴°¿ÚÖÐÔĶÁÎļþÈÔÓÐÆäÓÅÊÆ¡£¶ÔÓÚÄÇЩLinux¿ª·¢ÕßÀ´ ......

arm linux µÈ´ý¶ÓÁмòµ¥·ÖÎö

Author-------Dansen-----xzd2734@163.com
wait_queue_head_t wait_q;
Ê×ÏÈ¿´¿´
wait_queue_head_tÕâ¸öµÈ´ý¶ÓÁеĽṹ
ÔÚwait.hÖж¨ÒåÁËÕâ¸ö½á¹¹
typedef struct
__wait_queue_head wait_queue_head_t;
struct __wait_queue_head {
 wq_lock_t
lock;
 struct list_head task_list;
};
# define wq_ ......

ÐéÄâ»úLinuxÏÂMinicomµÄÅäÖÃ

1¡¢Ìí¼Ó´®¿Ú: ÔÚLinuxÆô¶¯Ö®Ç°£¬ÐéÄâ»ú--¡·ÉèÖÃ--¡·Ìí¼Ó--¡·´®¿Ú--¡·±£´æ--¡·Æô¶¯Linux¡£
 
2¡¢#minicom £¬³öÏÖÆô¶¯½çÃ棬CTRL-A Z ½øÈë°ïÖú½çÃæ
   
3¡¢¼üÈëO £¬ÅäÖô®¿Ú£¬Ñ¡ÔñµÚÈýÏî“Serial port setup”µã»÷»Ø³µ
   
4¡¢Í¨¹ý·Ö±ð¼üÈëA¡¢E¡¢F£¬ÅäÖ㬵ã»÷»Ø³µ£¨FÑ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ