vendor: bump c/common to v0.49.2-0.20220929111928-2d1b45ae2423

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
Aditya R
2022-09-29 18:20:00 +05:30
parent b7eee0b2ce
commit f00ceaabd4
26 changed files with 243 additions and 114 deletions

View File

@@ -1,3 +1,4 @@
//go:build !windows && !freebsd
// +build !windows,!freebsd
package system
@@ -8,8 +9,8 @@ import (
// Mknod creates a filesystem node (file, device special file or named pipe) named path
// with attributes specified by mode and dev.
func Mknod(path string, mode uint32, dev int) error {
return unix.Mknod(path, mode, dev)
func Mknod(path string, mode uint32, dev uint32) error {
return unix.Mknod(path, mode, int(dev))
}
// Mkdev is used to build the value of linux devices (in /dev/) which specifies major

View File

@@ -1,3 +1,4 @@
//go:build freebsd
// +build freebsd
package system
@@ -17,6 +18,6 @@ func Mknod(path string, mode uint32, dev uint64) error {
// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes.
// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
// then the top 12 bits of the minor.
func Mkdev(major int64, minor int64) uint32 {
return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
func Mkdev(major int64, minor int64) uint64 {
return uint64(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
}

View File

@@ -35,6 +35,9 @@ func EnsureRemoveAll(dir string) error {
}
for {
if err := resetFileFlags(dir); err != nil {
return fmt.Errorf("resetting file flags: %w", err)
}
err := os.RemoveAll(dir)
if err == nil {
return nil

View File

@@ -0,0 +1,10 @@
//go:build !freebsd
// +build !freebsd
package system
// Reset file flags in a directory tree. This allows EnsureRemoveAll
// to delete trees which have the immutable flag set.
func resetFileFlags(dir string) error {
return nil
}

View File

@@ -0,0 +1,32 @@
package system
import (
"io/fs"
"path/filepath"
"unsafe"
"golang.org/x/sys/unix"
)
func lchflags(path string, flags int) (err error) {
p, err := unix.BytePtrFromString(path)
if err != nil {
return err
}
_, _, e1 := unix.Syscall(unix.SYS_LCHFLAGS, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
if e1 != 0 {
return e1
}
return nil
}
// Reset file flags in a directory tree. This allows EnsureRemoveAll
// to delete trees which have the immutable flag set.
func resetFileFlags(dir string) error {
return filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if err := lchflags(path, 0); err != nil {
return err
}
return nil
})
}