Skip to content

Commit

Permalink
Allow libcontainer/configs to be imported on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Jul 8, 2020
1 parent 5517d1d commit d78ee47
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
12 changes: 0 additions & 12 deletions libcontainer/configs/device.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package configs

import (
"errors"
"fmt"
"os"
"strconv"

"golang.org/x/sys/unix"
)

const (
Wildcard = -1
)

// TODO Windows: This can be factored out in the future

type Device struct {
DeviceRule

Expand Down Expand Up @@ -173,10 +168,3 @@ func (d *DeviceRule) CgroupString() string {
}
return fmt.Sprintf("%c %s:%s %s", d.Type, major, minor, d.Permissions)
}

func (d *DeviceRule) Mkdev() (uint64, error) {
if d.Major == Wildcard || d.Minor == Wildcard {
return 0, errors.New("cannot mkdev() device with wildcards")
}
return unix.Mkdev(uint32(d.Major), uint32(d.Minor)), nil
}
16 changes: 16 additions & 0 deletions libcontainer/configs/device_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// +build !windows

package configs

import (
"errors"

"golang.org/x/sys/unix"
)

func (d *DeviceRule) Mkdev() (uint64, error) {
if d.Major == Wildcard || d.Minor == Wildcard {
return 0, errors.New("cannot mkdev() device with wildcards")
}
return unix.Mkdev(uint32(d.Major), uint32(d.Minor)), nil
}
5 changes: 5 additions & 0 deletions libcontainer/configs/device_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package configs

func (d *DeviceRule) Mkdev() (uint64, error) {
return 0, nil
}

0 comments on commit d78ee47

Please sign in to comment.