Python3 os.fstatvfs() Method
Python3 OS File/Directory Methods
Overview
The os.fstatvfs() method is used to return information about the file system containing the file associated with file descriptor fd. It is equivalent to statvfs() in Python 3.3.
Available on Unix.
The structure returned by the fstatvfs method:
f_bsize:File system block size
f_frsize:Fragment size
f_blocks:Total number of data blocks in the file system
f_bfree:Number of available blocks
f_bavail:Number of blocks available to non-superusers
f_files:Total number of file nodes
f_ffree:Number of available file nodes
f_favail:Number of available file nodes for non-superusers
f_fsid:File system ID
f_flag:Mount flags
f_namemax:Maximum file length
Syntax
fstatvfs()The method syntax is as follows:
os.fstatvfs(fd)
Parameters
fd-- file descriptor.
Return Value
Returns information about the file system containing the file associated with file descriptor fd.
Example
The following example demonstrates the use of the fstatvfs() method:
#!/usr/bin/python3
import os, sys
# 打开文件
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
# 获取元组
info = os.fstatvfs(fd)
print ("文件信息 :", info)
# 获取文件名最大长度
print ("文件名最大长度 :%d" % info.f_namemax)
# 获取可用块数
print ("可用块数 :%d" % info.f_bfree)
# 关闭文件
os.close( fd)
The output of executing the above program is:
文件信息 : (4096, 4096, 2621440L, 1113266L, 1113266L,
8929602L, 8764252L, 8764252L, 0, 255)
文件名最大长度 :255
可用块数 :1113266
Other Extensions