Stats retrieves Bcachefs filesystem runtime statistics for each mounted Bcachefs filesystem.
()
| 52 | |
| 53 | // Stats retrieves Bcachefs filesystem runtime statistics for each mounted Bcachefs filesystem. |
| 54 | func (fs FS) Stats() ([]*Stats, error) { |
| 55 | base := fs.sys.Path("fs/bcachefs") |
| 56 | entries, err := os.ReadDir(base) |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | |
| 61 | stats := make([]*Stats, 0, len(entries)) |
| 62 | for _, entry := range entries { |
| 63 | if !entry.IsDir() { |
| 64 | continue |
| 65 | } |
| 66 | uuidPath := filepath.Join(base, entry.Name()) |
| 67 | s, err := GetStats(uuidPath) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | s.UUID = entry.Name() |
| 72 | stats = append(stats, s) |
| 73 | } |
| 74 | |
| 75 | return stats, nil |
| 76 | } |
| 77 | |
| 78 | // GetStats collects all Bcachefs statistics from sysfs. |
| 79 | func GetStats(uuidPath string) (*Stats, error) { |