mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/syscall/windows: increase internal Windows O_ flags values
The lowercase o_ flags are invented values. These conflict with constants that will soon be allowed by os.OpenFile, which values will be mandated by the Windows API. To avoid this overlap, the internal values have been increased to the 33-63 bit range, as the Windows ones are in the 0-32 bit range. Updates #73676 Change-Id: I0f657f3ed3403de150f1730a5a65ae887a18a4e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/697363 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
9d3f7fda70
commit
d86ec92499
3 changed files with 13 additions and 12 deletions
|
|
@ -13,16 +13,17 @@ import (
|
||||||
|
|
||||||
// Openat flags not supported by syscall.Open.
|
// Openat flags not supported by syscall.Open.
|
||||||
//
|
//
|
||||||
// These are invented values.
|
// These are invented values, use values in the 33-63 bit range
|
||||||
|
// to avoid overlap with flags and attributes supported by [syscall.Open].
|
||||||
//
|
//
|
||||||
// When adding a new flag here, add an unexported version to
|
// When adding a new flag here, add an unexported version to
|
||||||
// the set of invented O_ values in syscall/types_windows.go
|
// the set of invented O_ values in syscall/types_windows.go
|
||||||
// to avoid overlap.
|
// to avoid overlap.
|
||||||
const (
|
const (
|
||||||
O_DIRECTORY = 0x100000 // target must be a directory
|
O_DIRECTORY = 0x100000000 // target must be a directory
|
||||||
O_NOFOLLOW_ANY = 0x20000000 // disallow symlinks anywhere in the path
|
O_NOFOLLOW_ANY = 0x200000000 // disallow symlinks anywhere in the path
|
||||||
O_OPEN_REPARSE = 0x40000000 // FILE_OPEN_REPARSE_POINT, used by Lstat
|
O_OPEN_REPARSE = 0x400000000 // FILE_OPEN_REPARSE_POINT, used by Lstat
|
||||||
O_WRITE_ATTRS = 0x80000000 // FILE_WRITE_ATTRIBUTES, used by Chmod
|
O_WRITE_ATTRS = 0x800000000 // FILE_WRITE_ATTRIBUTES, used by Chmod
|
||||||
)
|
)
|
||||||
|
|
||||||
func Openat(dirfd syscall.Handle, name string, flag uint64, perm uint32) (_ syscall.Handle, e1 error) {
|
func Openat(dirfd syscall.Handle, name string, flag uint64, perm uint32) (_ syscall.Handle, e1 error) {
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ func openRootInRoot(r *Root, name string) (*Root, error) {
|
||||||
// rootOpenFileNolog is Root.OpenFile.
|
// rootOpenFileNolog is Root.OpenFile.
|
||||||
func rootOpenFileNolog(root *Root, name string, flag int, perm FileMode) (*File, error) {
|
func rootOpenFileNolog(root *Root, name string, flag int, perm FileMode) (*File, error) {
|
||||||
fd, err := doInRoot(root, name, nil, func(parent syscall.Handle, name string) (syscall.Handle, error) {
|
fd, err := doInRoot(root, name, nil, func(parent syscall.Handle, name string) (syscall.Handle, error) {
|
||||||
return openat(parent, name, flag, perm)
|
return openat(parent, name, uint64(flag), perm)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &PathError{Op: "openat", Path: name, Err: err}
|
return nil, &PathError{Op: "openat", Path: name, Err: err}
|
||||||
|
|
@ -138,8 +138,8 @@ func rootOpenFileNolog(root *Root, name string, flag int, perm FileMode) (*File,
|
||||||
return newFile(fd, joinPath(root.Name(), name), "file", false), nil
|
return newFile(fd, joinPath(root.Name(), name), "file", false), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func openat(dirfd syscall.Handle, name string, flag int, perm FileMode) (syscall.Handle, error) {
|
func openat(dirfd syscall.Handle, name string, flag uint64, perm FileMode) (syscall.Handle, error) {
|
||||||
h, err := windows.Openat(dirfd, name, uint64(flag)|syscall.O_CLOEXEC|windows.O_NOFOLLOW_ANY, syscallMode(perm))
|
h, err := windows.Openat(dirfd, name, flag|syscall.O_CLOEXEC|windows.O_NOFOLLOW_ANY, syscallMode(perm))
|
||||||
if err == syscall.ELOOP || err == syscall.ENOTDIR {
|
if err == syscall.ELOOP || err == syscall.ENOTDIR {
|
||||||
if link, err := readReparseLinkAt(dirfd, name); err == nil {
|
if link, err := readReparseLinkAt(dirfd, name); err == nil {
|
||||||
return syscall.InvalidHandle, errSymlink(link)
|
return syscall.InvalidHandle, errSymlink(link)
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ const (
|
||||||
O_SYNC = 0x01000
|
O_SYNC = 0x01000
|
||||||
O_ASYNC = 0x02000
|
O_ASYNC = 0x02000
|
||||||
O_CLOEXEC = 0x80000
|
O_CLOEXEC = 0x80000
|
||||||
o_DIRECTORY = 0x100000 // used by internal/syscall/windows
|
o_DIRECTORY = 0x100000000 // used by internal/syscall/windows
|
||||||
o_NOFOLLOW_ANY = 0x20000000 // used by internal/syscall/windows
|
o_NOFOLLOW_ANY = 0x200000000 // used by internal/syscall/windows
|
||||||
o_OPEN_REPARSE = 0x40000000 // used by internal/syscall/windows
|
o_OPEN_REPARSE = 0x400000000 // used by internal/syscall/windows
|
||||||
o_WRITE_ATTRS = 0x80000000 // used by internal/syscall/windows
|
o_WRITE_ATTRS = 0x800000000 // used by internal/syscall/windows
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue