statfs»ñµÃÓ²ÅÌʹÓÃÇé¿ö Ä£ÄâlinuxÃüÁî df
˵Ã÷£º±¾ÎÄÒÔÖ÷ҪΪתÔØÄÚÈÝ£¬Í¬Ê±¼ÓÈëÁËÎÒÔÚʹÓùý³ÌÖÐÓöµ½ÎÊÌâ¶ÔÆäµÄÐÞÕý£¡£¡£¡£¡£¡£¡£¡£¡£¡
ÏÈ˵statfs½á¹¹£º
#include <sys/vfs.h> /* »òÕß <sys/statfs.h> */
int statfs(const char *path, struct statfs *buf);
int fstatfs(int fd, struct statfs *buf);
²ÎÊý£º
path: λÓÚÐèÒª²éѯÐÅÏ¢µÄÎļþϵͳµÄÎļþ·¾¶Ãû(²»ÊÇÉ豸Ãû£¬ÊǹÒÔصãÃû³Æ)¡£
fd£º λÓÚÐèÒª²éѯÐÅÏ¢µÄÎļþϵͳµÄÎļþÃèÊö´Ê¡£
buf£ºÒÔϽṹÌåµÄÖ¸Õë±äÁ¿£¬ÓÃÓÚ´¢´æÎļþϵͳÏà¹ØµÄÐÅÏ¢
struct statfs
{
long f_type; /* ÎļþϵͳÀàÐÍ */
long f_bsize; /* ¾¹ýÓÅ»¯µÄ´«Êä¿é´óС */
long f_blocks; /* ÎļþϵͳÊý¾Ý¿é×ÜÊý */
long f_bfree; /* ¿ÉÓÿéÊý */
long f_bavail; /* ·Ç³¬¼¶Óû§¿É»ñÈ¡µÄ¿éÊý */
long f_files; /* Îļþ½áµã×ÜÊý */
long f_ffree; /* ¿ÉÓÃÎļþ½áµãÊý */
fsid_t f_fsid; /* Îļþϵͳ±êʶ */
long f_namelen; /* ÎļþÃûµÄ×î´ó³¤¶È */
};
***************************************************************
·µ»Ø˵Ã÷£º
³É¹¦Ö´ÐÐʱ£¬·µ»Ø0¡£Ê§°Ü·µ»Ø-1£¬errno±»ÉèΪÒÔϵÄij¸öÖµ
EACCES£º (statfs())Îļþ»ò·¾¶ÃûÖаüº¬µÄĿ¼²»¿É·ÃÎÊ
EBADF £º (fstatfs()) ÎļþÃèÊö´ÊÎÞЧ
EFAULT£º ÄÚ´æµØÖ·ÎÞЧ
EINTR £º ²Ù×÷ÓÉÐźÅÖжÏ
EIO £º ¶Áд³ö´í
ELOOP £º (statfs())½âÊÍ·¾¶Ãû¹ý³ÌÖдæÔÚÌ«¶àµÄ·ûºÅÁ¬½Ó
ENAMETOOLONG£º(statfs()) ·¾¶ÃûÌ«³¤
ENOENT£º(statfs()) Îļþ²»´æÔÚ
ENOMEM£º ºËÐÄÄÚ´æ²»×ã
ENOSYS£º Îļþϵͳ²»Ö§³Öµ÷ÓÃ
ENOTDIR£º(statfs())·¾¶ÃûÖе±×÷Ŀ¼µÄ×é¼þ²¢·ÇĿ¼
EOVERFLOW£ºÐÅÏ¢Òç³ö
**********************************************************************
Ïà¹ØµÄÎļþϵͳÀàÐÍÓУº
Ïà¹ØÎĵµ£º
/ ¸ùĿ¼
/bin ³£ÓõÄÃüÁî binary file µÄĿ¼
/boot ´æ·ÅϵͳÆô¶¯Ê±±ØÐë¶ÁÈ¡µÄµµ°¸£¬°üÀ¨ºËÐÄ (kernel) ÔÚÄÚ
  ......
Shell½Å±¾¼°Æä³É·Ö
ShellÊÇÒ»¸ö¹¦ÄÜÇ¿´óµÄ±à³ÌÓïÑÔ¡£ÓÃShell±àдµÄÅú´¦ÀíÎļþ³ÆΪShell½Å±¾¡¢
Shell½Å±¾µÄ³É·Ö
-×¢ÊͲ¿·Ö
ÒÔ#¿ªÍ·µÄÐÐ
-ÃüÁî
ÔÚShell½Å±¾ÖпÉÒÔ³öÏÖÈκÎÔÚ½»»¥·½Ê½Ï¿ÉÒÔʹÓõÄÃüÁî
-±äÁ¿
¼È¿ÉÒÔʹÓÃÓû§×Ô¶¨ÒåµÄ±äÁ¿£¬Ò²¿ÉÒÔʹÓÃϵͳ»·¾³±äÁ¿
-Á÷³Ì¿ØÖÆ
¶ÔÃüÁîµÄÖ´ÐÐÁ÷³ ......
´ÅÅÌ·ÖÇø¹¤¾ß--fdisk
fdisk /dev/hda
fdiskÃüÁîµÄ×ÓÃüÁî
-m ÏÔʾ°ïÖú£¨ÃüÁîÇåµ¥£©
-a ¼¤»î·ÖÇøµÄ¿ÉÒýµ¼±êÖ¾
-l Áгö¿ÉÑ¡µÄ·ÖÇøÀàÐÍ
-n Ìí¼ÓзÖÇø
-d ɾ³ýÒѾ´æÔڵķÖÇø
-p ÏÔʾ·ÖÇø±í
-t ¸Ä±ä·ÖÇøµÄÎļþÀàÐÍ
  ......
Linux·¢Ðа汾֮¼äµÄ²î±ðÆäʵºÜÉÙ£¬²î±ðÖ÷Òª±íÏÖÔÚϵͳ¹ÜÀíµÄÌØÉ«¹¤¾ßÒÔ¼°Èí¼þ°ü¹ÜÀí·½Ê½µÄ²»Í¬£¬³ý´ËÖ®Í⣬ûÓÐʲô´óµÄ²î±ð£» ±ÈÈçFedoraÈí¼þ°ü¹ÜÀí¹¤¾ßÊÇrpm£¬¶øSlackwareÊÇpkgtool »òinstallpkgµÈ£»
ÑÔ¹éÕý´«£¬ÎÒÃǽÓ×Å˵Îļþϵͳ×éÖ¯½á¹¹¡£
/ LinuxÎļþϵͳµÄÈë¿Ú£¬Ò²ÊÇ´¦ÓÚ×î¸ßÒ»¼¶µÄĿ¼£»
/bin »ù´¡ÏµÍ³ËùÐèÒªµ ......
ls -l|grep ^d ----Áгöµ±Ç°Ä¿Â¼ÏµÄÎļþ¼Ð
ls -l|grep ^d|grep "tmp" ----Áгöµ±Ç°Ä¿Â¼ÏÂÃ÷×Óº¬ÓÐ"tmp"µÄÎļþ¼Ð
for dir in `ls -l ~/dxy/|grep ^d | awk '{print $9}'` ---- awk '{print $9}' ,Ö»print Îļþ¼ÐµÄÃû×Ö
do
echo "==== $dir"
cd ~/dxy;cd $dir/
t=`ls -l|grep ^d|grep " ......