Source file
src/syscall/syscall_linux_arm.go
1
2
3
4
5 package syscall
6
7 import "unsafe"
8
9 const _SYS_setgroups = SYS_SETGROUPS32
10
11 func setTimespec(sec, nsec int64) Timespec {
12 return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
13 }
14
15 func setTimeval(sec, usec int64) Timeval {
16 return Timeval{Sec: int32(sec), Usec: int32(usec)}
17 }
18
19
20
21 func seek(fd int, offset int64, whence int) (newoffset int64, err Errno)
22
23 func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
24 newoffset, errno := seek(fd, offset, whence)
25 if errno != 0 {
26 return 0, errno
27 }
28 return newoffset, nil
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 func Stat(path string, stat *Stat_t) (err error) {
85 return fstatat(_AT_FDCWD, path, stat, 0)
86 }
87
88 func Lchown(path string, uid int, gid int) (err error) {
89 return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
90 }
91
92 func Lstat(path string, stat *Stat_t) (err error) {
93 return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
94 }
95
96 func Fstatfs(fd int, buf *Statfs_t) (err error) {
97 _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
98 if e != 0 {
99 err = e
100 }
101 return
102 }
103
104 func Statfs(path string, buf *Statfs_t) (err error) {
105 pathp, err := BytePtrFromString(path)
106 if err != nil {
107 return err
108 }
109 _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
110 if e != 0 {
111 err = e
112 }
113 return
114 }
115
116 func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
117 page := uintptr(offset / 4096)
118 if offset != int64(page)*4096 {
119 return 0, EINVAL
120 }
121 return mmap2(addr, length, prot, flags, fd, page)
122 }
123
124 type rlimit32 struct {
125 Cur uint32
126 Max uint32
127 }
128
129
130
131 const rlimInf32 = ^uint32(0)
132 const rlimInf64 = ^uint64(0)
133
134 func Getrlimit(resource int, rlim *Rlimit) (err error) {
135 err = prlimit(0, resource, nil, rlim)
136 if err != ENOSYS {
137 return err
138 }
139
140 rl := rlimit32{}
141 err = getrlimit(resource, &rl)
142 if err != nil {
143 return
144 }
145
146 if rl.Cur == rlimInf32 {
147 rlim.Cur = rlimInf64
148 } else {
149 rlim.Cur = uint64(rl.Cur)
150 }
151
152 if rl.Max == rlimInf32 {
153 rlim.Max = rlimInf64
154 } else {
155 rlim.Max = uint64(rl.Max)
156 }
157 return
158 }
159
160
161
162 func Setrlimit(resource int, rlim *Rlimit) (err error) {
163 err = prlimit(0, resource, rlim, nil)
164 if err != ENOSYS {
165 return err
166 }
167
168 rl := rlimit32{}
169 if rlim.Cur == rlimInf64 {
170 rl.Cur = rlimInf32
171 } else if rlim.Cur < uint64(rlimInf32) {
172 rl.Cur = uint32(rlim.Cur)
173 } else {
174 return EINVAL
175 }
176 if rlim.Max == rlimInf64 {
177 rl.Max = rlimInf32
178 } else if rlim.Max < uint64(rlimInf32) {
179 rl.Max = uint32(rlim.Max)
180 } else {
181 return EINVAL
182 }
183
184 return setrlimit(resource, &rl)
185 }
186
187 func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) }
188
189 func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) }
190
191 func (iov *Iovec) SetLen(length int) {
192 iov.Len = uint32(length)
193 }
194
195 func (msghdr *Msghdr) SetControllen(length int) {
196 msghdr.Controllen = uint32(length)
197 }
198
199 func (cmsg *Cmsghdr) SetLen(length int) {
200 cmsg.Len = uint32(length)
201 }
202
203 func rawVforkSyscall(trap, a1 uintptr) (r1 uintptr, err Errno)
204
View as plain text