Python os.fstatvfs () method
Python OS file / directory methods
Outline
os.fstatvfs () method returns the file that contains the information for the file descriptor fd of the file system, similar to statvfs ().
Available on Unix.
fstatvfs method returns a structure:
f_bsize: file system block size
f_frsize: sub-stack size
f_blocks: The total number of file system data blocks
f_bfree: Available blocks
f_bavail: number of blocks available in non-root user
f_files: file structure Total points
f_ffree: available file nodes
f_favail: a non-root nodes available files
f_fsid: file system identifier ID
f_flag: Mount mark
f_namemax: maximum file size
grammar
fstatvfs () method syntax is as follows:
os.fstatvfs(fd)
parameter
fd - the file descriptor.
return value
Returns information file contains the file descriptor fd of the file system.
Examples
The following example demonstrates fstatvfs () method of use:
#!/usr/bin/python # -*- coding: UTF-8 -*- 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 above program output is:
文件信息 : (4096, 4096, 2621440L, 1113266L, 1113266L, 8929602L, 8764252L, 8764252L, 0, 255) 文件名最大长度 :255 可用块数 :1113266