0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

statfs 情報を取得する Python モジュール

Posted at

Python モジュール

macOS, FreeBSD のシステム コールstatfs, fstatfs, getfsstat, getmntinfoの結果を取得するモジュールを作ってみました。

実行結果
$ python3
Python 3.11.13 (main, Aug  9 2025, 01:11:38) [Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2 on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> import statfs
>>> statfs.statfs('/')
statfs(f_version=538182936, f_otype=None, f_oflags=None, f_flags=268455952, f_flags_ext=None, f_owner=0, f_fsid=(0, 0), f_type=222, f_fssubtype=None, f_namemax=255, f_fstypename='zfs', f_mntfromname='zroot/ROOT/default', f_mntonname='/', f_spare='', f_charspare='', f_iosize=131072, f_bsize=512, f_blocks=1006203680, f_bavail=1000395072, f_bfree=1000395072, f_ffree=1000395072, f_files=1000468910, f_syncwrites=0, f_asyncwrites=0, f_syncreads=0, f_asyncreads=0, f_reserved=None, f_reserved1=None, f_reserved2=None, f_reserved3=None, f_reserved4=None)

取得できる情報は macOS と FreeBSD で異なります。さらに、macOS ではコンパイル時の
  _DARWIN_FEATURE_64_BIT_INODE (DF64と略します)
の定義次第で異なります。

変数名 FreeBSD DF64なし DF64あり
f_version
f_otype
f_oflags
f_flags
f_flags_ext
f_owner
f_fsid
f_type
f_fssubtype
f_namemax
f_fstypename
f_mntfromname
f_mntonname
f_spare
f_charspare
f_iosize
f_bsize
f_blocks
f_bavail
f_bfree
f_ffree
f_files
f_syncwrites
f_asyncwrites
f_syncreads
f_asyncreads
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?