Documentation ¶
Overview ¶
Package syscallcompat wraps Linux-specific syscalls.
Index ¶
- Constants
- func Dup3(oldfd int, newfd int, flags int) (err error)
- func EnospcPrealloc(fd int, off int64, len int64) (err error)
- func Faccessat(dirfd int, path string, mode uint32) error
- func Fallocate(fd int, mode uint32, off int64, len int64) (err error)
- func FchmodatNofollow(dirfd int, path string, mode uint32) (err error)
- func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
- func Fgetxattr(fd int, attr string) (val []byte, err error)
- func Flistxattr(fd int) (attrs []string, err error)
- func Fstatat(dirfd int, path string, stat *unix.Stat_t, flags int) (err error)
- func FutimesNano(fd int, a *time.Time, m *time.Time) (err error)
- func Getdents(fd int) ([]fuse.DirEntry, error)
- func IsENOSPC(err error) bool
- func Lgetxattr(path string, attr string) (val []byte, err error)
- func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
- func Llistxattr(path string) (attrs []string, err error)
- func Mkdirat(dirfd int, path string, mode uint32) (err error)
- func MkdiratUser(dirfd int, path string, mode uint32, context *fuse.Context) (err error)
- func Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
- func MknodatUser(dirfd int, path string, mode uint32, dev int, context *fuse.Context) (err error)
- func OpenDirNofollow(baseDir string, relPath string) (fd int, err error)
- func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
- func OpenatUser(dirfd int, path string, flags int, mode uint32, context *fuse.Context) (fd int, err error)
- func Readlinkat(dirfd int, path string) (string, error)
- func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
- func Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
- func SymlinkatUser(oldpath string, newdirfd int, newpath string, context *fuse.Context) (err error)
- func Unix2syscall(u unix.Stat_t) syscall.Stat_t
- func Unlinkat(dirfd int, path string, flags int) (err error)
- func UtimesNanoAtNofollow(dirfd int, path string, a *time.Time, m *time.Time) (err error)
Constants ¶
const ( // O_DIRECT means oncached I/O on Linux. No direct equivalent on MacOS and defined // to zero there. O_DIRECT = syscall.O_DIRECT // O_PATH is only defined on Linux O_PATH = unix.O_PATH )
const PATH_MAX = 4096
PATH_MAX is the maximum allowed path length on Linux. It is not defined on Darwin, so we use the Linux value.
const XATTR_BUFSZ = XATTR_SIZE_MAX + 1024
Make the buffer 1kB bigger so we can detect overflows
const XATTR_SIZE_MAX = 65536
Variables ¶
This section is empty.
Functions ¶
func Dup3 ¶ added in v1.4.1
Dup3 wraps the Dup3 syscall. We want to use Dup3 rather than Dup2 because Dup2 is not implemented on arm64.
func EnospcPrealloc ¶
EnospcPrealloc preallocates ciphertext space without changing the file size. This guarantees that we don't run out of space while writing a ciphertext block (that would corrupt the block).
func Faccessat ¶ added in v1.4.3
Faccessat exists both in Linux and in MacOS 10.10+, but the Linux version DOES NOT support any flags. Emulate AT_SYMLINK_NOFOLLOW like glibc does.
func FchmodatNofollow ¶ added in v1.7.1
FchmodatNofollow is like Fchmodat but never follows symlinks.
This should be handled by the AT_SYMLINK_NOFOLLOW flag, but Linux does not implement it, so we have to perform an elaborate dance with O_PATH and /proc/self/fd.
See also: Qemu implemented the same logic as fchmodat_nofollow(): https://git.qemu.org/?p=qemu.git;a=blob;f=hw/9pfs/9p-local.c#l335
func Fgetxattr ¶ added in v1.7.1
Fgetxattr is a wrapper around unix.Fgetxattr that handles the buffer sizing.
func Flistxattr ¶ added in v1.7.1
Flistxattr is a wrapper for unix.Flistxattr that handles buffer sizing and parsing the returned blob to a string slice.
func FutimesNano ¶ added in v1.7.1
FutimesNano syscall.
func IsENOSPC ¶ added in v1.6.1
IsENOSPC tries to find out if "err" is a (potentially wrapped) ENOSPC error.
func Lgetxattr ¶ added in v1.7.1
Lgetxattr is a wrapper around unix.Lgetxattr that handles the buffer sizing.
func Llistxattr ¶ added in v1.7.1
Llistxattr is a wrapper for unix.Llistxattr that handles buffer sizing and parsing the returned blob to a string slice.
func MkdiratUser ¶ added in v1.7.1
MkdiratUser runs the Mkdirat syscall in the context of a different user.
func MknodatUser ¶ added in v1.7.1
MknodatUser runs the Mknodat syscall in the context of a different user.
func OpenDirNofollow ¶ added in v1.7.1
OpenDirNofollow opens the dir at "relPath" in a way that is secure against symlink attacks. Symlinks that are part of "relPath" are never followed. This function is implemented by walking the directory tree, starting at "baseDir", using the Openat syscall with the O_NOFOLLOW flag. Symlinks that are part of the "baseDir" path are followed.
func OpenatUser ¶ added in v1.7.1
func OpenatUser(dirfd int, path string, flags int, mode uint32, context *fuse.Context) (fd int, err error)
OpenatUser runs the Openat syscall in the context of a different user.
func Readlinkat ¶ added in v1.4.3
Readlinkat is a convenience wrapper around unix.Readlinkat() that takes care of buffer sizing. Implemented like os.Readlink().
func SymlinkatUser ¶ added in v1.7.1
SymlinkatUser runs the Symlinkat syscall in the context of a different user.
func Unix2syscall ¶ added in v1.4.3
Unix2syscall converts a unix.Stat_t struct to a syscall.Stat_t struct. A direct cast does not work because the padding is named differently in unix.Stat_t for some reason ("X__unused" in syscall, "_" in unix).
Types ¶
This section is empty.