From 9bab9300446caba17a9c2594db19b46925b99714 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Tue, 23 Feb 2016 13:33:57 +0800 Subject: [PATCH 1/2] Fix type of devices type Fixes: opencontainers/runc#566 For type rune, we can assign char as 'c' in struct, but after marshal, it'll be presented as int32. So in json config it needs to be presented as a number which is not friendly to be identified. Change it to string so that you can actually write "b", "c" in json spec and you can easily know what type of device it is. Signed-off-by: Qiang Huang --- config-linux.md | 4 ++-- config_linux.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config-linux.md b/config-linux.md index f7723c74..dd7878bb 100644 --- a/config-linux.md +++ b/config-linux.md @@ -112,7 +112,7 @@ The runtime may supply them however it likes (with [mknod][mknod.2], by bind mou The following parameters can be specified: -* **`type`** *(char, required)* - type of device: `c`, `b`, `u` or `p`. +* **`type`** *(string, required)* - type of device: `c`, `b`, `u` or `p`. More info in [mknod(1)][mknod.1]. * **`path`** *(string, required)* - full path to device inside container. * **`major, minor`** *(int64, required unless **`type`** is `p`)* - [major, minor numbers][devices] for the device. @@ -194,7 +194,7 @@ The runtime MUST apply entries in the listed order. The following parameters can be specified: * **`allow`** *(boolean, required)* - whether the entry is allowed or denied. -* **`type`** *(char, optional)* - type of device: `a` (all), `c` (char), or `b` (block). +* **`type`** *(string, optional)* - type of device: `a` (all), `c` (char), or `b` (block). `null` or unset values mean "all", mapping to `a`. * **`major, minor`** *(int64, optional)* - [major, minor numbers][devices] for the device. `null` or unset values mean "all", mapping to [`*` in the filesystem API][cgroup-v1-devices]. diff --git a/config_linux.go b/config_linux.go index 72027112..6b064ca9 100644 --- a/config_linux.go +++ b/config_linux.go @@ -238,7 +238,7 @@ type Device struct { // Path to the device. Path string `json:"path"` // Device type, block, char, etc. - Type rune `json:"type"` + Type string `json:"type"` // Major is the device's major number. Major int64 `json:"major"` // Minor is the device's minor number. @@ -256,7 +256,7 @@ type DeviceCgroup struct { // Allow or deny Allow bool `json:"allow"` // Device type, block, char, etc. - Type *rune `json:"type,omitempty"` + Type *string `json:"type,omitempty"` // Major is the device's major number. Major *int64 `json:"major,omitempty"` // Minor is the device's minor number. From ccf3a246ca3721ec850628d8f133603ebbb27d8e Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Tue, 23 Feb 2016 08:22:27 +0800 Subject: [PATCH 2/2] Fix fileMode json example In json, os.FileMode would be presented as a uint32, which is decimal. Otherwise we'll get error: `invalid character '6' after object key:value pair` when unmarshal the json file. Signed-off-by: Qiang Huang --- config-linux.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config-linux.md b/config-linux.md index dd7878bb..50811d79 100644 --- a/config-linux.md +++ b/config-linux.md @@ -130,7 +130,7 @@ The following parameters can be specified: "type": "c", "major": 10, "minor": 229, - "fileMode": 0666, + "fileMode": 438, "uid": 0, "gid": 0 }, @@ -139,7 +139,7 @@ The following parameters can be specified: "type": "b", "major": 8, "minor": 0, - "fileMode": 0660, + "fileMode": 432, "uid": 0, "gid": 0 }