Move to new github.com/sirupsen/logrus.

Need to mv to latest released and supported version of logrus
switch github.com/Sirupsen/logrus github.com/sirupsen/logrus

Also vendor in latest containers/storage and containers/image

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh 2017-08-05 07:40:46 -04:00
parent 816b15e07e
commit 63a218a458
366 changed files with 7104 additions and 2749 deletions

View file

@ -2,11 +2,9 @@ package devices
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"syscall" //only for Stat_t
"github.com/opencontainers/runc/libcontainer/configs"
@ -19,45 +17,41 @@ var (
// Testing dependencies
var (
osLstat = os.Lstat
unixLstat = unix.Lstat
ioutilReadDir = ioutil.ReadDir
)
// Given the path to a device and its cgroup_permissions(which cannot be easily queried) look up the information about a linux device and return that information as a Device struct.
func DeviceFromPath(path, permissions string) (*configs.Device, error) {
fileInfo, err := osLstat(path)
var stat unix.Stat_t
err := unixLstat(path, &stat)
if err != nil {
return nil, err
}
var (
devType rune
mode = fileInfo.Mode()
fileModePermissionBits = os.FileMode.Perm(mode)
devType rune
mode = stat.Mode
)
switch {
case mode&os.ModeDevice == 0:
return nil, ErrNotADevice
case mode&os.ModeCharDevice != 0:
fileModePermissionBits |= unix.S_IFCHR
case mode&unix.S_IFBLK == unix.S_IFBLK:
devType = 'b'
case mode&unix.S_IFCHR == unix.S_IFCHR:
devType = 'c'
default:
fileModePermissionBits |= unix.S_IFBLK
devType = 'b'
return nil, ErrNotADevice
}
stat_t, ok := fileInfo.Sys().(*syscall.Stat_t)
if !ok {
return nil, fmt.Errorf("cannot determine the device number for device %s", path)
}
devNumber := int(stat_t.Rdev)
devNumber := int(stat.Rdev)
uid := stat.Uid
gid := stat.Gid
return &configs.Device{
Type: devType,
Path: path,
Major: Major(devNumber),
Minor: Minor(devNumber),
Permissions: permissions,
FileMode: fileModePermissionBits,
Uid: stat_t.Uid,
Gid: stat_t.Gid,
FileMode: os.FileMode(mode),
Uid: uid,
Gid: gid,
}, nil
}