YouTip LogoYouTip

Os Fstatvfs

# Python2.x Python os.fstatvfs() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The os.fstatvfs() method is used to return information about the file system containing the file descriptor fd, similar to statvfs(). 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 free blocks * **f_bavail:** Number of free blocks available to non-super users * **f_files:** Total number of file nodes * **f_ffree:** Number of free file nodes * **f_favail:** Number of free file nodes available to non-super users * **f_fsid:** File system ID * **f_flag:** Mount flags * **f_namemax:** Maximum filename length ### Syntax The syntax for the **fstatvfs()** method is as follows: os.fstatvfs(fd) ### Parameters * **fd** -- The file descriptor. ### Return Value Returns information about the file system 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 "File info :", info # Get maximum filename lengthprint "Maximum filename length :%d" % info.f_namemax # Get number of free blocksprint "Number of free blocks :%d" % info.f_bfree # Close file os.close( fd) The output of executing the above program is: File info : (4096, 4096, 2621440L, 1113266L, 1113266L, 8929602L, 8764252L, 8764252L, 0, 255)Maximum filename length :255Number of free blocks :1113266 [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Os FtruncateOs Fstatvfs β†’