diff --git a/c/syscall/unix/at_sysnum_darwin.go b/c/syscall/unix/at_sysnum_darwin.go new file mode 100644 index 00000000..208ff34d --- /dev/null +++ b/c/syscall/unix/at_sysnum_darwin.go @@ -0,0 +1,10 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const AT_REMOVEDIR = 0x80 +const AT_SYMLINK_NOFOLLOW = 0x0020 + +const UTIME_OMIT = -0x2 diff --git a/c/syscall/unix/at_sysnum_dragonfly.go b/c/syscall/unix/at_sysnum_dragonfly.go new file mode 100644 index 00000000..b7ed3f73 --- /dev/null +++ b/c/syscall/unix/at_sysnum_dragonfly.go @@ -0,0 +1,16 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import "syscall" + +const unlinkatTrap uintptr = syscall.SYS_UNLINKAT +const openatTrap uintptr = syscall.SYS_OPENAT +const fstatatTrap uintptr = syscall.SYS_FSTATAT + +const AT_REMOVEDIR = 0x2 +const AT_SYMLINK_NOFOLLOW = 0x1 + +const UTIME_OMIT = -0x1 diff --git a/c/syscall/unix/at_sysnum_freebsd.go b/c/syscall/unix/at_sysnum_freebsd.go new file mode 100644 index 00000000..9cd5da6c --- /dev/null +++ b/c/syscall/unix/at_sysnum_freebsd.go @@ -0,0 +1,18 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import "syscall" + +const ( + AT_REMOVEDIR = 0x800 + AT_SYMLINK_NOFOLLOW = 0x200 + + UTIME_OMIT = -0x2 + + unlinkatTrap uintptr = syscall.SYS_UNLINKAT + openatTrap uintptr = syscall.SYS_OPENAT + posixFallocateTrap uintptr = syscall.SYS_POSIX_FALLOCATE +) diff --git a/c/syscall/unix/at_sysnum_fstatat64_linux.go b/c/syscall/unix/at_sysnum_fstatat64_linux.go new file mode 100644 index 00000000..445b0c38 --- /dev/null +++ b/c/syscall/unix/at_sysnum_fstatat64_linux.go @@ -0,0 +1,11 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build arm || mips || mipsle || 386 + +package unix + +import "syscall" + +const fstatatTrap uintptr = syscall.SYS_FSTATAT64 diff --git a/c/syscall/unix/at_sysnum_fstatat_linux.go b/c/syscall/unix/at_sysnum_fstatat_linux.go new file mode 100644 index 00000000..73a3da5b --- /dev/null +++ b/c/syscall/unix/at_sysnum_fstatat_linux.go @@ -0,0 +1,11 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build arm64 || riscv64 + +package unix + +import "syscall" + +const fstatatTrap uintptr = syscall.SYS_FSTATAT diff --git a/c/syscall/unix/at_sysnum_linux.go b/c/syscall/unix/at_sysnum_linux.go new file mode 100644 index 00000000..7c3b15c3 --- /dev/null +++ b/c/syscall/unix/at_sysnum_linux.go @@ -0,0 +1,19 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import "syscall" + +const unlinkatTrap uintptr = syscall.SYS_UNLINKAT +const openatTrap uintptr = syscall.SYS_OPENAT + +const ( + AT_EACCESS = 0x200 + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_NOFOLLOW = 0x100 + + UTIME_OMIT = 0x3ffffffe +) diff --git a/c/syscall/unix/at_sysnum_netbsd.go b/c/syscall/unix/at_sysnum_netbsd.go new file mode 100644 index 00000000..becc1bdf --- /dev/null +++ b/c/syscall/unix/at_sysnum_netbsd.go @@ -0,0 +1,16 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import "syscall" + +const unlinkatTrap uintptr = syscall.SYS_UNLINKAT +const openatTrap uintptr = syscall.SYS_OPENAT +const fstatatTrap uintptr = syscall.SYS_FSTATAT + +const AT_REMOVEDIR = 0x800 +const AT_SYMLINK_NOFOLLOW = 0x200 + +const UTIME_OMIT = (1 << 30) - 2 diff --git a/c/syscall/unix/at_sysnum_newfstatat_linux.go b/c/syscall/unix/at_sysnum_newfstatat_linux.go new file mode 100644 index 00000000..76edf675 --- /dev/null +++ b/c/syscall/unix/at_sysnum_newfstatat_linux.go @@ -0,0 +1,11 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build amd64 || mips64 || mips64le || ppc64 || ppc64le || s390x + +package unix + +import "syscall" + +const fstatatTrap uintptr = syscall.SYS_NEWFSTATAT diff --git a/c/syscall/unix/at_sysnum_openbsd.go b/c/syscall/unix/at_sysnum_openbsd.go new file mode 100644 index 00000000..fd389477 --- /dev/null +++ b/c/syscall/unix/at_sysnum_openbsd.go @@ -0,0 +1,16 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import "syscall" + +const unlinkatTrap uintptr = syscall.SYS_UNLINKAT +const openatTrap uintptr = syscall.SYS_OPENAT +const fstatatTrap uintptr = syscall.SYS_FSTATAT + +const AT_REMOVEDIR = 0x08 +const AT_SYMLINK_NOFOLLOW = 0x02 + +const UTIME_OMIT = -0x1 diff --git a/internal/lib/os/exec/unix_eaccess_linux.go b/internal/lib/os/exec/unix_eaccess_linux.go index 68d250b9..3d6a1389 100644 --- a/internal/lib/os/exec/unix_eaccess_linux.go +++ b/internal/lib/os/exec/unix_eaccess_linux.go @@ -4,8 +4,12 @@ package exec -import "syscall" +import ( + "syscall" + + "github.com/goplus/llgo/c/syscall/unix" +) func unixEaccess(path string, mode uint32) error { - return syscall.Faccessat(AT_FDCWD, path, mode, AT_EACCESS) + return syscall.Faccessat(unix.AT_FDCWD, path, mode, unix.AT_EACCESS) } diff --git a/internal/lib/os/file_unix.go b/internal/lib/os/file_unix.go index 1450ff18..fe390562 100644 --- a/internal/lib/os/file_unix.go +++ b/internal/lib/os/file_unix.go @@ -7,7 +7,6 @@ package os import ( - "io/fs" "runtime" ) @@ -173,7 +172,10 @@ func (d *unixDirent) Info() (FileInfo, error) { } func (d *unixDirent) String() string { + /* TODO(xsw): return fs.FormatDirEntry(d) + */ + panic("todo: os.unixDirent.String") } /* TODO(xsw): diff --git a/internal/lib/syscall/syscall_linux.go b/internal/lib/syscall/syscall_linux.go new file mode 100644 index 00000000..a3e05ff2 --- /dev/null +++ b/internal/lib/syscall/syscall_linux.go @@ -0,0 +1,16 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Linux system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and +// wrap it in our own nicer implementation. + +package syscall + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + panic("todo: syscall.Faccessat") +}