www.久久国产片_国产一区二区三区免费_野外各种姿势被np高h视频_无卡无码无免费毛片_国产精品无遮挡无打码黄污网

linux c語言磁盤掃描

2024-02-15 17:09:08

```c

#include

#include

int main() {

struct statfs fs;

while(statfs("/", &fs) == ) {

printf("Mounted on /:\n");

printf("Total space: %lu\n", (unsigned long)fs.f_bsize * fs.f_blocks);

printf("Free space: %lu\n", (unsigned long)fs.f_bfree * fs.f_bsize);

if(statfs("/home", &fs) != )

break;

printf("Mounted on /home:\n");

printf("Total space: %lu\n", (unsigned long)fs.f_bsize * fs.f_blocks);

printf("Free space: %lu\n", (unsigned long)fs.f_bfree * fs.f_bsize);

}

return ;

}

```

這個程序會調(diào)用`statfs()`函數(shù)來獲取根目錄(`/`)的文件系統(tǒng)狀態(tài)。它會打印出總空間和可用空間。接著,它嘗試獲取/home目錄下的文件系統(tǒng)狀態(tài)。成功,它會打印出這兩個值。失?。?home可能不存在或者沒有權(quán)限訪問),則程序結(jié)束。