Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python os.fstatvfs() method

Python os.fstatvfs() method

Python File methods Python OS file/directory methods


Overview

The os.fstatvfs() method returns information about the file system containing the file with file descriptor fd, similar to statvfs().

Available on Unix.

The structure returned by the fstatvfs method:

Syntax

The **fstatvfs()** method syntax is as follows:



os.fstatvfs(fd)

Parameters

Return Value

Returns information about the file system of the file containing the file descriptor fd.

Example

The following example demonstrates the use of the fstatvfs() method:



#!/usr/bin/python

# -*- coding: UTF-8 -*-



import os, sys



# Open file

fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )



# Get tuple

info = os.fstatvfs(fd)



print "文件信息 :", info



# Get maximum filename length

print "文件名最大长度 :%d" % info.f_namemax



# Get available blocks

print "可用块数 :%d" % info.f_bfree



# Close file

os.close( fd)

The output of the above program is:



文件信息 : (4096, 4096, 2621440L, 1113266L, 1113266L, 

             8929602L, 8764252L, 8764252L, 0, 255)

文件名最大长度 :255

可用块数 :1113266

Python File methods Python OS file/directory methods