Merge pull request #1321 from Mashimiao/support-device-new-type
support create device with type p and u
This commit is contained in:
commit
4f21aea40d
|
@ -510,10 +510,12 @@ func createDeviceNode(rootfs string, node *configs.Device, bind bool) error {
|
||||||
func mknodDevice(dest string, node *configs.Device) error {
|
func mknodDevice(dest string, node *configs.Device) error {
|
||||||
fileMode := node.FileMode
|
fileMode := node.FileMode
|
||||||
switch node.Type {
|
switch node.Type {
|
||||||
case 'c':
|
case 'c', 'u':
|
||||||
fileMode |= syscall.S_IFCHR
|
fileMode |= syscall.S_IFCHR
|
||||||
case 'b':
|
case 'b':
|
||||||
fileMode |= syscall.S_IFBLK
|
fileMode |= syscall.S_IFBLK
|
||||||
|
case 'p':
|
||||||
|
fileMode |= syscall.S_IFIFO
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%c is not a valid device type for device %s", node.Type, node.Path)
|
return fmt.Errorf("%c is not a valid device type for device %s", node.Type, node.Path)
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,7 +318,7 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
|
||||||
if d.Access == nil || *d.Access == "" {
|
if d.Access == nil || *d.Access == "" {
|
||||||
return nil, fmt.Errorf("device access at %d field cannot be empty", i)
|
return nil, fmt.Errorf("device access at %d field cannot be empty", i)
|
||||||
}
|
}
|
||||||
dt, err := stringToDeviceRune(t)
|
dt, err := stringToCgroupDeviceRune(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringToDeviceRune(s string) (rune, error) {
|
func stringToCgroupDeviceRune(s string) (rune, error) {
|
||||||
switch s {
|
switch s {
|
||||||
case "a":
|
case "a":
|
||||||
return 'a', nil
|
return 'a', nil
|
||||||
|
@ -460,6 +460,21 @@ func stringToDeviceRune(s string) (rune, error) {
|
||||||
return 'b', nil
|
return 'b', nil
|
||||||
case "c":
|
case "c":
|
||||||
return 'c', nil
|
return 'c', nil
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("invalid cgroup device type %q", s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func stringToDeviceRune(s string) (rune, error) {
|
||||||
|
switch s {
|
||||||
|
case "p":
|
||||||
|
return 'p', nil
|
||||||
|
case "u":
|
||||||
|
return 'u', nil
|
||||||
|
case "b":
|
||||||
|
return 'b', nil
|
||||||
|
case "c":
|
||||||
|
return 'c', nil
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("invalid device type %q", s)
|
return 0, fmt.Errorf("invalid device type %q", s)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue