INNER CODE UNIT · Go

fileOwner

kubernetes-csi/csi-driver-nfs · pkg/nfs/chmod_unix.go:34

func fileOwner(path string) (int, int, error) {
	info, err := os.Lstat(path)
	if err != nil {
		return unsetOwner, unsetOwner, err
	}
	stat, ok := info.Sys().(*syscall.Stat_t)
	if !ok {
		return unsetOwner, unsetOwner, fmt.Errorf("failed to get uid/gid for %s", path)
	}
	return int(stat.Uid), int(stat.Gid), nil
}

func chownPath(path string, uid, gid int) error {
	// Lchown matches fileOwner's Lstat: do not follow a symlink to a
	// different inode than the path we inspected.
	return os.Lchown(path, uid, gid)
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…