描述
方法fstatvfs()返回有關包含與文件描述符 fd 關聯的文件的文件係統的信息。這將返回以下結構 -
f_bsize− 文件係統塊大小
f_frsize− 片段大小
f_blocks- 以 f_frsize 為單位的 fs 大小
f_bfree- 空閑塊
f_bavail- 非根的空閑塊
f_files- 節點
f_ffree- 免費的 inode
f_favail- 非 root 的免費 inode
f_fsid− 文件係統 ID
f_flag- 安裝標誌
f_namemax− 最大文件名長度
用法
以下是語法fstatvfs()方法 -
os.fstatvfs(fd)
參數
fd− 這是要為其返回係統信息的文件描述符。
返回值
此方法返回有關包含關聯文件的文件係統的信息。
示例
下麵的例子展示了 fstatvfs() 方法的用法。
#!/usr/bin/python3
import os, sys
# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
# Now get the touple
info = os.fstatvfs(fd)
print ("File Info:", info)
# Now get maximum filename length
print ("Maximum filename length:%d" % info.f_namemax:)
# Now get free blocks
print ("Free blocks:%d" % info.f_bfree)
# Close opened file
os.close( fd)
結果
當我們運行上述程序時,它會產生以下結果 -
File Info:(4096, 4096, 2621440L, 1113266L, 1113266L, 8929602L, 8764252L, 8764252L, 0, 255) Maximum filename length:255 Free blocks:1113266
相關用法
- Python 3 os.fstat()用法及代碼示例
- Python 3 os.fsync()用法及代碼示例
- Python 3 os.fdopen()用法及代碼示例
- Python 3 os.fdatasync()用法及代碼示例
- Python 3 os.fchmod()用法及代碼示例
- Python 3 os.fchown()用法及代碼示例
- Python 3 os.fpathconf()用法及代碼示例
- Python 3 os.fchdir()用法及代碼示例
- Python 3 os.ftruncate()用法及代碼示例
- Python 3 os.minor()用法及代碼示例
- Python 3 os.close()用法及代碼示例
- Python 3 os.unlink()用法及代碼示例
- Python 3 os.major()用法及代碼示例
- Python 3 os.rmdir()用法及代碼示例
- Python 3 os.isatty()用法及代碼示例
- Python 3 os.rename()用法及代碼示例
- Python 3 os.walk()用法及代碼示例
- Python 3 os.renames()用法及代碼示例
- Python 3 os.makedirs()用法及代碼示例
- Python 3 os.utime()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - os.fstatvfs() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。