aboutsummaryrefslogtreecommitdiff
path: root/internal/nametransform
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-07-03 20:17:40 +0200
committerJakob Unterwurzacher2016-07-03 20:17:40 +0200
commitd8524c73696392c7e895e6b3fe4c7e120d7296f7 (patch)
treefa071f1ffb9946bfdd152c2ab7c5e9496b3ea52e /internal/nametransform
parent1d7728959c2120cd9bc0f1280cbdd1daccaa497c (diff)
syscallcompat: OSX: add Unlinkat wrapper
Also, replace remaining naked syscall.Openat calls.
Diffstat (limited to 'internal/nametransform')
-rw-r--r--internal/nametransform/diriv.go3
-rw-r--r--internal/nametransform/longnames.go5
2 files changed, 5 insertions, 3 deletions
diff --git a/internal/nametransform/diriv.go b/internal/nametransform/diriv.go
index b9473aa..51af1c3 100644
--- a/internal/nametransform/diriv.go
+++ b/internal/nametransform/diriv.go
@@ -9,6 +9,7 @@ import (
"syscall"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
+ "github.com/rfjakob/gocryptfs/internal/syscallcompat"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
@@ -35,7 +36,7 @@ func ReadDirIV(dir string) (iv []byte, err error) {
// ReadDirIVAt reads "gocryptfs.diriv" from the directory that is opened as "dirfd".
// Using the dirfd makes it immune to concurrent renames of the directory.
func ReadDirIVAt(dirfd *os.File) (iv []byte, err error) {
- fdRaw, err := syscall.Openat(int(dirfd.Fd()), DirIVFilename, syscall.O_RDONLY, 0)
+ fdRaw, err := syscallcompat.Openat(int(dirfd.Fd()), DirIVFilename, syscall.O_RDONLY, 0)
if err != nil {
tlog.Warn.Printf("ReadDirIVAt: opening %q in dir %q failed: %v",
DirIVFilename, dirfd.Name(), err)
diff --git a/internal/nametransform/longnames.go b/internal/nametransform/longnames.go
index 13bedb3..cf7f34c 100644
--- a/internal/nametransform/longnames.go
+++ b/internal/nametransform/longnames.go
@@ -9,6 +9,7 @@ import (
"strings"
"syscall"
+ "github.com/rfjakob/gocryptfs/internal/syscallcompat"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
@@ -65,7 +66,7 @@ func ReadLongName(path string) (string, error) {
// DeleteLongName deletes "hashName.name".
func DeleteLongName(dirfd *os.File, hashName string) error {
- err := syscall.Unlinkat(int(dirfd.Fd()), hashName+LongNameSuffix)
+ err := syscallcompat.Unlinkat(int(dirfd.Fd()), hashName+LongNameSuffix)
if err != nil {
tlog.Warn.Printf("DeleteLongName: %v", err)
}
@@ -86,7 +87,7 @@ func (n *NameTransform) WriteLongName(dirfd *os.File, hashName string, plainName
cName := n.EncryptName(plainName, dirIV)
// Write the encrypted name into hashName.name
- fdRaw, err := syscall.Openat(int(dirfd.Fd()), hashName+LongNameSuffix,
+ fdRaw, err := syscallcompat.Openat(int(dirfd.Fd()), hashName+LongNameSuffix,
syscall.O_WRONLY|syscall.O_CREAT|syscall.O_EXCL, 0600)
if err != nil {
tlog.Warn.Printf("WriteLongName: Openat: %v", err)