Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit 2b16551

Browse files
committed
add support for repository not mounted on /cvmfs
1 parent 298161c commit 2b16551

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

cvmfs/cvmfs.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,30 @@ const (
2424
)
2525

2626
type filesystem struct {
27-
repository string
28-
mountedLayers map[string]string
29-
mountedLayersLock sync.Mutex
27+
fsAbsoluteMountpoint string
28+
mountedLayers map[string]string
29+
mountedLayersLock sync.Mutex
3030
}
3131

3232
type Config struct {
33-
Repository string `toml:"repository" default:"unpacked.cern.ch"`
33+
Repository string `toml:"repository" default:"unpacked.cern.ch"`
34+
AbsoluteMountpoint string `toml:"absolute-mountpoint" default:""`
3435
}
3536

3637
func NewFilesystem(ctx context.Context, root string, config *Config) (snapshot.FileSystem, error) {
37-
log.G(ctx).WithField("root", root).Warning("New fs")
38-
repository := config.Repository
39-
if repository == "" {
40-
repository = "unpacked.cern.ch"
38+
var absolutePath string
39+
defer log.G(ctx).WithField("root", root).WithField("absolutePath", absolutePath).Info("Mounting new filesystem")
40+
mountedLayersMap := make(map[string]string)
41+
if config.AbsoluteMountpoint == "" {
42+
repository := config.Repository
43+
if repository == "" {
44+
repository = "unpacked.cern.ch"
45+
}
46+
absolutePath = filepath.Join("/", "cvmfs", repository)
47+
} else {
48+
absolutePath = config.AbsoluteMountpoint
4149
}
42-
return &filesystem{repository: repository, mountedLayers: make(map[string]string)}, nil
50+
return &filesystem{fsAbsoluteMountpoint: absolutePath, mountedLayers: mountedLayersMap}, nil
4351
}
4452

4553
func (fs *filesystem) Mount(ctx context.Context, mountpoint string, labels map[string]string) error {
@@ -52,7 +60,7 @@ func (fs *filesystem) Mount(ctx context.Context, mountpoint string, labels map[s
5260
}
5361
digest = strings.Split(digest, ":")[1]
5462
firstTwo := digest[0:2]
55-
path := filepath.Join("/", "cvmfs", fs.repository, ".layers", firstTwo, digest, "layerfs")
63+
path := filepath.Join(fs.fsAbsoluteMountpoint, ".layers", firstTwo, digest, "layerfs")
5664
if _, err := os.Stat(path); os.IsNotExist(err) {
5765
err = fmt.Errorf("layer %s not in the cvmfs repository", digest)
5866
log.G(ctx).WithError(err).WithField("layer digest", digest).WithField("path", path).Debug("cvmfs: Layer not found")

0 commit comments

Comments
 (0)