class FuseFS::StatsHelper
Helper for filesystem accounting
Attributes
max_nodes[RW]
@return [Integer] maximum number of (virtual) inodes
max_space[RW]
@return [Integer] size of filesystem in bytes
nodes[R]
@return [Integer] used inodes (typically count of files and directories)
space[R]
@return [Integer] used space in bytes
strict[RW]
If set true, adjustments that cause space/nodes to exceed the maximums will raise ENOSPC (no space left on device) @return [Boolean]
Public Class Methods
new(max_space=nil,max_nodes=nil,strict=false)
click to toggle source
Public Instance Methods
adjust(delta_space,delta_nodes=0)
click to toggle source
Adjust accumlated statistics @param [Integer] delta_space change in {#space} usage @param [Integer] delta_nodes change in {#nodes} usage
@return [void] @raise [Errno::ENOSPC] if {#strict} and adjusted {#space}/{#nodes} would exceed {#max_space} or {#max_nodes}
# File lib/fuse/fusedir.rb, line 40 def adjust(delta_space,delta_nodes=0) @nodes += delta_nodes @space += delta_space raise Errno::ENOSPC if @strict && ( @nodes > @max_nodes || @space > @max_space ) end
to_statistics(free_space=nil,free_nodes=nil)
click to toggle source
@overload to_statistics
()
@return [Array<Integer>] in format expected by {FuseDir#statistics}
@overload to_statistics
(free_space,free_nodes)
Calculate total space so that free space remains fixed @param [Integer] free_space available space in bytes @param [Integer] free_nodes available (virtual) inodes @return [Array<Integer>] in format expected by {FuseDir#statistics}
# File lib/fuse/fusedir.rb, line 53 def to_statistics(free_space=nil,free_nodes=nil) total_space = free_space ? space + free_space : max_space total_nodes = free_nodes ? nodes + free_nodes : max_nodes [ @space, @nodes, total_space, total_nodes ] end