1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 const direntSize
= 8 + 8 + 2 + 256
21 func direntIno(buf
[]byte) (uint64, bool) {
25 func direntReclen(buf
[]byte) (uint64, bool) {
26 return readInt(buf
, unsafe
.Offsetof(Dirent
{}.Reclen
), unsafe
.Sizeof(Dirent
{}.Reclen
))
29 func direntNamlen(buf
[]byte) (uint64, bool) {
30 reclen
, ok
:= direntReclen(buf
)
34 return reclen
- uint64(unsafe
.Offsetof(Dirent
{}.Name
)), true
39 // An Errno is an unsigned number describing an error condition.
40 // It implements the error interface. The zero Errno is by convention
41 // a non-error, so code to convert from Errno to error should use:
48 func (e Errno
) Error() string {
49 if 0 <= int(e
) && int(e
) < len(errorstr
) {
55 return "errno " + itoa(int(e
))
58 func (e Errno
) Temporary() bool {
59 return e
== EINTR || e
== EMFILE || e
.Timeout()
62 func (e Errno
) Timeout() bool {
63 return e
== EAGAIN || e
== EWOULDBLOCK || e
== ETIMEDOUT
66 // A Signal is a number describing a process signal.
67 // It implements the os.Signal interface.
79 func (s Signal
) Signal() {}
81 func (s Signal
) String() string {
82 if 0 <= s
&& int(s
) < len(signals
) {
88 return "signal " + itoa(int(s
))
91 var signals
= [...]string{}
140 S_IFSHM_SYSV
= 0000300000
141 S_IFSEMA
= 0000270000
142 S_IFCOND
= 0000260000
143 S_IFMUTEX
= 0000250000
145 S_IFBOUNDSOCK
= 0000230000
146 S_IFSOCKADDR
= 0000220000
147 S_IFDSOCK
= 0000210000
149 S_IFSOCK
= 0000140000
203 // Not supported - just enough for package os.
205 var ForkLock sync
.RWMutex
207 type WaitStatus
uint32
209 func (w WaitStatus
) Exited() bool { return false }
210 func (w WaitStatus
) ExitStatus() int { return 0 }
211 func (w WaitStatus
) Signaled() bool { return false }
212 func (w WaitStatus
) Signal() Signal
{ return 0 }
213 func (w WaitStatus
) CoreDump() bool { return false }
214 func (w WaitStatus
) Stopped() bool { return false }
215 func (w WaitStatus
) Continued() bool { return false }
216 func (w WaitStatus
) StopSignal() Signal
{ return 0 }
217 func (w WaitStatus
) TrapCause() int { return 0 }
226 type ProcAttr
struct {
233 type SysProcAttr
struct {
236 func Syscall(trap
, a1
, a2
, a3
uintptr) (r1
, r2
uintptr, err Errno
) {
240 func Syscall6(trap
, a1
, a2
, a3
, a4
, a5
, a6
uintptr) (r1
, r2
uintptr, err Errno
) {
244 func RawSyscall(trap
, a1
, a2
, a3
uintptr) (r1
, r2
uintptr, err Errno
) {
248 func RawSyscall6(trap
, a1
, a2
, a3
, a4
, a5
, a6
uintptr) (r1
, r2
uintptr, err Errno
) {
252 func Sysctl(key
string) (string, error
) {
253 if key
== "kern.hostname" {
259 const ImplementsGetwd
= true
261 func Getwd() (wd
string, err error
) {
262 var buf
[PathMax
]byte
263 n
, err
:= Getcwd(buf
[0:])
267 return string(buf
[:n
]), nil
270 func Getegid() int { return 1 }
271 func Geteuid() int { return 1 }
272 func Getgid() int { return 1 }
273 func Getgroups() ([]int, error
) { return []int{1}, nil }
274 func Getppid() int { return 2 }
275 func Getpid() int { return 3 }
276 func Gettimeofday(tv
*Timeval
) error
{ return ENOSYS
}
277 func Getuid() int { return 1 }
278 func Kill(pid
int, signum Signal
) error
{ return ENOSYS
}
279 func Sendfile(outfd
int, infd
int, offset
*int64, count
int) (written
int, err error
) {
282 func StartProcess(argv0
string, argv
[]string, attr
*ProcAttr
) (pid
int, handle
uintptr, err error
) {
285 func Wait4(pid
int, wstatus
*WaitStatus
, options
int, rusage
*Rusage
) (wpid
int, err error
) {
289 type Iovec
struct{} // dummy
291 type Timespec
struct {
296 type Timeval
struct {
301 func setTimespec(sec
, nsec
int64) Timespec
{
302 return Timespec
{Sec
: sec
, Nsec
: nsec
}
305 func setTimeval(sec
, usec
int64) Timeval
{
306 return Timeval
{Sec
: sec
, Usec
: usec
}