//go:build linux

package appbackup

import (
	"os"
	"syscall"
)

// chownGID sets the GROUP of path (owner unchanged via -1). Setting an arbitrary group requires
// CAP_CHOWN; the in-guest controller runs as root, so this succeeds in production.
func chownGID(path string, gid int) error { return os.Chown(path, -1, gid) }

// StatGID returns the owning GID of fi (Linux). ok=false when the underlying stat is unavailable.
func StatGID(fi os.FileInfo) (int, bool) {
	if st, ok := fi.Sys().(*syscall.Stat_t); ok {
		return int(st.Gid), true
	}
	return -1, false
}
