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 fstatvfs() method.
The Python os fstatvfs() method returns data about the file system containing the file associated with the file descriptor fd. The following below is the list of structure that is returned by fstatvfs() Method -
The Python os fstatvfs() method returns data about the file system containing the file associated with the file descriptor fd. The following below is the list of structure that is returned by fstatvfs() Method -
- f_bsize - File system block size
- f_frsize - fragment size
- f_blocks - the size of fs in f_frsize units
- f_bfree - free blocks
- f_bavail - free blocks for non-root
- f_files - inodes
- f_ffree - free inodes
- f_favail - free inodes for non-root
- f_fsid - file system ID
- f_flag - mount flags.
- f_namemax - the maximum filename length
Syntax
The following below is the syntax for Python Os fstatvfs() method -
os.fstatvfs( fd )
RECOMMENDED POST: Python os.fstat() Method with example
Parameter Details
- fd - File descriptor for which system information is to be returned.
Return Value
This returns information about a file associated with the fd.
Example
The following below is a simple example -
#!/usr/bin/python import os, sys # Open a file fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT ) # Now get the touple info = os.fstatvfs(fd) print "File Info :", info # Now get maximum filename length print "Maximum filename length :%d" % info.f_namemax: # Now get free blocks print "Free blocks :%d" % info.f_bfree # Close opened file os.close( fd)
Output
When the above code is executed, it will produce the following result -
File Info : (4096, 4096, 2621440L, 1113266L, 1113266L, 8929602L, 8764252L, 8764252L, 0, 255) Maximum filename length :255 Free blocks :1113266
RECOMMENDED POST: Python os.fpathconf() Method with example
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 fsync() 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.
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.