mirror of
https://github.com/containers/podman.git
synced 2025-12-01 18:49:18 +08:00
fix(deps): update module github.com/crc-org/vfkit to v0.6.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
82
vendor/github.com/lufia/plan9stats/host.go
generated
vendored
82
vendor/github.com/lufia/plan9stats/host.go
generated
vendored
@@ -109,12 +109,6 @@ func parseGauge(s string, r *Gauge) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type Storage struct {
|
||||
Name string
|
||||
Model string
|
||||
Capacity int64
|
||||
}
|
||||
|
||||
type Interface struct {
|
||||
Name string
|
||||
Addr string
|
||||
@@ -177,7 +171,7 @@ func ReadHost(ctx context.Context, opts ...Option) (*Host, error) {
|
||||
}
|
||||
h.Sysname = name
|
||||
|
||||
a, err := readStorages(cfg.rootdir)
|
||||
a, err := ReadStorages(ctx, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -203,80 +197,6 @@ func readSysname(rootdir string) (string, error) {
|
||||
return string(bytes.TrimSpace(b)), nil
|
||||
}
|
||||
|
||||
func readStorages(rootdir string) ([]*Storage, error) {
|
||||
sdctl := filepath.Join(rootdir, "/dev/sdctl")
|
||||
f, err := os.Open(sdctl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
var a []*Storage
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
fields := bytes.Split(scanner.Bytes(), delim)
|
||||
if len(fields) == 0 {
|
||||
continue
|
||||
}
|
||||
exp := string(fields[0]) + "*"
|
||||
if !strings.HasPrefix(exp, "sd") {
|
||||
continue
|
||||
}
|
||||
dir := filepath.Join(rootdir, "/dev", exp)
|
||||
m, err := filepath.Glob(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, dir := range m {
|
||||
s, err := readStorage(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a = append(a, s)
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
func readStorage(dir string) (*Storage, error) {
|
||||
ctl := filepath.Join(dir, "ctl")
|
||||
f, err := os.Open(ctl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
var s Storage
|
||||
s.Name = filepath.Base(dir)
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Bytes()
|
||||
switch {
|
||||
case bytes.HasPrefix(line, []byte("inquiry")):
|
||||
s.Model = string(bytes.TrimSpace(line[7:]))
|
||||
case bytes.HasPrefix(line, []byte("geometry")):
|
||||
fields := bytes.Split(line, delim)
|
||||
if len(fields) < 3 {
|
||||
continue
|
||||
}
|
||||
var p intParser
|
||||
sec := p.ParseInt64(string(fields[1]), 10)
|
||||
size := p.ParseInt64(string(fields[2]), 10)
|
||||
if err := p.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Capacity = sec * size
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
type IPStats struct {
|
||||
ID int // number of interface in ipifc dir
|
||||
Device string // associated physical device
|
||||
|
||||
Reference in New Issue
Block a user