https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1711330511
2014-04-24T09:13:57Z
Ruby Issue Tracking System
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46299
2014-04-24T09:13:57Z
akr (Akira Tanaka)
akr@fsij.org
<ul></ul><p>ruby-core:62137 で Eric Wong も尋ねていますが、なぜ POSIX で定義されている statvfs じゃなくて、statfs なのか、というのは私も最初に疑問に思いました。</p>
<p>理由を参照できる形で残しておくのは重要だと思うので、説明を書いていただけないでしょうか。</p>
<p>そして、その理由があったとしても、API としては statvfs という名前にして、<br>
statfs が存在する環境ではより多くの情報がなぜか取得できるとした方がいいのではないかという気がします。<br>
(理由がないのであれば、もちろん statvfs にすべきだと思います。)</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46300
2014-04-24T12:29:32Z
znz (Kazuhiro NISHIYAMA)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/46300/diff?detail_id=33405">diff</a>)</li></ul>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46304
2014-04-24T21:23:26Z
kosaki (Motohiro KOSAKI)
kosaki.motohiro@gmail.com
<ul></ul><p>POSIX的には、statvfsで取れるのは以下のメンバで他はoptional。つまり一番欲しいfs typeが<br>
取れないわけです。<br>
なので、statvfsはmisleadingだと思います。</p>
<p>それよりもstatfsで有益な情報がとれるOSは結局どのぐらいあるのか。が焦点ではないかと思います。<br>
プラットフォーム依存なのは最初からわかっているんだし。</p>
<p>unsigned long f_bsize File system block size.<br>
unsigned long f_frsize Fundamental file system block size.<br>
fsblkcnt_t f_blocks Total number of blocks on file system in units of f_frsize.<br>
fsblkcnt_t f_bfree Total number of free blocks.<br>
fsblkcnt_t f_bavail Number of free blocks available to<br>
non-privileged process.<br>
fsfilcnt_t f_files Total number of file serial numbers.<br>
fsfilcnt_t f_ffree Total number of free file serial numbers.<br>
fsfilcnt_t f_favail Number of file serial numbers available to<br>
non-privileged process.<br>
unsigned long f_fsid File system ID.<br>
unsigned long f_flag Bit mask of f_flag values.<br>
unsigned long f_namemax Maximum filename length.</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46305
2014-04-24T23:11:20Z
akr (Akira Tanaka)
akr@fsij.org
<ul></ul><p>こういうときは先人の知恵ということで探してみると coreutils の src/stat.h になにかそれっぽいコメントがありました。</p>
<pre><code> 212 /* Return the type of the specified file system.
213 Some systems have statfvs.f_basetype[FSTYPSZ] (AIX, HP-UX, and Solaris).
214 Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0).
215 Others have statfs.f_fstypename[MFSNAMELEN] (NetBSD 1.5.2).
216 Still others have neither and have to get by with f_type (GNU/Linux).
217 But f_type may only exist in statfs (Cygwin). */
</code></pre>
<p><a href="http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/stat.c;h=7d43eb55510372e18cc1129db269586710d28229;hb=HEAD#l212" class="external">http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/stat.c;h=7d43eb55510372e18cc1129db269586710d28229;hb=HEAD#l212</a></p>
<p>仮に proprietary なのは気にしないとしても、NetBSD はどうなのかなぁ。</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46317
2014-04-25T18:40:01Z
kosaki (Motohiro KOSAKI)
kosaki.motohiro@gmail.com
<ul></ul><p>2014-04-24 19:11 GMT-04:00 <a href="mailto:akr@fsij.org" class="email">akr@fsij.org</a>:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: IO#statfs and File::Statfs (Rejected)" href="https://bugs.ruby-lang.org/issues/9772">#9772</a> has been updated by Akira Tanaka.</p>
<p>こういうときは先人の知恵ということで探してみると coreutils の src/stat.h になにかそれっぽいコメントがありました。</p>
<pre><code> 212 /* Return the type of the specified file system.
213 Some systems have statfvs.f_basetype[FSTYPSZ] (AIX, HP-UX, and Solaris).
214 Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0).
215 Others have statfs.f_fstypename[MFSNAMELEN] (NetBSD 1.5.2).
216 Still others have neither and have to get by with f_type (GNU/Linux).
217 But f_type may only exist in statfs (Cygwin). */
</code></pre>
<p><a href="http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/stat.c;h=7d43eb55510372e18cc1129db269586710d28229;hb=HEAD#l212" class="external">http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/stat.c;h=7d43eb55510372e18cc1129db269586710d28229;hb=HEAD#l212</a></p>
<p>仮に proprietary なのは気にしないとしても、NetBSD はどうなのかなぁ。</p>
</blockquote>
<p>ああ、statvfsにメンバ追加のほうが世の中で主流なのですね。じゃあ、わたしの主張は取り下げます</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46330
2014-04-26T09:48:40Z
taca (Takahiro Kambe)
taca@back-street.net
<ul></ul><p>In message <a href="mailto:redmine.journal-46305.20140424231120.f745bb8a50ac0750@ruby-lang.org" class="email">redmine.journal-46305.20140424231120.f745bb8a50ac0750@ruby-lang.org</a><br>
on Thu, 24 Apr 2014 23:11:20 +0000,<br>
<a href="mailto:akr@fsij.org" class="email">akr@fsij.org</a> wrote:</p>
<blockquote>
<p>214 Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0).<br>
215 Others have statfs.f_fstypename[MFSNAMELEN] (NetBSD 1.5.2).<br>
216 Still others have neither and have to get by with f_type (GNU/Linux).<br>
217 But f_type may only exist in statfs (Cygwin). */</p>
<pre><code>
http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/stat.c;h=7d43eb55510372e18cc1129db269586710d28229;hb=HEAD#l212
仮に proprietary なのは気にしないとしても、NetBSD はどうなのかなぁ。
</code></pre>
</blockquote>
<p>「NetBSD はどうなのかなぁ。」とは、どのような意味でしょう??</p>
<p>--<br>
神戸 隆博 / Takahiro Kambe</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46331
2014-04-26T14:21:25Z
akr (Akira Tanaka)
akr@fsij.org
<ul></ul><p>Takahiro Kambe wrote:</p>
<blockquote>
<p>「NetBSD はどうなのかなぁ。」とは、どのような意味でしょう??</p>
</blockquote>
<p>NetBSD で動かないのはよろしくないんじゃないか、という意味です。</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46390
2014-04-30T06:27:35Z
naruse (Yui NARUSE)
naruse@airemix.jp
<ul></ul><p>Akira Tanaka wrote:</p>
<blockquote>
<p>ruby-core:62137 で Eric Wong も尋ねていますが、なぜ POSIX で定義されている statvfs じゃなくて、statfs なのか、というのは私も最初に疑問に思いました。</p>
<p>理由を参照できる形で残しておくのは重要だと思うので、説明を書いていただけないでしょうか。</p>
</blockquote>
<p>statfs では f_type の類がとれないからですね。<a href="https://blade.ruby-lang.org/ruby-core/62150">[ruby-core:62150]</a></p>
<blockquote>
<p>そして、その理由があったとしても、API としては statvfs という名前にして、<br>
statfs が存在する環境ではより多くの情報がなぜか取得できるとした方がいいのではないかという気がします。<br>
(理由がないのであれば、もちろん statvfs にすべきだと思います。)</p>
</blockquote>
<p>うーん、ファイルシステムの情報であって特別VFSの情報ってわけでもないしなぁ、<br>
と思いつつPythonさんを見るとos.statvfsなんですね。<br>
<a href="https://docs.python.org/3/library/os.html?highlight=statvfs#os.statvfs" class="external">https://docs.python.org/3/library/os.html?highlight=statvfs#os.statvfs</a></p>
<p>Motohiro KOSAKI wrote:</p>
<blockquote>
<p>ああ、statvfsにメンバ追加のほうが世の中で主流なのですね。じゃあ、わたしの主張は取り下げます</p>
</blockquote>
<p>statfs は残しつつ、statvfsでは標準のメンバしか出さないLinux, FreeBSD, Darwin, OpenBSDと、<br>
statvfs に寄せた上で独自拡張するプロプライエタリ(と、NetBSD)って読むのが正しいんじゃないですかね。</p>
<p>なお、NetBSDとOpenBSDでは動くようにした…はずです。</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46407
2014-04-30T14:04:07Z
ngoto (Naohisa Goto)
ngotogenome@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/9788">Bug #9788</a>: TestFile#test_statfs = Bad System Call on Solaris </i> added</li></ul>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46408
2014-04-30T14:38:28Z
taca (Takahiro Kambe)
taca@back-street.net
<ul></ul><p>In message <a href="mailto:redmine.journal-46331.20140426142125.1b2e3962cfe9fb0b@ruby-lang.org" class="email">redmine.journal-46331.20140426142125.1b2e3962cfe9fb0b@ruby-lang.org</a><br>
on Sat, 26 Apr 2014 14:21:25 +0000,<br>
<a href="mailto:akr@fsij.org" class="email">akr@fsij.org</a> wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: IO#statfs and File::Statfs (Rejected)" href="https://bugs.ruby-lang.org/issues/9772">#9772</a> has been updated by Akira Tanaka.</p>
<p>Takahiro Kambe wrote:</p>
<blockquote>
<p>「NetBSD はどうなのかなぁ。」とは、どのような意味でしょう??</p>
</blockquote>
<p>NetBSD で動かないのはよろしくないんじゃないか、という意味です。<br>
あ、そういう意味でしたか。</p>
</blockquote>
<p>NetBSDはstatfs(2)を捨ててstatvfs(2)にしたとき、ソースレベルでは<br>
statfs(2)を完全に捨ててしまいました。</p>
<p>--<br>
神戸 隆博 / Takahiro Kambe</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46413
2014-04-30T16:26:45Z
ngoto (Naohisa Goto)
ngotogenome@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/9789">Bug #9789</a>: Error in TestIO#test_seek_symwhence and TestIO#test_seek on systems without File::Statfs#type (e.g. Solaris)</i> added</li></ul>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46431
2014-05-01T15:50:56Z
djberg96 (Daniel Berger)
<ul></ul><p>Also, for reference see the sys-filesystem gem. :)</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46460
2014-05-02T15:29:07Z
ngoto (Naohisa Goto)
ngotogenome@gmail.com
<ul></ul><p>r45790 にて、File::Statfs#fstypename を AIX, HP-UX, Solaris でも使えるようにしてみました。(ただし動作確認は Solaris のみ。)<br>
struct statvfs.f_basetype を struct statfs.f_fstypename の代替として使用しています。</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46467
2014-05-02T23:58:54Z
akr (Akira Tanaka)
akr@fsij.org
<ul></ul><p>Yui NARUSE wrote:</p>
<blockquote>
<p>statfs では f_type の類がとれないからですね。<a href="https://blade.ruby-lang.org/ruby-core/62150">[ruby-core:62150]</a></p>
</blockquote>
<p>なるほど。</p>
<p>では、IO#statfs では f_type の類は必須で、<br>
f_type の類が提供されない環境では statvfs があっても<br>
IO#statfs は提供しないということでしょうか?</p>
<blockquote>
<p>なお、NetBSDとOpenBSDでは動くようにした…はずです。</p>
</blockquote>
<p>OpenBSD 5.5 が出たので記念にインストールして試してみたところ、コンパイルできない感じです。</p>
<pre><code>% uname -mrsv
OpenBSD 5.5 GENERIC#271 amd64
% make up all
Updating '.':
At revision 45793.
./revision.h unchanged
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -O0 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=deprecated-declarations -std=iso9899:1999
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
CPPFLAGS = -DRUBY_DEBUG_ENV -I. -I.ext/include/x86_64-openbsd5.5 -I./include -I.
DLDFLAGS = -fstack-protector -pie
SOLIBS =
Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd5.5/4.2.1/specs
Target: amd64-unknown-openbsd5.5
Configured with: OpenBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070719
compiling file.c
file.c: In function 'rb_io_statfs':
file.c:1153: error: storage size of 'st' isn't known
file.c:1161: warning: implicit declaration of function 'fstatvfs'
file.c:1153: warning: unused variable 'st'
file.c: In function 'statfs_memsize':
file.c:5358: error: invalid application of 'sizeof' to incomplete type 'statfs_t'
file.c: In function 'statfs_new_0':
file.c:5373: error: invalid application of 'sizeof' to incomplete type 'statfs_t'
file.c:5374: error: dereferencing pointer to incomplete type
file.c:5374: error: dereferencing pointer to incomplete type
file.c: In function 'rb_statfs_init':
file.c:5423: error: storage size of 'st' isn't known
file.c:5428: warning: implicit declaration of function 'statvfs'
file.c:5435: error: invalid application of 'sizeof' to incomplete type 'statfs_t'
file.c:5436: error: dereferencing pointer to incomplete type
file.c:5423: warning: unused variable 'st'
file.c: In function 'rb_statfs_init_copy':
file.c:5454: error: invalid application of 'sizeof' to incomplete type 'statfs_t'
file.c:5455: error: dereferencing pointer to incomplete type
file.c:5455: error: dereferencing pointer to incomplete type
file.c: In function 'statfs_bsize':
file.c:5495: error: dereferencing pointer to incomplete type
file.c: In function 'statfs_blocks':
file.c:5509: error: dereferencing pointer to incomplete type
file.c: In function 'statfs_bfree':
file.c:5523: error: dereferencing pointer to incomplete type
file.c: In function 'statfs_bavail':
file.c:5537: error: dereferencing pointer to incomplete type
file.c: In function 'statfs_files':
file.c:5551: error: dereferencing pointer to incomplete type
file.c: In function 'statfs_ffree':
file.c:5565: error: dereferencing pointer to incomplete type
file.c: In function 'statfs_inspect':
file.c:5627: error: dereferencing pointer to incomplete type
file.c:5628: error: dereferencing pointer to incomplete type
file.c:5628: error: dereferencing pointer to incomplete type
file.c:5628: error: dereferencing pointer to incomplete type
file.c:5629: error: dereferencing pointer to incomplete type
file.c:5629: error: dereferencing pointer to incomplete type
*** Error 1 in /home/akr/tst1/ruby (Makefile:330 'file.o': @ gcc -O0 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parenthe...)
zsh: exit 1 make up all
% egrep -i 'statv?fs' .ext/include/x86_64-openbsd5.5/ruby/config.h
#define HAVE_STRUCT_STATVFS 1
#define HAVE_FSTATFS 1
#define HAVE_FSTATVFS 1
</code></pre>
<p>ヘッダファイルが足りないという感じかなぁ</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46609
2014-05-08T02:09:29Z
naruse (Yui NARUSE)
naruse@airemix.jp
<ul></ul><p>Akira Tanaka wrote:</p>
<blockquote>
<p>Yui NARUSE wrote:</p>
<blockquote>
<p>statfs では f_type の類がとれないからですね。<a href="https://blade.ruby-lang.org/ruby-core/62150">[ruby-core:62150]</a></p>
</blockquote>
<p>なるほど。</p>
<p>では、IO#statfs では f_type の類は必須で、<br>
f_type の類が提供されない環境では statvfs があっても<br>
IO#statfs は提供しないということでしょうか?</p>
</blockquote>
<p>他の方が互換実装を提供することに反対はしませんが、わたしがわざわざ実装する動機は欠けますね。</p>
<blockquote>
<blockquote>
<p>なお、NetBSDとOpenBSDでは動くようにした…はずです。</p>
</blockquote>
<p>OpenBSD 5.5 が出たので記念にインストールして試してみたところ、コンパイルできない感じです。</p>
<p>ヘッダファイルが足りないという感じかなぁ</p>
</blockquote>
<p>r45873で直しました。</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46610
2014-05-08T04:31:16Z
akr (Akira Tanaka)
akr@fsij.org
<ul></ul><p>Yui NARUSE wrote:</p>
<blockquote>
<p>他の方が互換実装を提供することに反対はしませんが、わたしがわざわざ実装する動機は欠けますね。</p>
</blockquote>
<p>とすると、statvfs があるときは少なくとも statvfs の情報は提供することになるような気がしますね。<br>
statvfs は POSIX で標準化されているので、結局、提案されているメソッドの実際の動作は<br>
statvfs + 環境依存の様々な情報、ということになりそうな気がします。</p>
<p>そうすると常に提供されると期待できるのは statvfs の部分なわけで、やっぱ名前は statvfs のほうがいい気がするなぁ。<br>
(statfs を使ったときに f_fsid をどう提供するかという問題はあります。)</p>
<p>あるいは、もっと動機に率直なメソッドにしてしまうという手もあって、<br>
ファイルシステムの種類を返すメソッドというように限定してしまうのもいいかもしれません。<br>
そうすると、statfs/statvfs 以外の方法でファイルシステムの種類を得る実装も扱えるようになります。<br>
たとえば、getmntent とか。</p>
<p>実際に statfs/statvfs がなくて getmntent がある環境など、そういう備えが役に立つ環境があるかどうかは知りませんが。</p>
<p>いや、(GNU/Linux の) getmntent は /etc/mtab を読むから、<br>
もしかして ext2/3/4 が判別できるという利点があるかも? (確認してません)</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46615
2014-05-08T09:43:44Z
naruse (Yui NARUSE)
naruse@airemix.jp
<ul></ul><p>Akira Tanaka wrote:</p>
<blockquote>
<p>Yui NARUSE wrote:</p>
<blockquote>
<p>他の方が互換実装を提供することに反対はしませんが、わたしがわざわざ実装する動機は欠けますね。</p>
</blockquote>
<p>とすると、statvfs があるときは少なくとも statvfs の情報は提供することになるような気がしますね。<br>
statvfs は POSIX で標準化されているので、結局、提案されているメソッドの実際の動作は<br>
statvfs + 環境依存の様々な情報、ということになりそうな気がします。</p>
<p>そうすると常に提供されると期待できるのは statvfs の部分なわけで、やっぱ名前は statvfs のほうがいい気がするなぁ。<br>
(statfs を使ったときに f_fsid をどう提供するかという問題はあります。)</p>
</blockquote>
<p>まぁ採否も含めてまつもとさんに判断頂く際に、名前も決めていただくってことでいいかと。</p>
<blockquote>
<p>あるいは、もっと動機に率直なメソッドにしてしまうという手もあって、<br>
ファイルシステムの種類を返すメソッドというように限定してしまうのもいいかもしれません。<br>
そうすると、statfs/statvfs 以外の方法でファイルシステムの種類を得る実装も扱えるようになります。<br>
たとえば、getmntent とか。</p>
<p>実際に statfs/statvfs がなくて getmntent がある環境など、そういう備えが役に立つ環境があるかどうかは知りませんが。</p>
<p>いや、(GNU/Linux の) getmntent は /etc/mtab を読むから、<br>
もしかして ext2/3/4 が判別できるという利点があるかも? (確認してません)</p>
</blockquote>
<p>ふむ、確かに今のわたしのユースケースだとこちらのほうが適している気はしますね。<br>
こちらはこちらでいじってみます。<br>
こっちだと Etc.mntinfo とか Etc.df とかですかねぇ</p>
Ruby master - Feature #9772: IO#statfs and File::Statfs
https://bugs.ruby-lang.org/issues/9772?journal_id=46828
2014-05-22T10:37:39Z
naruse (Yui NARUSE)
naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Rejected</i></li></ul><p><a href="https://docs.google.com/document/d/1sLZec48bWLyrJZ7MZna74bY9h2YoLBerlBHe-0EQgek/pub" class="external">https://docs.google.com/document/d/1sLZec48bWLyrJZ7MZna74bY9h2YoLBerlBHe-0EQgek/pub</a></p>