LinuxÖÐÕýÈ·´¦Àíerrno
errno±äÁ¿(Ðèinclude errno.h)»á±»¸³Ò»¸öÕûÊýÖµ,²»Í¬µÄÖµ±íʾ²»Í¬µÄº¬Òå,
¿ÉÒÔͨ¹ý²é¿´¸ÃÖµÍƲâ³ö´íµÄÔÒò¡£µ«ÊÇerrnoÊÇÒ»¸öÊý×Ö£¬´ú±íµÄ¾ßÌ庬Òå
»¹Òªµ½errno.hÖÐÈ¥ÔĶÁºê¶¨Òå¡£ÓÐÏÂÃ漸ÖÖ·½·¨¿ÉÒÔ·½±ãµÄµÃµ½´íÎóÐÅÏ¢
(Ò»)
#include <stdio.h>
void perror(const char *s)
perror()ÓÃÀ´½«ÉÏÒ»¸öº¯Êý·¢Éú´íÎóµÄÔÒòÊä³öµ½stderr¡£²ÎÊýsËùÖ¸µÄ×Ö·û´®»áÏÈ
´òÓ¡³ö£¬ºóÃæ¸úÒ»¸öðºÅºÍÒ»¸ö¿Õ¸ñÔÙ¼ÓÉÏ´íÎóÔÒò×Ö·û´® ºóÃæÔÙ¼ÓÉÏÒ»¸ö»»Ðзû¡£
´Ë´íÎóÔÒòÒÀÕÕÈ«¾Ö±äÁ¿errnoµÄ Ö±À´¾ö¶¨Òª
Êä³öµÄ×Ö·û´®
*******/
#include<stdio.h>
#include<stdlib.h>
int main ()
{
FILE *fp;
fp=fopen("/tmp/xx","r+");
if(fp==NULL) perror("fopen");
return 0;
}
£¨¶þ£©
#include <string.h>
char * strerror(int errnum)
º¯Êý˵Ã÷ strerror£¨£©ÓÃÀ´ÒÀ²ÎÊýerrnumµÄ´íÎóÂëÀ´²éѯ´íÎóÔÒò
µÄÃèÊö×Ö·û´®£¬È»ºó½«¸Ã×Ö·û´®Ö¸Õë·µ»Ø¡£
Õâ¸öº¯Êý±¾Éí²¢²»»á±§´í ËùÒÔûÓÐΪÕâ¸öº¯Êý±£ÁôÏìÓ¦µÄ´íÎóÖµ
·µ»ØÖµ£º ·µ»ØÃèÊö´íÎóÔÒòµÄ×Ö·û´®Ö¸Õë
****/
#include <string.h>
#include <stdio.h>
int main ()
{
//ÏÔʾ´íÎó´úÂë0µ½9µÄ´íÎóÔÒòÃèÊö
int i;
for(i=0;i<10;i++)
fprintf(stderr,"%d:%s \n",i,strerror(i));
return 0;
}
strerrorº¯Êý¿ÉÄÜ»á¸Ä±äerror¡£Èç¹ûÐèÒªÔÚµ÷ÓÃstrerrorºóÔÙ´ÎʹÓÃ
error £¬Ó¦¸ÃÔÚµ÷ÓÃstrerrorÇ®±£´æerror£¬²¢ÔÚÔÙ´ÎʹÓÃ֮ǰ½«Æä»Ö¸´¡£
ÏÂÃæµÄ´úÂë˵Ã÷ÈçºÎÔÚʹÓÃstrerrorµÄͬʱÒÀÈ»±£³ÖerrorµÄÖµ
int error;
int fildes;
if (close(fildes)==-1){
error = errno;
fprintf(stderr,"Failed to close descriptor %d :%s\n",
fildes,strerror(errono);
errno = error;
}
ÕýÈ·µØ´¦ÀíerrnoÊǸö¼¬ÊÖµÄÎÊÌâ¡£ÓÉÓڿ⺯ÊýµÄʵÏÖÖпÉÄÜ»áµ÷ÓÃÆäËû¿ÉÒÔ
ÉèÖÃerrnoµÄº¯Êý£¬Òò´Ë£¬¼´Ê¹¿âº¯ÊýµÄÁª»ú°ïÖúÒ³ÃæÖÐûÓÐÏÔʾµÄ˵Ã÷£¬¿â
º¯Êý»¹ÊÇ»á¶Ôerrno½øÐÐÐ޸ġ£Í¬Ñù£¬Ó¦ÓóÌÐòÎÞ·¨Ð޸ĴÓstrerrorÖзµ»ØµÄ×Ö·û´®£
Ïà¹ØÎĵµ£º
Linux Îļþϵͳ¸ÅÊö
×÷Õߣº±±ÄÏÄϱ±
À´×Ô£ºLinuxSir.Org
ÕªÒª£º ±¾ÎÄͨ¹ýÎļþϵͳµÄ¶¨Òå˵Æð£¬È»ºóͨ¹ýÒýÎļòµ¥µÄ½éÉÜÁËÒ»ÏÂÎļþϵͳÀàÐÍ£»¶ÔLinux³£ÓõÄext2¡¢ext3¼°reiserfs ¸ù¾Ý±¾ÈËʹÓþÑéÒ²·º·ºµÄ̸ÁË̸£¬µ«²¢²»ÊÇרҵµÄ¡£ÈçºÎÔĶÁ±¾ÎÄ£¬»¹ÊÇÓÃÂí¿Ë˼ÀíÂÛ¸æËßÎÒÃǵķ½·¨£ºÒ»·ÖΪ¶þ£¬±ß¿´±ßÅú°É£»Ä¿Â¼Ë÷Òý Ò»¡¢Ê²Ã´ ......
Ò»¡¢ÏÂÔØjpeg¿â
¶þ¡¢ÅäÖñàÒ룬Éú³ÉMakefileÎļþ¡£
#./configure --prefix=/usr/arm/arm-linux --exec-prefix=/usr/arm/arm-linux \
--enable-shared --enable-static
×¢Ò⣺prefixÊÇ×îºó°²×°Ê±¿â´æ·ÅµÄÎļþ£¬sharedÊDZàÒë³É¶¯Ì¬¿â£¬staticÊDZàÒë³É¾²Ì¬¿â
Èý¡¢ÐÞ¸ÄÉú³ÉµÄMakefile¡£
ʹÓÃgedit £Í£á£ë£å£æ£é£ì£å
½«CC ......
ʹÓùý³ÌÖеÄÐĵãº
Ò»¡¢½â³ýĿ¼ӳÉä¹Øϵ
umount Ŀ¼¿ÉÒÔ½â³ý¹ØÁª¹Øϵ
±ØÐëÏÈÔÚ¿Í»§¶Ëumount£¬È»ºóÔÚ·þÎñÆ÷¶ËÍ£Ö¹nfs·þÎñ£¬ÒÔ¼°ÐÞ¸Ä/etc/exports£¬·ñÔòµÄ»°»áµ¼ÖÂdf -hÎÞ·¨¹Ø±Õ
¶þ¡¢mount.nfs: Input/output error
½â¾ö:ÔÚ¿Í»§¶ËÒ²ÐèÆô¶¯portmap
Èý¡¢ÐÞ¸ÄÍê±Ï/etc/exportsÎļþÖ®ºó£¬¿ÉÒÔÖØÆônfs·þÎñ£¬Ò²¿ÉÒÔʹÓÃexp ......
ÔÚijЩÌØÊâµÄÇé¿öÏ£¬ÈçÒòΪÍøÂç»òÕßXÅäÖõĹØϵÎÞ·¨Á¬½Óµ½X server»òÕßÖ÷»úÉÏûÓÐX£¬¾Í¿ÉÒÔʹÓþ²Ä¬°²×°µÄ·½Ê½°²×°Êý¾Ý¿â£¬Í¬ÑùÈç¹ûÐèÒª´ó¹æÄ£²¿Êð£¬Ôò¾²Ä¬°²×°½«»á´ó´ó¼õÇáDBAµÄÖظ´ÀͶ¯Á¦£¬¶øÇÒ¾²Ä¬°²×°²»ÐèÒªX£¬´Ó°²×°Ð§ÂÊ
ÔÚijЩÌØÊâµÄÇé¿öÏ£¬ÈçÒòΪÍøÂç»òÕßXÅäÖõĹØϵÎÞ·¨Á¬½Óµ½X server»òÕßÖ÷»úÉÏûÓÐX£ ......
ÔÚVFSµÄÖ§³ÖÏ£¬Óû§Ì¬½ø³Ì¶ÁдÈκÎÀàÐ͵ÄÎļþϵͳ¶¼¿ÉÒÔʹÓÃreadºÍwrite×ÅÁ½¸öϵͳµ÷Ó㬵«ÊÇÔÚlinuxÄÚºËÖÐûÓÐÕâÑùµÄϵͳµ÷ÓÃÎÒÃÇÈçºÎ²Ù×÷ÎļþÄØ£¿ÎÒÃÇÖªµÀreadºÍwriteÔÚ½øÈëÄÚºË̬֮ºó£¬Êµ¼ÊÖ´ÐеÄÊÇsys_readºÍsys_write£¬µ«ÊDz鿴ÄÚºËÔ´´úÂ룬·¢ÏÖÕâЩ²Ù×÷ÎļþµÄº¯Êý¶¼Ã»Óе¼³ö(ʹÓÃEXPORT_SYMBOLµ¼³ö)£¬Ò²¾ÍÊÇ˵ÔÚÄÚºË ......