mirror of
https://github.com/containers/podman.git
synced 2025-06-24 03:08:13 +08:00
Merge pull request #1696 from QiWang19/ExportForCrio
Change ParseDevice to exported name
This commit is contained in:
@ -28,7 +28,7 @@ func Device(d *configs.Device) spec.LinuxDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addDevice(g *generate.Generator, device string) error {
|
func addDevice(g *generate.Generator, device string) error {
|
||||||
src, dst, permissions, err := parseDevice(device)
|
src, dst, permissions, err := ParseDevice(device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -148,21 +148,21 @@ func getLoggingPath(opts []string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseDevice parses device mapping string to a src, dest & permissions string
|
// ParseDevice parses device mapping string to a src, dest & permissions string
|
||||||
func parseDevice(device string) (string, string, string, error) { //nolint
|
func ParseDevice(device string) (string, string, string, error) { //nolint
|
||||||
src := ""
|
src := ""
|
||||||
dst := ""
|
dst := ""
|
||||||
permissions := "rwm"
|
permissions := "rwm"
|
||||||
arr := strings.Split(device, ":")
|
arr := strings.Split(device, ":")
|
||||||
switch len(arr) {
|
switch len(arr) {
|
||||||
case 3:
|
case 3:
|
||||||
if !validDeviceMode(arr[2]) {
|
if !IsValidDeviceMode(arr[2]) {
|
||||||
return "", "", "", fmt.Errorf("invalid device mode: %s", arr[2])
|
return "", "", "", fmt.Errorf("invalid device mode: %s", arr[2])
|
||||||
}
|
}
|
||||||
permissions = arr[2]
|
permissions = arr[2]
|
||||||
fallthrough
|
fallthrough
|
||||||
case 2:
|
case 2:
|
||||||
if validDeviceMode(arr[1]) {
|
if IsValidDeviceMode(arr[1]) {
|
||||||
permissions = arr[1]
|
permissions = arr[1]
|
||||||
} else {
|
} else {
|
||||||
if arr[1][0] != '/' {
|
if arr[1][0] != '/' {
|
||||||
@ -183,9 +183,9 @@ func parseDevice(device string) (string, string, string, error) { //nolint
|
|||||||
return src, dst, permissions, nil
|
return src, dst, permissions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// validDeviceMode checks if the mode for device is valid or not.
|
// IsValidDeviceMode checks if the mode for device is valid or not.
|
||||||
// Valid mode is a composition of r (read), w (write), and m (mknod).
|
// IsValid mode is a composition of r (read), w (write), and m (mknod).
|
||||||
func validDeviceMode(mode string) bool {
|
func IsValidDeviceMode(mode string) bool {
|
||||||
var legalDeviceMode = map[rune]bool{
|
var legalDeviceMode = map[rune]bool{
|
||||||
'r': true,
|
'r': true,
|
||||||
'w': true,
|
'w': true,
|
||||||
|
Reference in New Issue
Block a user