3)Linux³ÌÐòÉè¼ÆÈëÃÅ
3)Linux³ÌÐòÉè¼ÆÈëÃÅ--Îļþ²Ù×÷
LinuxÏÂÎļþµÄ²Ù×÷
Ç°ÑÔ:
ÎÒÃÇÔÚÕâÒ»½Ú½«ÒªÌÖÂÛlinuxÏÂÎļþ²Ù×÷µÄ¸÷¸öº¯Êý.
ÎļþµÄ´´½¨ºÍ¶Áд
ÎļþµÄ¸÷¸öÊôÐÔ
Ŀ¼ÎļþµÄ²Ù×÷
¹ÜµÀÎļþ
----------------------------------------------------------------------------
----
1¡£ÎļþµÄ´´½¨ºÍ¶Áд
ÎÒ¼ÙÉèÄãÒѾ֪µÀÁ˱ê×¼¼¶µÄÎļþ²Ù×÷µÄ¸÷¸öº¯Êý(fopen,fread,fwriteµÈµÈ).µ±È»
Èç¹ûÄã²»Çå³þµÄ»°Ò²²»Òª×ż±.ÎÒÃÇÌÖÂÛµÄϵͳ¼¶µÄÎļþ²Ù×÷ʵ¼ÊÉÏÊÇΪ±ê×¼¼¶Îļþ²Ù×÷
·þÎñµÄ.
µ±ÎÒÃÇÐèÒª´ò¿ªÒ»¸öÎļþ½øÐжÁд²Ù×÷µÄʱºò,ÎÒÃÇ¿ÉÒÔʹÓÃϵͳµ÷Óú¯Êýopen.ʹÓÃÍê
³ÉÒÔºóÎÒÃǵ÷ÓÃÁíÍâÒ»¸öcloseº¯Êý½øÐйرղÙ×÷.
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
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 ÆäËûÈË¿ÉÒÔд
S_IXOTH ÆäËûÈË¿ÉÒÔÖ´ÐÐ S_IRWXO ÆäËûÈË¿ÉÒÔ¶ÁдִÐÐ
-----------------------------------------------------------------
S_ISUID ÉèÖÃÓû§Ö´ÐÐID S_ISGID ÉèÖÃ×éµÄÖ´ÐÐID
-----------
Ïà¹ØÎĵµ£º
Õâ¸öÊÇÎÒÔÚÒ»±¾ÊéÉÏ¿´µ½µÄ£¬ÆäÖеÄһЩ´úÂëÎÒÓÐËù¸Ä±ä£¬Ð´¸ø¸÷λºÃÓѹ²Ïíһϣ¡
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h&g ......
ÍêÉÆLinuxϵͳ
1.¿ª»ú×Ô¶¯¹ÒÔØwindow·ÖÇø
fedora10ËäÈ»ÄÜ×Ô¶¯¹ÒÔØ,µ«ÊǹÒÔصķÖÇøÓÐʱ»á²»ÈϺº×ÖÎļþ¼Ð
´ÓÖÕ¶ËÓÃvi»ògedit´ò¿ª/etc/fstab£¬ÔÚÆäÖÐÌí¼Ó£º
/dev/sda1 /mnt/1 ntfs default 0 0
×¢£ºµÚÒ»ÏîÊÇ·ÖÇøÇý¶¯µØÖ·
......
ºÜÔçÒÔÇ°,¾ÍÏë°Ñ×Ô¼ºÔÚ¿ª·¢ÏîĿʱ¹ØÓÚlinuxÊØ»¤½ø³ÌµÄ¼¼ÊõÕûÀíÒ»ÏÂ,·¢±íһƪÎÄÕÂ.½ñÌìÔÚÍøÉÏżȻÅöµ½ÓÐһƪдµÄͦ²»´íµÄÎÄÕÂ,ÕýºÃ¿ÉÒÔתÌù¹ýÀ´ºÍ´ó¼Ò·ÖÏí.
Linux Deamon±à³Ì·½·¨
ÊØ»¤½ø³Ì£¨Daemon£©ÊÇÔËÐÐÔÚºǫ́µÄÒ»ÖÖÌØÊâ½ø³Ì¡£Ëü¶ÀÁ¢ÓÚ¿ØÖÆÖն˲¢ÇÒÖ ......
2.1.2 ÓÃNFSʵÏÖ×ÊÔ´¹²Ïí
Ç°Ãæ½²µÄSambaÊÇʵÏÖLinuxÖ÷»úÖ®¼ä¡¢WindowsºÍLinuxÖ®¼äʵÏÖ×ÊÔ´¹²ÏíµÄ;¾¶¡£¶øNFSÊÇʵÏÖLinuxÖ÷»úÖ®¼ä¹²ÏíµÄÁíÒ»ÖÖ;¾¶¡£NFS×îÔçʹÓÃÔÚSun·þÎñÆ÷ÉÏ£¬ÏÖÔÚÒѾÒÆÖ²µ½¸÷ÖÖÀàUNIXϵͳÏÂÁË£¬WindowsÏÂÒ²ÓÐÏàÓ¦µÄ°æ±¾¡£Ïà¶ÔSamba·þÎñ£¬NFS¹²Ïí¾ßÓмòµ¥¿ìËÙµÄÌص㣬ËùÒÔÄ¿Ç°¹ã·ºÓÃÓÚÀàUNIXÖ÷»úÖ®¼äµÄ×Ê ......