# TestFile#test\_statfs = Bad System Call on Solaris

**URL:** <https://www.ruby-forum.com/t/testfile-test-statfs-bad-system-call-on-solaris/240795>\
**Category:** Development\
**Created:** [April 30, 2014, 4:49pm UTC](https://www.ruby-forum.com/t/testfile-test-statfs-bad-system-call-on-solaris/240795 "2014-04-30T16:49:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [April 30, 2014, 4:49pm UTC](https://www.ruby-forum.com/t/testfile-test-statfs-bad-system-call-on-solaris/240795/1 "2014-04-30T16:49:17Z")

</div>

Issue #9788 has been updated by Takahiro K…

In message  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
on Wed, 30 Apr 2014 14:02:22 +0000,  
removed\_email\_address@domain.invalid wrote:

> という記述があり、現在のSolaris10では、削除はされていないものの、呼ん  
> でもSIGSYSかENOSYSを返してまともに動作しないようです。（または、未確  
> 認ですが、UFSなど昔からあるファイルシステムでのみ有効なのかもしれな  
> い？）  
> 過去のリリースでコンパイルしたバイナリでは動作するのかもしれません。

–  
神戸 隆博 / Takahiro K.

* * *

Bug #9788: TestFile#test\_statfs = Bad System Call on Solaris

> **[Bug #9788: TestFile#test\_statfs = Bad System Call on Solaris - Ruby master -...](https://bugs.ruby-lang.org/issues/9788#change-46409)**
>
> Redmine

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

* * *

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

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

```

以下のように、statfsメソッド内にて呼んでいるfstatfsシステムコールがSIGSYSを発生させているようです。

```auto
 % 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]

```

configureの関連する出力を抜き出すと以下になります。

```auto
 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

```

関連するコンパイル時のwarningを以下に示します。

```auto
 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.  
> \*/

という記述があり、現在のSolaris10では、削除はされていないものの、呼んでもSIGSYSかENOSYSを返してまともに動作しないようです。（または、未確認ですが、UFSなど昔からあるファイルシステムでのみ有効なのかもしれない？）

そして、現在の file.c では #if defined(HAVE\_FSTATFS) の場合には必ず fstatfs()  
を呼ぶため、上記のエラーが発生したようです。

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

```auto
 --- file.c (revision 45760)
 +++ file.c (working copy)
 @@ -92,9 +92,9 @@
  #endif
  #ifndef WITHOUT_STATFS
  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))
  #endif
  #endif

```
