Monday, August 17, 2020

Python os.statvfs() Method with example



Hello dear readers! Welcome back to another section of our tutorial on Python. In this tutorial guide, we are going to be studying about the Os statvfs() method.

Python os statvfs() method carries out a statvfs system on the given path. Below is the list of members of statvfs structure -

  • f_bsize - preferred file system block size.
  • f_frsize - fundamental file system block size.
  • f_blocks - total number of blocks in the file system.
  • f_bfree - total number of free blocks
  • f_bavail - free blocks for non-root
  • f_files - inodes
  • f_ffree - free inodes
  • f_favail - free inodes for non-root
  • f_flag - system dependent.
  • f_namemax - the maximum filename length

Syntax

The following below is the syntax for Python Os statvfs() method -

os.statvfs( path )


Parameter Details

  • path - This is the path, whose statvfs information is needed.

Return Value

This returns information about a file associated with path.

Example

The following below is a simple example -

# !/usr/bin/python

import os, sys

# showing statvfs information of file "a1.py"
stinfo = os.statvfs('a1.py')

print stinfo

Output
When the above code is executed, it will produce the following result -

posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=1909350L, f_bfree=1491513L,
f_bavail=1394521L, f_files=971520L, f_ffree=883302L, f_fvail=883302L, f_flag=0,
f_namemax=255)


Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we are going to be studying about the Python OS symlink() Method.

Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.
Share:

0 comments:

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.