@@ -24,22 +24,30 @@ const (
2424)
2525
2626type 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
3232type 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
3637func 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
4553func (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