[前][次][番号順一覧][スレッド一覧]

ruby-changes:33961

From: naruse <ko1@a...>
Date: Thu, 22 May 2014 19:39:55 +0900 (JST)
Subject: [ruby-changes:33961] naruse:r46042 (trunk): revert File::Statfs [Feature #9772]

naruse	2014-05-22 19:39:48 +0900 (Thu, 22 May 2014)

  New Revision: 46042

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46042

  Log:
    revert File::Statfs [Feature #9772]

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/configure.in
    trunk/file.c
    trunk/include/ruby/win32.h
    trunk/test/ruby/test_file.rb
    trunk/test/ruby/test_io.rb
    trunk/win32/Makefile.sub
    trunk/win32/win32.c
Index: include/ruby/win32.h
===================================================================
--- include/ruby/win32.h	(revision 46041)
+++ include/ruby/win32.h	(revision 46042)
@@ -262,20 +262,6 @@ struct ifaddrs { https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L262
 #define IFF_POINTOPOINT IFF_POINTTOPOINT
 #endif
 
-/* for ustatfs() */
-typedef uint32_t fsid_t;
-struct statfs {
-    uint32_t f_type;
-    uint64_t f_bsize;
-    uint64_t f_blocks;
-    uint64_t f_bfree;
-    int64_t f_bavail;
-    uint64_t f_files;
-    uint64_t f_ffree;
-    fsid_t f_fsid;
-    char f_fstypename[MAX_PATH];
-};
-
 extern DWORD  rb_w32_osid(void);
 extern rb_pid_t  rb_w32_pipe_exec(const char *, const char *, int, int *, int *);
 extern int    flock(int fd, int oper);
@@ -361,7 +347,6 @@ extern int rb_w32_uaccess(const char *, https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L347
 extern char rb_w32_fd_is_text(int);
 extern int rb_w32_fstati64(int, struct stati64 *);
 extern int rb_w32_dup2(int, int);
-extern int ustatfs(const char *, struct statfs *);
 
 #ifdef __BORLANDC__
 extern off_t _lseeki64(int, off_t, int);
Index: configure.in
===================================================================
--- configure.in	(revision 46041)
+++ configure.in	(revision 46042)
@@ -1068,8 +1068,6 @@ main() https://github.com/ruby/ruby/blob/trunk/configure.in#L1068
                 ac_cv_func_clock_gettime=yes
                 ac_cv_func_clock_getres=yes
 		ac_cv_func_malloc_usable_size=no
-		ac_cv_type_struct_statfs=yes
-		ac_cv_member_struct_statfs_f_fstypename=yes
 		{ test "$target_cpu" = x64 && ac_cv_func___builtin_setjmp=no; }
 		AC_CHECK_TYPE([NET_LUID], [], [],
 			      [@%:@include <windows.h>
@@ -1093,7 +1091,6 @@ main() https://github.com/ruby/ruby/blob/trunk/configure.in#L1091
 		ac_cv_func_close=no
 		],
 [netbsd*], [	LIBS="-lm $LIBS"
-		ac_cv_func_fstatfs=no
 		],
 [dragonfly*], [	LIBS="-lm $LIBS"
 		# isinf() and isnan() are macros on DragonFly.
@@ -1133,8 +1130,6 @@ AC_CHECK_HEADERS( \ https://github.com/ruby/ruby/blob/trunk/configure.in#L1130
   sys/select.h \
   sys/time.h \
   sys/times.h \
-  sys/param.h \
-  sys/vfs.h \
   syscall.h \
   pwd.h \
   grp.h \
@@ -1163,9 +1158,6 @@ AC_CHECK_HEADERS( \ https://github.com/ruby/ruby/blob/trunk/configure.in#L1158
   malloc/malloc.h \
   setjmpex.h
 )
-AC_CHECK_HEADERS(sys/mount.h, [], [], [@%:@ifdef HAVE_SYS_PARAM_H
-@%:@ include <sys/param.h>
-@%:@endif])
 
 AC_ARG_WITH([gmp],
   [AS_HELP_STRING([--without-gmp],
@@ -1743,33 +1735,6 @@ AC_CHECK_TYPES([struct timezone], [], [] https://github.com/ruby/ruby/blob/trunk/configure.in#L1735
 @%:@ include <sys/time.h>
 @%:@endif])
 
-AC_CHECK_TYPES([struct statfs], [], [], [@%:@ifdef HAVE_SYS_PARAM_H
-@%:@ include <sys/param.h>
-@%:@endif
-@%:@ifdef HAVE_SYS_MOUNT_H
-@%:@ include <sys/mount.h>
-@%:@endif
-@%:@ifdef HAVE_SYS_VFS_H
-@%:@ include <sys/vfs.h>
-@%:@endif])
-AS_IF([test "$ac_cv_type_struct_statfs" = yes], [
-AC_CHECK_MEMBERS([struct statfs.f_type, struct statfs.f_fstypename], [], [], [@%:@ifdef HAVE_SYS_PARAM_H
-@%:@ include <sys/param.h>
-@%:@endif
-@%:@ifdef HAVE_SYS_MOUNT_H
-@%:@ include <sys/mount.h>
-@%:@endif
-@%:@ifdef HAVE_SYS_VFS_H
-@%:@ include <sys/vfs.h>
-@%:@endif])
-])
-# AIX, HP-UX, NetBSD, Solaris
-AC_CHECK_TYPES([struct statvfs], [], [], [@%:@ include <sys/statvfs.h>])
-# NetBSD
-AC_CHECK_MEMBERS([struct statvfs.f_fstypename], [], [], [@%:@ include <sys/statvfs.h>])
-# AIX, HP-UX, Solaris
-AC_CHECK_MEMBERS([struct statvfs.f_basetype], [], [], [@%:@ include <sys/statvfs.h>])
-
 AC_CHECK_TYPES([clockid_t], [], [], [@%:@ifdef HAVE_TIME_H
 @%:@ include <time.h>
 @%:@endif
@@ -1995,8 +1960,6 @@ AC_CHECK_FUNCS(fcntl) https://github.com/ruby/ruby/blob/trunk/configure.in#L1960
 AC_CHECK_FUNCS(fdatasync)
 AC_CHECK_FUNCS(fmod)
 AC_CHECK_FUNCS(fork)
-AC_CHECK_FUNCS(fstatfs)
-AC_CHECK_FUNCS(fstatvfs)
 AC_CHECK_FUNCS(fsync)
 AC_CHECK_FUNCS(ftruncate)
 AC_CHECK_FUNCS(ftruncate64)		# used for Win32 platform
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46041)
+++ ChangeLog	(revision 46042)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May 22 19:38:14 2014  NARUSE, Yui  <naruse@r...>
+
+	* file.c: remove IO::Statfs because of reject. [Feature #9772]
+
 Thu May 22 14:02:13 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* enc/jis/props.kwd: constify character property tables of JIS
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 46041)
+++ win32/win32.c	(revision 46042)
@@ -5865,55 +5865,6 @@ rb_w32_pipe(int fds[2]) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5865
 }
 
 /* License: Ruby's */
-int
-ustatfs(const char *path, struct statfs *buf)
-{
-    WCHAR *wpath = utf8_to_wstr(path, NULL);
-    WCHAR root[MAX_PATH], system[8];
-    DWORD serial, spc, bps, unused, total;
-    char *tmp;
-    WINBASEAPI BOOL WINAPI GetVolumePathNameW(LPCWSTR, LPWSTR, DWORD);
-
-    if (!wpath) {
-	return -1;
-    }
-
-    if (!GetVolumePathNameW(wpath, root, sizeof(root) / sizeof(WCHAR))) {
-	free(wpath);
-	errno = map_errno(GetLastError());
-	return -1;
-    }
-    free(wpath);
-
-    if (!GetVolumeInformationW(root, NULL, 0, &serial, NULL, NULL,
-			       system, sizeof(system) / sizeof(WCHAR))) {
-	errno = map_errno(GetLastError());
-	return -1;
-    }
-
-    if (!GetDiskFreeSpaceW(root, &spc, &bps, &unused, &total)) {
-	errno = map_errno(GetLastError());
-	return -1;
-    }
-
-    tmp = wstr_to_filecp(system, NULL);
-    if (!tmp) {
-	return -1;
-    }
-    strlcpy(buf->f_fstypename, tmp, sizeof(buf->f_fstypename));
-    free(tmp);
-
-    buf->f_type = 0;
-    buf->f_bsize = (uint64_t)spc * bps;
-    buf->f_blocks = total;
-    buf->f_bfree = buf->f_bavail = unused;
-    buf->f_files = buf->f_ffree = 0;
-    buf->f_fsid = serial;
-
-    return 0;
-}
-
-/* License: Ruby's */
 static int
 console_emulator_p(void)
 {
Index: win32/Makefile.sub
===================================================================
--- win32/Makefile.sub	(revision 46041)
+++ win32/Makefile.sub	(revision 46042)
@@ -700,8 +700,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/ https://github.com/ruby/ruby/blob/trunk/win32/Makefile.sub#L700
 #define SETPGRP_VOID 1
 #define RSHIFT(x,y) ((x)>>(int)y)
 #define HAVE_RB_FD_INIT 1
-#define HAVE_STRUCT_STATFS 1
-#define HAVE_STRUCT_STATFS_F_FSTYPENAME 1
 #define RUBY_SETJMP(env) _setjmp(env)
 #define RUBY_LONGJMP(env,val) longjmp(env,val)
 #define RUBY_JMP_BUF jmp_buf
Index: NEWS
===================================================================
--- NEWS	(revision 46041)
+++ NEWS	(revision 46042)
@@ -22,18 +22,11 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L22
     * min, min_by, max and max_by supports optional argument to return
       multiple elements.
 
-* File
-  * new class File::Statfs to hold filesystem information. (experimental)
-
 * Float
   * New methods:
     * Float#next_float
     * Float#prev_float
 
-* IO
-  * New methods
-    * IO#statfs returns filesystem information as File::Statfs. (experimental)
-
 * Process
   * Extended method:
     * Process execution methods such as Process.spawn opens the file in write
Index: test/ruby/test_file.rb
===================================================================
--- test/ruby/test_file.rb	(revision 46041)
+++ test/ruby/test_file.rb	(revision 46042)
@@ -383,31 +383,4 @@ class TestFile < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L383
       assert_file.not_exist?(path)
     end
   end
-
-  def test_statfs
-    skip "not implemented" unless $stdout.respond_to?(:statfs)
-    open(__FILE__) do |f|
-      st = f.statfs
-      assert_kind_of File::Statfs, st
-      begin
-        assert_kind_of Integer, st.type
-      rescue NotImplementedError
-      end
-      assert_kind_of Integer, st.bsize
-      assert_kind_of Integer, st.blocks
-      assert_kind_of Integer, st.bfree
-      assert_kind_of Integer, st.bavail
-      assert_kind_of Integer, st.files
-      assert_kind_of Integer, st.ffree
-      begin
-        assert_kind_of String, st.fstypename
-      rescue NotImplementedError
-      end
-      s = st.inspect
-      assert_match(/\A\#<File::Statfs\b.*>\z/, s)
-      assert_match(/\bbsize=\d+\b/, s)
-      assert_match(/\bblocks=(?:\d+[,>\/])+\b/, s)
-      assert_match(/\bfiles=(?:\d+[,>\/])+\b/, s)
-    end
-  end
 end
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 46041)
+++ test/ruby/test_io.rb	(revision 46042)
@@ -1668,24 +1668,22 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1668
 
   def can_seek_data(f)
     if /linux/ =~ RUBY_PLATFORM
-      # include/uapi/linux/magic.h
-      case f.statfs.type
-      when 0x9123683E # BTRFS_SUPER_MAGIC
-      when 0x7461636f # OCFS2_SUPER_MAGIC
-      when 0xEF53 # EXT2_SUPER_MAGIC EXT3_SUPER_MAGIC EXT4_SUPER_MAGIC
-        return false if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) < 0
-        # ext3's timestamp resolution is seconds
-        s = f.stat
-        s.mtime.nsec != 0 || s.atime.nsec != 0 || s.ctime.nsec != 0
-      when 0x58465342 # XFS_SUPER_MAGIC
-        return false if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,5]) < 0
-      when 0x01021994 # TMPFS_MAGIC
-        return false if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) < 0
-      else
-        return false
+      require "-test-/file"
+      # lseek(2)
+      case Bug::File::Fs.fsname(f.path)
+      when "btrfs"
+        return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,1]) >= 0
+      when "ocfs"
+        return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,2]) >= 0
+      when "xfs"
+        return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,5]) >= 0
+      when "ext4"
+        return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) >= 0
+      when "tmpfs"
+        return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) >= 0
       end
     end
-    true
+    false
   end
 
   def test_seek
@@ -1715,9 +1713,7 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1713
         open(t.path) { |f|
           break unless can_seek_data(f)
           assert_equal("foo\n", f.gets)
-          assert_nothing_raised(proc {"cannot SEEK_DATA on FS(0x%X)" % f.statfs.type}) do
-            f.seek(0, IO::SEEK_DATA)
-          end
+          f.seek(0, IO::SEEK_DATA)
           assert_equal("foo\nbar\nbaz\n", f.read)
         }
         open(t.path, 'r+') { |f|
@@ -1765,9 +1761,7 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1761
         open(t.path) { |f|
           break unless can_seek_data(f)
           assert_equal("foo\n", f.gets)
-          assert_nothing_raised(proc {"cannot SEEK_DATA on FS(0x%X)" % f.statfs.type}) do
-            f.seek(0, :DATA)
-          end
+          f.seek(0, :DATA)
           assert_equal("foo\nbar\nbaz\n", f.read)
         }
         open(t.path, 'r+') { |f|
Index: file.c
===================================================================
--- file.c	(revision 46041)
+++ file.c	(revision 46042)
@@ -63,46 +63,6 @@ int flock(int, int); https://github.com/ruby/ruby/blob/trunk/file.c#L63
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-#ifdef HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
-#ifdef HAVE_STRUCT_STATFS
-typedef struct statfs statfs_t;
-# define STATFS(f, s) statfs((f), (s))
-# ifdef HAVE_FSTATFS
-#  define FSTATFS(f, s) fstatfs((f), (s))
-# endif
-# ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME
-#  define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
-# endif
-# ifdef HAVE_STRUCT_STATFS_F_TYPE
-#  define HAVE_STRUCT_STATFS_T_F_TYPE 1
-# endif
-#elif defined(HAVE_STRUCT_STATVFS)
-typedef struct statvfs statfs_t;
-# define STATFS(f, s) statvfs((f), (s))
-# ifdef HAVE_FSTATVFS
-#  define FSTATFS(f, s) fstatvfs((f), (s))
-# endif
-# if defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME) /* NetBSD */
-#  define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
-# elif defined(HAVE_STRUCT_STATVFS_F_BASETYPE) /* AIX, HP-UX, Solaris */
-#  define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
-#  define f_fstypename f_basetype
-# endif
-# ifdef HAVE_STRUCT_STATVFS_F_TYPE
-#  define HAVE_STRUCT_STATFS_T_F_TYPE 1
-# endif
-#else
-# define WITHOUT_STATFS
-#endif
-#ifndef WITHOUT_STATFS
-static VALUE rb_statfs_new(const statfs_t *st);
-#endif
-
 #if defined(__native_client__) && defined(NACL_NEWLIB)
 # include "nacl/utime.h"
 # include "nacl/stat.h"
@@ -145,9 +105,6 @@ static VALUE rb_statfs_new(const statfs_ https://github.com/ruby/ruby/blob/trunk/file.c#L105
 #define unlink(p)	rb_w32_uunlink(p)
 #undef rename
 #define rename(f, t)	rb_w32_urename((f), (t))
-#undef STATFS
-#define STATFS(f, s)	ustatfs((f), (s))
-#define HAVE_STATFS 1
 #else
 #define STAT(p, s)	stat((p), (s))
 #endif
@@ -182,7 +139,6 @@ be_fchown(int fd, uid_t owner, gid_t gro https://github.com/ruby/ruby/blob/trunk/file.c#L139
 VALUE rb_cFile;
 VALUE rb_mFileTest;
 VALUE rb_cStat;
-VALUE rb_cStatfs;
 
 #define insecure_obj_p(obj, level) ((level) >= 4 || ((level) > 0 && OBJ_TAINTED(obj)))
 
@@ -1130,48 +1086,6 @@ rb_file_lstat(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L1086
 #endif
 }
 
-#ifndef WITHOUT_STATFS
-/*
- *  call-seq:
- *     ios.statfs    -> statfs
- *
- *  Returns filesystem status information for <em>ios</em> as an object of type
- *  <code>File::Statfs</code>.
- *
- *     f = File.new("testfile")
- *     s = f.statfs
- *     s.mode   #=> "100644"
- *     s.bsize         #=> 512
- *     s.fstypename    #=> "zfs"
- *
- */
-
-static VALUE
-rb_io_statfs(VALUE obj)
-{
-    rb_io_t *fptr;
-    statfs_t st;
-#ifndef FSTATFS
-    VALUE path;
-#endif
-    int ret;
-
-    GetOpenFile(obj, fptr);
-#ifdef FSTATFS
-    ret = FSTATFS(fptr->fd, &st);
-#else
-    path = rb_str_encode_ospath(fptr->pathv);
-    ret = STATFS(StringValueCStr(path), &st);
-#endif
-    if (ret == -1) {
-	rb_sys_fail_path(fptr->pathv);
-    }
-    return rb_statfs_new(&st);
-}
-#else
-#define rb_io_statfs rb_f_notimplement
-#endif
-
 static int
 rb_group_member(GETGROUPS_T gid)
 {
@@ -5348,288 +5262,6 @@ rb_stat_sticky(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L5262
     return Qfalse;
 }
 
-#ifndef WITHOUT_STATFS
-/* File::Statfs */
-
-static size_t
-statfs_memsize(const void *p)
-{
-    return p ? sizeof(statfs_t) : 0;
-}
-
-static const rb_data_type_t statfs_data_type = {
-    "statfs",
-    {NULL, RUBY_TYPED_DEFAULT_FREE, statfs_memsize,},
-    NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static VALUE
-statfs_new_0(VALUE klass, const statfs_t *st)
-{
-    statfs_t *nst = 0;
-
-    if (st) {
-	nst = ALLOC(statfs_t);
-	*nst = *st;
-    }
-    return TypedData_Wrap_Struct(klass, &statfs_data_type, nst);
-}
-
-static VALUE
-rb_statfs_new(const statfs_t *st)
-{
-    return statfs_new_0(rb_cStatfs, st);
-}
-
-static statfs_t*
-get_statfs(VALUE self)
-{
-    statfs_t* st;
-    TypedData_Get_Struct(self, statfs_t, &statfs_data_type, st);
-    if (!st) rb_raise(rb_eTypeError, "uninitialized File::Statfs");
-    return st;
-}
-
-/*
- *  Document-class: File::Statfs
- *
- *  Objects of class <code>File::Statfs</code> encapsulate common status
- *  information for filesystem. The information is
- *  recorded at the moment the <code>File::Statfs</code> object is
- *  created; changes made to the filesystem after that point will not be
- *  reflected. <code>File::Statfs</code> objects are returned by
- *  <code>IO#statfs</code>.
- */
-
-static VALUE
-rb_statfs_s_alloc(VALUE klass)
-{
-    return statfs_new_0(klass, 0);
-}
-
-/*
- * call-seq:
- *
- *   File::Statfs.new(file_name)  -> 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;
-}
-
-/* :nodoc: */
-static VALUE
-rb_statfs_init_copy(VALUE copy, VALUE orig)
-{
-    statfs_t *nst;
-
-    if (!OBJ_INIT_COPY(copy, orig)) return copy;
-    if (DATA_PTR(copy)) {
-	xfree(DATA_PTR(copy));
-	DATA_PTR(copy) = 0;
-    }
-    if (DATA_PTR(orig)) {
-	nst = ALLOC(statfs_t);
-	*nst = *(statfs_t*)DATA_PTR(orig);
-	DATA_PTR(copy) = nst;
-    }
-
-    return copy;
-}
-
-#ifdef HAVE_STRUCT_STATFS_T_F_TYPE
-/*
- *  call-seq:
- *     st.type    -> fixnum
- *
- *  Returns type of filesystem.
- *
- *     f = File.new("testfile")
- *     s = f.statfs
- *     "%d" % s.type   #=> 17
- *
- */
-
-static VALUE
-statfs_type(VALUE self)
-{
-    return LL2NUM(get_statfs(self)->f_type);
-}
-#else
-#define statfs_type rb_f_notimplement
-#endif
-
-/*
- *  call-seq:
- *     st.bsize    -> integer
- *
- *  Returns block size in filesystem.
- *
- */
-
-static VALUE
-statfs_bsize(VALUE self)
-{
-    return LL2NUM(get_statfs(self)->f_bsize);
-}
-
-/*
- *  call-seq:
- *     st.blocks    -> integer
- *
- *  Returns total data bocks of filesystem.
- *
- */
-
-static VALUE
-statfs_blocks(VALUE self)
-{
-    return LL2NUM(get_statfs(self)->f_blocks);
-}
-
-/*
- *  call-seq:
- *     st.bfree    -> integer
- *
- *  Returns free blocks in filesystem.
- *
- */
-
-static VALUE
-statfs_bfree(VALUE self)
-{
-    return LL2NUM(get_statfs(self)->f_bfree);
-}
-
-/*
- *  call-seq:
- *     st.bavail    -> integer
- *
- *  Returns available blocks to non-super user in filesystem.
- *
- */
-
-static VALUE
-statfs_bavail(VALUE self)
-{
-    return LL2NUM(get_statfs(self)->f_bavail);
-}
-
-/*
- *  call-seq:
- *     st.files    -> integer
- *
- *  Returns total file nodes in filesystem.
- *
- */
-
-static VALUE
-statfs_files(VALUE self)
-{
-    return LL2NUM(get_statfs(self)->f_files);
-}
-
-/*
- *  call-seq:
- *     st.ffree    -> integer
- *
- *  Returns free nodes in filesystem.
- *
- */
-
-static VALUE
-statfs_ffree(VALUE self)
-{
-    return LL2NUM(get_statfs(self)->f_ffree);
-}
-
-#ifdef HAVE_STRUCT_STATFS_T_F_FSTYPENAME
-/*
- *  call-seq:
- *     st.fstypename    -> string
- *
- *  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);
-}
-#else
-#define statfs_fstypename rb_f_notimplement
-#endif
-
-/*
- *  call-seq:
- *     st.inspect    -> string
- *
- *  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 (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]