syscallcompat: OSX: add Mknodat wrapper
Protip: find naked *at syscalls using: git grep "syscall." | grep "at(" | grep -v syscallcompat
This commit is contained in:
parent
d8524c7369
commit
741bf0726e
@ -205,7 +205,7 @@ func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create device node
|
// Create device node
|
||||||
err = syscall.Mknodat(int(dirfd.Fd()), cName, uint32(mode), int(dev))
|
err = syscallcompat.Mknodat(int(dirfd.Fd()), cName, uint32(mode), int(dev))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
nametransform.DeleteLongName(dirfd, cName)
|
nametransform.DeleteLongName(dirfd, cName)
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,24 @@ func Unlinkat(dirfd int, path string) (err error) {
|
|||||||
return syscall.Unlink(path)
|
return syscall.Unlink(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Poor man's Mknodat
|
||||||
|
func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
|
||||||
|
chdirMutex.Lock()
|
||||||
|
defer chdirMutex.Unlock()
|
||||||
|
if !filepath.IsAbs(path) {
|
||||||
|
oldWd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.Chdir(oldWd)
|
||||||
|
}
|
||||||
|
path, err = dirfdAbs(dirfd, path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return syscall.Mknod(path, mode, dev)
|
||||||
|
}
|
||||||
|
|
||||||
// dirfdAbs transforms the dirfd-relative "path" to an absolute one. If the
|
// dirfdAbs transforms the dirfd-relative "path" to an absolute one. If the
|
||||||
// path is not already absolute, this function will change the working
|
// path is not already absolute, this function will change the working
|
||||||
// directory. The caller has to chdir back.
|
// directory. The caller has to chdir back.
|
||||||
|
@ -52,3 +52,7 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e
|
|||||||
func Unlinkat(dirfd int, path string) error {
|
func Unlinkat(dirfd int, path string) error {
|
||||||
return syscall.Unlinkat(dirfd, path)
|
return syscall.Unlinkat(dirfd, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
|
||||||
|
return syscall.Mknodat(dirfd, path, mode, dev)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user