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 referenced by 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 data blocks in the file system * **f_bfree:** Free blocks * **f_bavail:** Free blocks available to non-superuser * **f_files:** Total file nodes * **f_ffree:** Free file nodes * **f_favail:** Free file nodes available to non-superuser * **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 referenced by 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 free blocksprint "Free blocks :%d" % info.f_bfree # Close file os.close( fd) Executing the above program outputs the following result: File info : (4096, 4096, 2621440L, 1113266L, 1113266L, 8929602L, 8764252L, 8764252L, 0, 255)Maximum filename length :255Free blocks :1113266 [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Os FstatvfsOs Fpathconf β†’