Python os.statvfs() Method
os.statvfs() Overview
The os.statvfs() method is used to return information about the file system of the file containing the file descriptor fd.
os.statvfs() Syntax
The statvfs() method syntax format is as follows.
os.statvfs([path])
os.statvfs() Parameters
- path – The path to the file.
os.statvfs() Return Value
The returned structure:
- f_bsize: file system block size
- f_frsize: stack size
- f_blocks: total number of file system data blocks
- f_bfree: number of available blocks
- f_bavail: number of blocks available to non-super users
- f_files: total number of file nodes
- f_ffree: number of available file nodes
- f_favail: the number of available file nodes for non-super users
- f_fsid: File system identification ID
- f_flag: mount flag
- f_namemax: maximum file length
os.statvfs() Example#1
The following example demonstrates the use of the statvfs() method.
import os
path = "/root/apidemos.py"
info = os.statvfs(path)
print(info)
# Get the file system block size
print("File system block size by info.f_bsize:", info.f_bsize)
# Get the number of free blocks in the file system
print("Number of free blocks by info.f_bfree:", info.f_bfree)
Output: