Easy Tutorial
❮ Ref Math Floor Ref Math Acos ❯

Python3 os.fstatvfs() Method

Python3 OS File/Directory Methods


Overview

The os.fstatvfs() method is used to return information about the filesystem containing the file associated with file descriptor fd. This is equivalent to statvfs() in Python 3.3.

Available on Unix.

The structure returned by the fstatvfs method includes:

Syntax

The syntax for the fstatvfs() method is as follows:

os.fstatvfs(fd)

Parameters

Return Value

Returns information about the filesystem 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

# Open a file
fd = os.open("foo.txt", os.O_RDWR|os.O_CREAT)

# Get the tuple
info = os.fstatvfs(fd)

print("File Info :", info)

# Get the maximum file name length
print("Maximum file name length :%d" % info.f_namemax)

# Get the number of free blocks
print("Number of free blocks :%d" % info.f_bfree)

# Close the file
os.close(fd)

Executing the above program outputs:

File Info : (4096, 4096, 2621440, 1113266, 1113266, 
             8929602, 8764252, 8764252, 0, 255)
Maximum file name length :255
Number of free blocks :1113266

Python3 OS File/Directory Methods

❮ Ref Math Floor Ref Math Acos ❯