forked from someonegg/pathfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyscall_linux.go
More file actions
54 lines (46 loc) · 1.46 KB
/
syscall_linux.go
File metadata and controls
54 lines (46 loc) · 1.46 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package pathfs
import (
"syscall"
"testing"
"time"
)
func utimes(path string, atime *time.Time, mtime *time.Time) error {
timevals := []syscall.Timeval{
{Sec: atime.Unix(), Usec: int64(atime.Nanosecond())},
{Sec: mtime.Unix(), Usec: int64(mtime.Nanosecond())},
}
return syscall.Utimes(path, timevals)
}
func fUtimes(fd int, atime *time.Time, mtime *time.Time) error {
timevals := []syscall.Timeval{
{Sec: atime.Unix(), Usec: int64(atime.Nanosecond())},
{Sec: mtime.Unix(), Usec: int64(mtime.Nanosecond())},
}
return syscall.Futimes(fd, timevals)
}
func setXAttr(path string, attr string, data []byte, flags int) error {
return syscall.Setxattr(path, attr, data, flags)
}
func removeXAttr(path string, attr string) error {
return syscall.Removexattr(path, attr)
}
func getXAttrSyscall(path string, attr string, dest []byte) (int, error) {
return syscall.Getxattr(path, attr, dest)
}
func listXAttrSyscall(path string, dest []byte) (int, error) {
return syscall.Listxattr(path, dest)
}
func verifyAttrTesting(t *testing.T, st *syscall.Stat_t, mode uint32, timeVal []syscall.Timeval, fileSize int64) {
if st.Mode != mode {
t.Errorf("want mode %o, have %o", mode, st.Mode)
}
if st.Atim.Sec != timeVal[0].Sec {
t.Errorf("want atime %d, have %d", timeVal[0].Sec, st.Atim.Sec)
}
if st.Mtim.Sec != timeVal[1].Sec {
t.Errorf("want mtime %d, have %d", timeVal[1].Sec, st.Mtim.Sec)
}
if st.Size != fileSize {
t.Errorf("want size %d, have %d", fileSize, st.Size)
}
}