2016-07-03 17:51:40 +02:00
|
|
|
package syscallcompat
|
2016-01-07 21:39:41 +01:00
|
|
|
|
2016-07-03 19:14:12 +02:00
|
|
|
import (
|
2017-06-18 15:40:38 +02:00
|
|
|
"log"
|
2016-07-03 19:14:12 +02:00
|
|
|
"syscall"
|
2017-12-03 17:53:14 +01:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
|
|
|
|
"github.com/hanwen/go-fuse/fuse"
|
2016-07-03 19:14:12 +02:00
|
|
|
)
|
|
|
|
|
2018-09-08 18:06:33 +02:00
|
|
|
const (
|
|
|
|
// O_DIRECT means oncached I/O on Linux. No direct equivalent on MacOS and defined
|
|
|
|
// to zero there.
|
|
|
|
O_DIRECT = 0
|
|
|
|
|
|
|
|
// O_PATH is only defined on Linux
|
|
|
|
O_PATH = 0
|
|
|
|
)
|
2018-07-04 09:04:00 +02:00
|
|
|
|
2016-07-03 20:05:32 +02:00
|
|
|
// Sorry, fallocate is not available on OSX at all and
|
|
|
|
// fcntl F_PREALLOCATE is not accessible from Go.
|
|
|
|
// See https://github.com/rfjakob/gocryptfs/issues/18 if you want to help.
|
2017-02-16 19:23:17 +01:00
|
|
|
func EnospcPrealloc(fd int, off int64, len int64) error {
|
2016-01-09 13:04:48 +01:00
|
|
|
return nil
|
2016-01-07 21:39:41 +01:00
|
|
|
}
|
2016-07-03 19:14:12 +02:00
|
|
|
|
2016-07-03 20:05:32 +02:00
|
|
|
// See above.
|
2017-02-16 19:23:17 +01:00
|
|
|
func Fallocate(fd int, mode uint32, off int64, len int64) error {
|
2016-07-03 20:05:32 +02:00
|
|
|
return syscall.EOPNOTSUPP
|
|
|
|
}
|
2016-07-03 19:14:12 +02:00
|
|
|
|
2017-11-30 17:07:55 +01:00
|
|
|
// Dup3 is not available on Darwin, so we use Dup2 instead.
|
|
|
|
func Dup3(oldfd int, newfd int, flags int) (err error) {
|
|
|
|
if flags != 0 {
|
|
|
|
log.Panic("darwin does not support dup3 flags")
|
2016-07-03 20:05:32 +02:00
|
|
|
}
|
2017-11-30 17:07:55 +01:00
|
|
|
return syscall.Dup2(oldfd, newfd)
|
2016-07-03 20:05:32 +02:00
|
|
|
}
|
2016-07-03 19:14:12 +02:00
|
|
|
|
2017-11-30 17:07:55 +01:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//// Emulated Syscalls (see emulate.go) ////////////////
|
|
|
|
////////////////////////////////////////////////////////
|
2016-07-03 19:14:12 +02:00
|
|
|
|
2017-11-30 17:07:55 +01:00
|
|
|
func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
|
|
|
|
return emulateOpenat(dirfd, path, flags, mode)
|
2016-07-03 20:17:40 +02:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:07:55 +01:00
|
|
|
func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
|
|
|
|
return emulateRenameat(olddirfd, oldpath, newdirfd, newpath)
|
2016-07-03 20:21:29 +02:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:07:55 +01:00
|
|
|
func Unlinkat(dirfd int, path string, flags int) (err error) {
|
|
|
|
return emulateUnlinkat(dirfd, path, flags)
|
2016-07-03 19:14:12 +02:00
|
|
|
}
|
2017-06-18 15:40:38 +02:00
|
|
|
|
2017-11-30 17:07:55 +01:00
|
|
|
func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
|
|
|
|
return emulateMknodat(dirfd, path, mode, dev)
|
2017-06-18 15:40:38 +02:00
|
|
|
}
|
2017-11-26 21:59:24 +01:00
|
|
|
|
2017-11-29 12:54:34 +01:00
|
|
|
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
|
2017-11-30 17:07:55 +01:00
|
|
|
return emulateFchmodat(dirfd, path, mode, flags)
|
2017-11-29 12:54:34 +01:00
|
|
|
}
|
|
|
|
|
2017-11-26 21:59:24 +01:00
|
|
|
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
|
2017-11-30 17:07:55 +01:00
|
|
|
return emulateFchownat(dirfd, path, uid, gid, flags)
|
2017-11-26 21:59:24 +01:00
|
|
|
}
|
2017-11-28 00:54:38 +01:00
|
|
|
|
|
|
|
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
|
2017-11-30 17:07:55 +01:00
|
|
|
return emulateSymlinkat(oldpath, newdirfd, newpath)
|
2017-11-28 00:54:38 +01:00
|
|
|
}
|
2017-11-29 13:21:28 +01:00
|
|
|
|
|
|
|
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
|
2017-11-30 17:07:55 +01:00
|
|
|
return emulateMkdirat(dirfd, path, mode)
|
2017-11-29 13:21:28 +01:00
|
|
|
}
|
2017-12-03 17:53:14 +01:00
|
|
|
|
|
|
|
func Fstatat(dirfd int, path string, stat *unix.Stat_t, flags int) (err error) {
|
|
|
|
return emulateFstatat(dirfd, path, stat, flags)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Getdents(fd int) ([]fuse.DirEntry, error) {
|
|
|
|
return emulateGetdents(fd)
|
|
|
|
}
|