Skip to content

Commit ac42ca8

Browse files
authored
Merge pull request #2149 from stgraber/main
incusd/storage: Fix squashfs unpacking to NFS destinations
2 parents c4e01a3 + 4746333 commit ac42ca8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

internal/linux/filesystem.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ func DetectFilesystem(path string) (string, error) {
4242
return FSTypeToName(int32(fs.Type))
4343
}
4444

45+
// IsNFS returns true if the path exists and is on a NFS mount.
46+
func IsNFS(path string) bool {
47+
backingFs, err := DetectFilesystem(path)
48+
if err != nil {
49+
return false
50+
}
51+
52+
return backingFs == "nfs"
53+
}
54+
4555
// FSTypeToName returns the name of the given fs type.
4656
// The fsType is from the Type field of unix.Statfs_t. We use int32 so that this function behaves the same on both
4757
// 32bit and 64bit platforms by requiring any 64bit FS types to be overflowed before being passed in. They will

shared/archive/archive.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"golang.org/x/sys/unix"
1717

18+
"github.com/lxc/incus/v6/internal/linux"
1819
"github.com/lxc/incus/v6/shared/ioprogress"
1920
"github.com/lxc/incus/v6/shared/logger"
2021
"github.com/lxc/incus/v6/shared/subprocess"
@@ -200,6 +201,13 @@ func Unpack(file string, path string, blockBackend bool, maxMemory int64, tracke
200201
}
201202
}
202203

204+
// NFS 4.2 can support xattrs, but not security.xattr.
205+
if linux.IsNFS(path) {
206+
logger.Warn("Unpack: destination path is NFS, disabling non-user xatttr unpacking", logger.Ctx{"file": file, "command": command, "extension": extension, "path": path, "args": args})
207+
208+
args = append(args, "-user-xattrs")
209+
}
210+
203211
args = append(args, file)
204212
} else {
205213
return fmt.Errorf("Unsupported image format: %s", extension)

0 commit comments

Comments
 (0)