aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/unix2syscall.go
blob: 31620258cf5db6d206672bf925832a1c215e7e91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package syscallcompat

import (
	"syscall"

	"golang.org/x/sys/unix"
)

// Unix2syscall converts a unix.Stat_t struct to a syscall.Stat_t struct.
// A direct cast does not work because the padding is named differently in
// unix.Stat_t for some reason ("X__unused" in syscall, "_" in unix).
func Unix2syscall(u unix.Stat_t) syscall.Stat_t {
	return syscall.Stat_t{
		Dev:     u.Dev,
		Ino:     u.Ino,
		Nlink:   u.Nlink,
		Mode:    u.Mode,
		Uid:     u.Uid,
		Gid:     u.Gid,
		Rdev:    u.Rdev,
		Size:    u.Size,
		Blksize: u.Blksize,
		Blocks:  u.Blocks,
		Atim:    syscall.Timespec(u.Atim),
		Mtim:    syscall.Timespec(u.Mtim),
		Ctim:    syscall.Timespec(u.Ctim),
	}
}