리눅스에서 df 프로그램과 유사하게 FileSystem 과 mount 된 폴더 리스트를 출력하는 소스코드

Here is an example of the source code for Linux outputting FileSystem and mounted folder lists as well as the df program: If you want the thread safe version, I recommend you to use getmntent_r.

#param<paramio.h>#mont<ment.h>intmain(intargc, char*argv[]){FILE*fd;structuret*fs; fd=setment(“/etc/mtab”, “r”); if(fd==NULL){printf(“setmenterror\n); if(fs=getment(fn_fn){fn!fn]{ftl]

After building the above source code, the results and df output are as follows:

$ g++-Wallgetmentt.cpp$./a.out [/dev/mapper/vg_master-lv_root][/][/boot][/dev/sda1][/boot][/dev/mapper/vg_master-lv_home]$df-h file system size available %/dev/mapper/vg_master-lv_root-tv_g.84%G/tmfG.8 %G.8 %G.8 %G/8 %G/8 %G/8 %G/8 %G/8 %G/g/

$ g++-Wallgetmentt.cpp$./a.out [/dev/mapper/vg_master-lv_root][/][/boot][/dev/sda1][/boot][/dev/mapper/vg_master-lv_home]$df-h file system size available %/dev/mapper/vg_master-lv_root-tv_g.84%G/tmfG.8 %G.8 %G.8 %G/8 %G/8 %G/8 %G/8 %G/8 %G/g/

$ g++-Wallgetmentt.cpp$./a.out [/dev/mapper/vg_master-lv_root][/][/boot][/dev/sda1][/boot][/dev/mapper/vg_master-lv_home]$df-h file system size available %/dev/mapper/vg_master-lv_root-tv_g.84%G/tmfG.8 %G.8 %G.8 %G/8 %G/8 %G/8 %G/8 %G/8 %G/g/

$ g++-Wallgetmentt.cpp$./a.out [/dev/mapper/vg_master-lv_root][/][/boot][/dev/sda1][/boot][/dev/mapper/vg_master-lv_home]$df-h file system size available %/dev/mapper/vg_master-lv_root-tv_g.84%G/tmfG.8 %G.8 %G.8 %G/8 %G/8 %G/8 %G/8 %G/8 %G/g/$ g++-Wallgetmentt.cpp$./a.out [/dev/mapper/vg_master-lv_root][/][/boot][/dev/sda1][/boot][/dev/mapper/vg_master-lv_home]$df-h file system size available %/dev/mapper/vg_master-lv_root-tv_g.84%G/tmfG.8 %G.8 %G.8 %G/8 %G/8 %G/8 %G/8 %G/8 %G/g/

error: Content is protected !!