mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-13 04:03:16 +02:00
Bloody lazy Crapple
No mknodat. Sigh.
This commit is contained in:
@@ -347,12 +347,7 @@ func ConvertFileModeToUnix(goMode os.FileMode) uint32 {
|
||||
|
||||
func MknodAt(parent *os.File, name string, mode os.FileMode, dev int) (err error) {
|
||||
unix_mode := ConvertFileModeToUnix(mode)
|
||||
for {
|
||||
if err = unix.Mknodat(int(parent.Fd()), name, unix_mode, dev); err != unix.EINTR {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if err = mknodAt(parent, name, unix_mode, dev); err != nil {
|
||||
err = &os.PathError{Op: "mknodat", Path: filepath.Join(parent.Name(), name), Err: err}
|
||||
}
|
||||
return
|
||||
|
||||
21
tools/utils/file_at_fd_darwin.go
Normal file
21
tools/utils/file_at_fd_darwin.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func mknodAt(parent *os.File, name string, mode uint32, dev int) (err error) {
|
||||
path := filepath.Join(parent.Name(), name)
|
||||
for {
|
||||
if err = unix.Mknod(path, mode, dev); err != unix.EINTR {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
21
tools/utils/file_at_fd_generic.go
Normal file
21
tools/utils/file_at_fd_generic.go
Normal file
@@ -0,0 +1,21 @@
|
||||
//go:build !darwin
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func mknodAt(parent *os.File, name string, mode uint32, dev int) (err error) {
|
||||
for {
|
||||
if err = unix.Mknodat(int(parent.Fd()), name, mode, dev); err != unix.EINTR {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user