diff --git a/cmd/nvidia-ctk/cdi/generate/generate.go b/cmd/nvidia-ctk/cdi/generate/generate.go index 47b6c711..830437ca 100644 --- a/cmd/nvidia-ctk/cdi/generate/generate.go +++ b/cmd/nvidia-ctk/cdi/generate/generate.go @@ -238,7 +238,7 @@ func (m command) generateSpec(opts *options) (spec.Interface, error) { nvcdi.WithDriverRoot(opts.driverRoot), nvcdi.WithNVIDIACTKPath(opts.nvidiaCTKPath), nvcdi.WithDeviceNamer(deviceNamer), - nvcdi.WithMode(string(opts.mode)), + nvcdi.WithMode(opts.mode), nvcdi.WithLibrarySearchPaths(opts.librarySearchPaths.Value()), nvcdi.WithCSVFiles(opts.csv.files.Value()), nvcdi.WithCSVIgnorePatterns(opts.csv.ignorePatterns.Value()), diff --git a/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing.go b/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing.go index a1af8b20..946f42b0 100644 --- a/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing.go +++ b/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing.go @@ -63,20 +63,13 @@ func (m existing) DeviceNodes() ([]deviceNode, error) { if m.nodeIsBlocked(d) { continue } - var stat unix.Stat_t err := unix.Stat(d, &stat) if err != nil { m.logger.Warningf("Could not stat device: %v", err) continue } - deviceNode := deviceNode{ - path: d, - major: unix.Major(uint64(stat.Rdev)), - minor: unix.Minor(uint64(stat.Rdev)), - } - - deviceNodes = append(deviceNodes, deviceNode) + deviceNodes = append(deviceNodes, newDeviceNode(d, stat)) } return deviceNodes, nil diff --git a/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_linux.go b/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_linux.go new file mode 100644 index 00000000..4aab942a --- /dev/null +++ b/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_linux.go @@ -0,0 +1,28 @@ +/** +# Copyright (c) NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package devchar + +import "golang.org/x/sys/unix" + +func newDeviceNode(d string, stat unix.Stat_t) deviceNode { + deviceNode := deviceNode{ + path: d, + major: unix.Major(stat.Rdev), + minor: unix.Minor(stat.Rdev), + } + return deviceNode +} diff --git a/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_other.go b/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_other.go new file mode 100644 index 00000000..9be96294 --- /dev/null +++ b/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_other.go @@ -0,0 +1,30 @@ +//go:build !linux + +/** +# Copyright (c) NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package devchar + +import "golang.org/x/sys/unix" + +func newDeviceNode(d string, stat unix.Stat_t) deviceNode { + deviceNode := deviceNode{ + path: d, + major: unix.Major(uint64(stat.Rdev)), + minor: unix.Minor(uint64(stat.Rdev)), + } + return deviceNode +} diff --git a/internal/ldcache/ldcache.go b/internal/ldcache/ldcache.go index 0547dee4..5ea263c1 100644 --- a/internal/ldcache/ldcache.go +++ b/internal/ldcache/ldcache.go @@ -287,7 +287,7 @@ func (c *ldcache) resolveSelected(selected func(string) bool) ([]string, []strin func (c *ldcache) resolve(target string) (string, error) { name := filepath.Join(c.root, target) - c.logger.Debugf("checking %v", string(name)) + c.logger.Debugf("checking %v", name) link, err := symlinks.Resolve(name) if err != nil { diff --git a/internal/requirements/constraints/binary.go b/internal/requirements/constraints/binary.go index 5ca37408..be2667f7 100644 --- a/internal/requirements/constraints/binary.go +++ b/internal/requirements/constraints/binary.go @@ -57,7 +57,7 @@ func (c binary) eval() (bool, error) { return false, err } - switch string(c.operator) { + switch c.operator { case equal: return compare == 0, nil case notEqual: diff --git a/pkg/nvcdi/lib_test.go b/pkg/nvcdi/lib_test.go index 77ead658..b467ee5b 100644 --- a/pkg/nvcdi/lib_test.go +++ b/pkg/nvcdi/lib_test.go @@ -104,13 +104,13 @@ type infoMock struct { } func (i infoMock) HasDXCore() (bool, string) { - return bool(i.hasDXCore), "" + return i.hasDXCore, "" } func (i infoMock) HasNvml() (bool, string) { - return bool(i.hasNVML), "" + return i.hasNVML, "" } func (i infoMock) IsTegraSystem() (bool, string) { - return bool(i.isTegra), "" + return i.isTegra, "" }