blob: 95d63c03c587ee2b311fc936665aef9eb5c8092b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package mountmanager
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"path/filepath"
)
// DefaultSocketDir is the default directory for volume sockets.
const DefaultSocketDir = "/var/lib/seaweedfs-mount"
// LocalSocketPath returns the unix socket path used to communicate with the weed mount process.
// The baseDir parameter should be the directory where sockets are stored (e.g., derived from mountEndpoint).
// Uses SHA256 hash (first 16 hex chars = 64 bits) to minimize collision risk.
func LocalSocketPath(baseDir, volumeID string) string {
if baseDir == "" {
baseDir = DefaultSocketDir
}
h := sha256.Sum256([]byte(volumeID))
hashStr := hex.EncodeToString(h[:8]) // 16 hex chars = 64 bits
return filepath.Join(baseDir, fmt.Sprintf("seaweedfs-mount-%s.sock", hashStr))
}
|