TestFile#test_statfs = Bad System Call on Solaris

Issue #9788 has been updated by Usaku NAKAMURA.

Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED,

Bug #9788: TestFile#test_statfs = Bad System Call on Solaris

  • Author: Naohisa G.
  • Status: Closed
  • Priority: Normal
  • Assignee:
  • Category:
  • Target version:
  • ruby -v: ruby 2.2.0dev (2014-04-30) [sparc64-solaris2.10]
  • Backport: 2.0.0: DONTNEED, 2.1: DONTNEED

Solaris 10 にて、make test-all が以下のエラーで中断します。(r45759 で確認。)

 TestFile#test_statfs = Bad System Call
 make: *** [yes-test-all] Error 140


 % truss ruby -e 'f = open("/bin/ls"); p f.statfs'
 /1:     open("/bin/ls", O_RDONLY)                       = 7
 /1:     fcntl(7, F_GETFD, 0x000001B6)                   = 0
 /1:     fcntl(7, F_SETFD, 0x00000001)                   = 0
 /1:     ioctl(7, TCGETA, 0xFFFFFFFF7FFFC91C)            Err#25 ENOTTY
 /1:     fstatfs()                                       Err#89 ENOSYS
 /1:         Received signal #12, SIGSYS [default]


 checking for struct statfs... no
 checking for struct statvfs... yes
 checking for struct statvfs.f_fstypename... no
 checking for fstatfs... yes
 checking for fstatvfs... yes


 cc -xO1 -xtarget=sparc64viiplus -m64 -DRUBY_EXPORT 
-I/usr/local/64/lib/libffi-3.0.10/include -I/usr/local/64/include   -I. 
-I.ext/include/sparc64-solaris2.10 -I./include -I. -o file.o -c file.c
 "file.c", line 1157: warning: implicit function declaration: fstatfs

Solaris 10 では、fstatfs(2) は存在しますが、/usr/include/sys/statfs.h
をincludeしないと定義が読み込まれません。また、/usr/include/sys/statfs.h 内には


  • Structure returned by statfs(2) and fstatfs(2).
  • This structure and associated system calls have been replaced
  • by statvfs(2) and fstatvfs(2) and will be removed from the system
  • in a near-future release.


そして、現在の file.c では #if defined(HAVE_FSTATFS) の場合には必ず fstatfs()

幸い、struct statfs は(sys/statfs.h
を明示的にincludeしない限り)定義されないため、以下のように、fstatfs と同時に struct statfs
の有無をチェックするようにしたら、エラーで make test-all が中断されることはなくなりました。ついでに、struct statvfs

 --- file.c  (revision 45760)
 +++ file.c  (working copy)
 @@ -92,9 +92,9 @@
  static VALUE rb_statfs_new(const statfs_t *st);
 -#if defined(HAVE_FSTATFS)
 +#if defined(HAVE_FSTATFS) && defined(HAVE_STRUCT_STATFS)
  #define FSTATFS(f, s) fstatfs((f), (s))
 -#elif defined(HAVE_FSTATVFS)
 +#elif defined(HAVE_FSTATVFS) && defined(HAVE_STRUCT_STATVFS)
  #define FSTATFS(f, s) fstatvfs((f), (s))