mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
Remove io/ioutil use
See https://golang.org/doc/go1.16#ioutil Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
@@ -121,7 +120,7 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list, err := ioutil.ReadDir(absRoot)
|
||||
list, err := os.ReadDir(absRoot)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
@@ -129,11 +128,15 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
||||
var s []containerState
|
||||
for _, item := range list {
|
||||
if item.IsDir() {
|
||||
// This cast is safe on Linux.
|
||||
stat := item.Sys().(*syscall.Stat_t)
|
||||
owner, err := user.LookupUid(int(stat.Uid))
|
||||
st, err := os.Stat(filepath.Join(absRoot, item.Name()))
|
||||
if err != nil {
|
||||
owner.Name = fmt.Sprintf("#%d", stat.Uid)
|
||||
fatal(err)
|
||||
}
|
||||
// This cast is safe on Linux.
|
||||
uid := st.Sys().(*syscall.Stat_t).Uid
|
||||
owner, err := user.LookupUid(int(uid))
|
||||
if err != nil {
|
||||
owner.Name = fmt.Sprintf("#%d", uid)
|
||||
}
|
||||
|
||||
container, err := factory.Load(item.Name())
|
||||
|
||||
Reference in New Issue
Block a user