Skip to content

incusd/storage: fix squashfs unpacking to NFS destinations #2148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/linux/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
return FSTypeToName(int32(fs.Type))
}

// IsNfs returns true if the path exists and is NFS

Check failure on line 45 in internal/linux/filesystem.go

View workflow job for this annotation

GitHub Actions / Code (stable)

Comment should end in a period (godot)

Check failure on line 45 in internal/linux/filesystem.go

View workflow job for this annotation

GitHub Actions / Code (tip)

Comment should end in a period (godot)

Check failure on line 45 in internal/linux/filesystem.go

View workflow job for this annotation

GitHub Actions / Code (oldstable)

Comment should end in a period (godot)
func IsNfs(path string) bool {
backingFs, err := DetectFilesystem(path)
if err != nil {
return false
}

return backingFs == "nfs"
}

// FSTypeToName returns the name of the given fs type.
// The fsType is from the Type field of unix.Statfs_t. We use int32 so that this function behaves the same on both
// 32bit and 64bit platforms by requiring any 64bit FS types to be overflowed before being passed in. They will
Expand Down
7 changes: 7 additions & 0 deletions shared/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"golang.org/x/sys/unix"

"github.com/lxc/incus/v6/internal/linux"
"github.com/lxc/incus/v6/shared/ioprogress"
"github.com/lxc/incus/v6/shared/logger"
"github.com/lxc/incus/v6/shared/subprocess"
Expand Down Expand Up @@ -200,6 +201,12 @@ func Unpack(file string, path string, blockBackend bool, maxMemory int64, tracke
}
}

// NFS 4.2 can support xattrs, but not security.xattr
if linux.IsNfs(path) {
logger.Warn("Unpack: destination path is NFS, disabling non-user xatttr unpacking", logger.Ctx{"file": file, "command": command, "extension": extension, "path": path, "args": args})
args = append(args, "-user-xattrs")
}

args = append(args, file)
} else {
return fmt.Errorf("Unsupported image format: %s", extension)
Expand Down
Loading