Objects of class File::Statfs
encapsulate common status
information for filesystem. The information is recorded at the moment the
File::Statfs
object is created; changes made to the filesystem
after that point will not be reflected. File::Statfs
objects
are returned by IO#statfs
.
Create a File::Statfs object for the given file name (raising an exception if the file doesn’t exist).
static VALUE rb_statfs_init(VALUE obj, VALUE fname) { statfs_t st, *nst; rb_secure(2); FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (STATFS(StringValueCStr(fname), &st) == -1) { rb_sys_fail_path(fname); } if (DATA_PTR(obj)) { xfree(DATA_PTR(obj)); DATA_PTR(obj) = NULL; } nst = ALLOC(statfs_t); *nst = st; DATA_PTR(obj) = nst; return Qnil; }
Returns available blocks to non-super user in filesystem.
static VALUE statfs_bavail(VALUE self) { return LL2NUM(get_statfs(self)->f_bavail); }
Returns free blocks in filesystem.
static VALUE statfs_bfree(VALUE self) { return LL2NUM(get_statfs(self)->f_bfree); }
Returns total data bocks of filesystem.
static VALUE statfs_blocks(VALUE self) { return LL2NUM(get_statfs(self)->f_blocks); }
Returns block size in filesystem.
static VALUE statfs_bsize(VALUE self) { return LL2NUM(get_statfs(self)->f_bsize); }
Returns free nodes in filesystem.
static VALUE statfs_ffree(VALUE self) { return LL2NUM(get_statfs(self)->f_ffree); }
Returns total file nodes in filesystem.
static VALUE statfs_files(VALUE self) { return LL2NUM(get_statfs(self)->f_files); }
Returns name of filesystem.
f = File.new("testfile") s = f.statfs s.fstypename #=> "zfs"
static VALUE statfs_fstypename(VALUE self) { return rb_str_new_cstr(get_statfs(self)->f_fstypename); }
Returns total file nodes in filesystem.
f = File.new("testfile") s = f.statfs s.inspect #=> "" #=> "#<File::Statfs type=zfs, bsize=4096, blocks=900000/1000000/2000000, files=100000/200000>
blocks
are numbers of available/free/total blocks.
files
are numbers of free/total files.
static VALUE statfs_inspect(VALUE self) { statfs_t *st = get_statfs(self); return rb_sprintf("#<%"PRIsVALUE" " #ifdef HAVE_STRUCT_STATFS_T_F_TYPE "type=%ld" #endif #ifdef HAVE_STRUCT_STATFS_T_F_FSTYPENAME "(%s)" #endif ", bsize=%ld" ", blocks=%"PRI_LL_PREFIX"d/%"PRI_LL_PREFIX"d/%"PRI_LL_PREFIX"d" ", files=%"PRI_LL_PREFIX"d/%"PRI_LL_PREFIX"d" ">", rb_obj_class(self), #ifdef HAVE_STRUCT_STATFS_T_F_TYPE (long)st->f_type, #endif #ifdef HAVE_STRUCT_STATFS_T_F_FSTYPENAME st->f_fstypename, #endif (long)st->f_bsize, (LONG_LONG)st->f_bavail, (LONG_LONG)st->f_bfree, (LONG_LONG)st->f_blocks, (LONG_LONG)st->f_ffree, (LONG_LONG)st->f_files); }
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.