Skip to content

Commit

Permalink
types/options: check prior drivers using readdir
Browse files Browse the repository at this point in the history
Fetch prior drivers if any using `ReadDir` and looking for traces of
`%s-images` dirs if present already on the system where `%s` is the
prior driver.

Signed-off-by: Aditya R <arajan@redhat.com>
  • Loading branch information
flouthoc committed Jun 12, 2023
1 parent 083f61b commit d7a6662
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"time"

"github.com/BurntSushi/toml"
drivers "github.com/containers/storage/drivers"
_ "github.com/containers/storage/drivers/register"
cfg "github.com/containers/storage/pkg/config"
"github.com/containers/storage/pkg/idtools"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -312,12 +310,16 @@ func getRootlessStorageOpts(rootlessUID int, systemOpts StoreOptions) (StoreOpti
}
if opts.GraphDriverName == "" {
if len(systemOpts.GraphDriverPriority) == 0 {
driversMap := drivers.ScanPriorDrivers(opts.GraphRoot)

for _, name := range drivers.Priority {
if _, prior := driversMap[name]; prior {
opts.GraphDriverName = name
break
dirEntries, err := os.ReadDir(opts.GraphRoot)
if err == nil {
for _, entry := range dirEntries {
if strings.HasSuffix(entry.Name(), "-images") {
var driver string
_, err = fmt.Sscanf(entry.Name(), "%s-images", &driver)
if err == nil {
opts.GraphDriverName = driver
}
}
}
}

Expand Down

0 comments on commit d7a6662

Please sign in to comment.