Skip to content

Commit 58e2344

Browse files
committed
[no-relnote] Add collection of mountSpecs
Signed-off-by: Evan Lezar <[email protected]>
1 parent d4e785a commit 58e2344

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

internal/platform-support/tegra/csv.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,21 @@ func (o options) newDiscovererFromMountSpecs(targetsByType MountSpecPathsByType)
8282
// MountSpecsFromCSVFiles returns a MountSpecPathsByTyper for the specified list
8383
// of CSV files.
8484
func MountSpecsFromCSVFiles(logger logger.Interface, csvFilePaths ...string) MountSpecPathsByType {
85-
targetsByType := make(MountSpecPathsByType)
85+
var mountSpecs mountSpecPathsByTypers
86+
8687
for _, filename := range csvFilePaths {
8788
targets, err := loadCSVFile(logger, filename)
8889
if err != nil {
8990
logger.Warningf("Skipping CSV file %v: %v", filename, err)
9091
continue
9192
}
93+
targetsByType := make(MountSpecPathsByType)
9294
for _, t := range targets {
9395
targetsByType[t.Type] = append(targetsByType[t.Type], t.Path)
9496
}
97+
mountSpecs = append(mountSpecs, targetsByType)
9598
}
96-
return targetsByType
99+
return mountSpecs.MountSpecPathsByType()
97100
}
98101

99102
// loadCSVFile loads the specified CSV file and returns the list of mount specs

internal/platform-support/tegra/mount_specs.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ type MountSpecPathsByTyper interface {
2525
MountSpecPathsByType() MountSpecPathsByType
2626
}
2727

28+
// moutSpecPathsByTypers represents a collection of MountSpecPathsByTyper
29+
type mountSpecPathsByTypers []MountSpecPathsByTyper
30+
2831
// MountSpecPathsByType define the per-type paths that define the entities
2932
// (e.g. device nodes, directories, libraries, symlinks) that are required for
3033
// gpu use on Tegra-based systems.
3134
// These are typically populated from CSV files defined by the platform owner.
3235
type MountSpecPathsByType map[csv.MountSpecType][]string
3336

3437
var _ MountSpecPathsByTyper = (MountSpecPathsByType)(nil)
38+
var _ MountSpecPathsByTyper = (mountSpecPathsByTypers)(nil)
3539

3640
// MountSpecPathsByType for a variable of type MountSpecPathsByType returns the
3741
// underlying data structure.
@@ -40,6 +44,22 @@ func (m MountSpecPathsByType) MountSpecPathsByType() MountSpecPathsByType {
4044
return m
4145
}
4246

47+
// MountSpecPathsByType returns the combination of mount specs by type for the
48+
// collection.
49+
func (collection mountSpecPathsByTypers) MountSpecPathsByType() MountSpecPathsByType {
50+
merged := make(MountSpecPathsByType)
51+
for _, t := range collection {
52+
if t == nil {
53+
continue
54+
}
55+
for tType, targets := range t.MountSpecPathsByType() {
56+
merged[tType] = append(merged[tType], targets...)
57+
}
58+
}
59+
return merged
60+
61+
}
62+
4363
// A Transformer modifies a specified set of mount specs by type.
4464
// The output of a transformer is itself a set of mount specs by type.
4565
type Transformer interface {

internal/platform-support/tegra/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ func WithLibrarySearchPaths(librarySearchPaths ...string) Option {
8686
}
8787
}
8888

89-
func WithMountSpecs(mountSpecs MountSpecPathsByTyper) Option {
89+
func WithMountSpecs(mountSpecs ...MountSpecPathsByTyper) Option {
9090
return func(o *options) {
91-
o.mountSpecs = mountSpecs
91+
o.mountSpecs = mountSpecPathsByTypers(mountSpecs)
9292
}
9393
}

0 commit comments

Comments
 (0)