Quantcast
Channel: Number of free inodes on a partition containing a directory - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Mechanical snail for Number of free inodes on a partition containing a directory

$
0
0

This can be done using the statvfs system call. In Python (both 2 and 3), this can be accessed using os.statvfs. The call describes the filesystem containing the file/directory the path specifies.

So to get the number of free inodes, use

#import osos.statvfs('/some/directory').f_favail

Also, it's possible that some percentage of the inodes are reserved for the root user. If the script is running as root and you want to allow it to use the reserved inodes, use f_ffree instead of f_favail.


Viewing all articles
Browse latest Browse all 2

Trending Articles