statvfs

カレントディレクトリが属するファイルシステムの情報取得

#include < sys/statvfs.h >
#include < stdio.h >

int main()
{
    struct statvfs buf;
    
    if(statvfs(".", &buf) < 0){
        perror("statvfs");
        return 1;
    }
    
    printf(
    (sizeof(fsblkcnt_t)== 8)?(
           "f_bsize = %lu, f_frsize = %lu,\n"
            "f_blocks = %llu, f_bfree = %llu, f_bavail = %llu,\n"
                              "f_files = %llu, f_ffree = %llu, f_favail = %llu,\n"
                              "f_fsid = %lx, f_flag = %lx, f_namemax = %lu\n")
           : (
           "f_bsize = %lu, f_frsize = %lu, \n"
              "f_blocks = %lu, f_bfree = %lu, f_bavail = %lu, \n"
              "f_fsid = %lx, f_flag = %lx, f_namemax = %lu\n"),
           buf.f_bsize, buf.f_frsize,
           buf.f_blocks, buf.f_bfree, buf.f_bavail,
           buf.f_files, buf.f_ffree, buf.f_favail,
           buf.f_fsid, buf.f_flag, buf.f_namemax);
    return 0;
}