Python os.fstatvfs() Examples
The following are 7
code examples of os.fstatvfs().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: reshaper.py From PyReshaper with Apache License 2.0 | 6 votes |
def _get_io_blocksize_MB_(pathname): """ Return the I/O blocksize for a given path (used to estimate IOPS) """ if isfile(pathname): fname = pathname fflag = O_RDONLY elif isdir(pathname): fname = join(pathname, '.bsize_test_file') fflag = O_CREAT else: return None fd = fdopen(fname, fflag) bsize = fstatvfs(fd).f_bsize fdclose(fd) return bsize #========================================================================= # create_reshaper factory function #=========================================================================
Example #2
Source File: utils.py From ray with Apache License 2.0 | 6 votes |
def get_shared_memory_bytes(): """Get the size of the shared memory file system. Returns: The size of the shared memory file system in bytes. """ # Make sure this is only called on Linux. assert sys.platform == "linux" or sys.platform == "linux2" shm_fd = os.open("/dev/shm", os.O_RDONLY) try: shm_fs_stats = os.fstatvfs(shm_fd) # The value shm_fs_stats.f_bsize is the block size and the # value shm_fs_stats.f_bavail is the number of available # blocks. shm_avail = shm_fs_stats.f_bsize * shm_fs_stats.f_bavail finally: os.close(shm_fd) return shm_avail
Example #3
Source File: PosixServer.py From pycopia with Apache License 2.0 | 5 votes |
def fstatvfs(self, handle): fo = self._files.get(handle, None) if fo: return os.fstatvfs(fo.fileno())
Example #4
Source File: fcheck.py From owasp-pysec with Apache License 2.0 | 5 votes |
def ino_check(dev, min_ino=MIN_INODES): return os.fstatvfs(dev).f_ffree >= int(min_ino)
Example #5
Source File: fcheck.py From owasp-pysec with Apache License 2.0 | 5 votes |
def space_check(dev, size): stdev = os.fstatvfs(dev) return size < stdev.f_bfree * stdev.f_bsize
Example #6
Source File: filepath.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def copyTo(self, destination): # XXX TODO: *thorough* audit and documentation of the exact desired # semantics of this code. Right now the behavior of existent # destination symlinks is convenient, and quite possibly correct, but # its security properties need to be explained. if self.isdir(): if not destination.exists(): destination.createDirectory() for child in self.children(): destChild = destination.child(child.basename()) child.copyTo(destChild) elif self.isfile(): writefile = destination.open('w') readfile = self.open() while 1: # XXX TODO: optionally use os.open, os.read and O_DIRECT and # use os.fstatvfs to determine chunk sizes and make # *****sure**** copy is page-atomic; the following is good # enough for 99.9% of everybody and won't take a week to audit # though. chunk = readfile.read(self._chunkSize) writefile.write(chunk) if len(chunk) < self._chunkSize: break writefile.close() readfile.close() else: # If you see the following message because you want to copy # symlinks, fifos, block devices, character devices, or unix # sockets, please feel free to add support to do sensible things in # reaction to those types! raise NotImplementedError( "Only copying of files and directories supported")
Example #7
Source File: utils.py From docket with Apache License 2.0 | 5 votes |
def free_space(f): """ return ( Bytes Free, Nodes free ) for the filesystem containing the provided file ex: free_space( open( '/tmp/nonexistant', 'w' ) ) -> ( bytes=123456789 , nodes=1234 ) """ vfs = os.fstatvfs(f.fileno()) return FreeSpace(bytes = vfs.f_bavail * vfs.f_frsize, nodes = vfs.f_favail)