Python3 os.statvfs() Method
Python3 OS File/Directory Methods
Overview
The os.statvfs()
method is used to return information about the filesystem containing the file associated with file descriptor fd
.
Syntax
The syntax for the statvfs() method is as follows:
os.statvfs([path])
Parameters
-
path -- The file path.
Return Value
The returned structure includes:
-
f_bsize: Filesystem block size
-
f_frsize: Fragment size
-
f_blocks: Total number of filesystem data blocks
-
f_bfree: Number of free blocks
-
f_bavail: Number of blocks available to non-superusers
-
f_files: Total number of file nodes
-
f_ffree: Number of free file nodes
-
f_favail: Number of file nodes available to non-superusers
-
f_fsid: Filesystem ID
-
f_flag: Mount flags
-
f_namemax: Maximum file length
Example
The following example demonstrates the use of the statvfs()
method:
#!/usr/bin/python3
import os, sys
# Display the statvfs information for the file "a1.py"
stinfo = os.statvfs('a1.py')
print (stinfo)
Output of the above program would be:
posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=1909350L, f_bfree=1491513L,
f_bavail=1394521L, f_files=971520L, f_ffree=883302L, f_fvail=883302L, f_flag=0,
f_namemax=255)