1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// Copyright (c) 2019-2023, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
//go:build singularity_engine
package squashfs
import (
"fmt"
"github.com/sylabs/singularity/v4/internal/pkg/buildcfg"
"github.com/sylabs/singularity/v4/internal/pkg/util/bin"
"github.com/sylabs/singularity/v4/pkg/util/singularityconf"
)
func getConfig() (*singularityconf.File, error) {
// if the caller has set the current config use it
// otherwise parse the default configuration file
cfg := singularityconf.GetCurrentConfig()
if cfg == nil {
var err error
configFile := buildcfg.SINGULARITY_CONF_FILE
cfg, err = singularityconf.Parse(configFile)
if err != nil {
return nil, fmt.Errorf("unable to parse singularity.conf file: %s", err)
}
}
return cfg, nil
}
// GetPath figures out where the mksquashfs binary is
// and return an error is not available or not usable.
func GetPath() (string, error) {
return bin.FindBin("mksquashfs")
}
func GetProcs() (uint, error) {
c, err := getConfig()
if err != nil {
return 0, err
}
// proc is either "" or the string value in the conf file
proc := c.MksquashfsProcs
return proc, err
}
func GetMem() (string, error) {
c, err := getConfig()
if err != nil {
return "", err
}
// mem is either "" or the string value in the conf file
mem := c.MksquashfsMem
return mem, err
}
|