gccgo: replace syscall.NAME_MAX with unix.NAME_MAX
For some reason the syscall.NAME_MAX constant does not exist on gccgo, and it does not hurt us to use unix.NAME_MAX instead. https://github.com/rfjakob/gocryptfs/issues/201
This commit is contained in:
parent
26ba8103bf
commit
9f8d0d8e57
@ -3,7 +3,8 @@ package fusefrontend_reverse
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/internal/ctlsock"
|
||||
"github.com/rfjakob/gocryptfs/internal/pathiv"
|
||||
@ -23,7 +24,7 @@ func (rfs *ReverseFS) EncryptPath(plainPath string) (string, error) {
|
||||
for _, part := range parts {
|
||||
dirIV := pathiv.Derive(cipherPath, pathiv.PurposeDirIV)
|
||||
encryptedPart := rfs.nameTransform.EncryptName(part, dirIV)
|
||||
if rfs.args.LongNames && len(encryptedPart) > syscall.NAME_MAX {
|
||||
if rfs.args.LongNames && len(encryptedPart) > unix.NAME_MAX {
|
||||
encryptedPart = rfs.nameTransform.HashLongName(encryptedPart)
|
||||
}
|
||||
cipherPath = filepath.Join(cipherPath, encryptedPart)
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/hanwen/go-fuse/fuse"
|
||||
"github.com/hanwen/go-fuse/fuse/nodefs"
|
||||
|
||||
@ -80,7 +82,7 @@ func (rfs *ReverseFS) findLongnameParent(dir string, dirIV []byte, longname stri
|
||||
continue
|
||||
}
|
||||
cName := rfs.nameTransform.EncryptName(plaintextName, dirIV)
|
||||
if len(cName) <= syscall.NAME_MAX {
|
||||
if len(cName) <= unix.NAME_MAX {
|
||||
// Entry should have been skipped by the "continue" above
|
||||
log.Panic("logic error or wrong shortNameMax constant?")
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ func (rfs *ReverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse.
|
||||
cName = configfile.ConfDefaultName
|
||||
} else {
|
||||
cName = rfs.nameTransform.EncryptName(entries[i].Name, dirIV)
|
||||
if len(cName) > syscall.NAME_MAX {
|
||||
if len(cName) > unix.NAME_MAX {
|
||||
cName = rfs.nameTransform.HashLongName(cName)
|
||||
dotNameFile := fuse.DirEntry{
|
||||
Mode: virtualFileMode,
|
||||
|
@ -9,6 +9,8 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
||||
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
||||
"github.com/rfjakob/gocryptfs/internal/tlog"
|
||||
@ -111,7 +113,7 @@ func WriteDirIV(dirfd *os.File, dir string) error {
|
||||
// too long.
|
||||
func (be *NameTransform) encryptAndHashName(name string, iv []byte) string {
|
||||
cName := be.EncryptName(name, iv)
|
||||
if be.longNames && len(cName) > syscall.NAME_MAX {
|
||||
if be.longNames && len(cName) > unix.NAME_MAX {
|
||||
return be.HashLongName(cName)
|
||||
}
|
||||
return cName
|
||||
@ -128,7 +130,7 @@ func (be *NameTransform) EncryptPathDirIV(plainPath string, rootDir string) (str
|
||||
}
|
||||
// Reject names longer than 255 bytes.
|
||||
baseName := filepath.Base(plainPath)
|
||||
if len(baseName) > syscall.NAME_MAX {
|
||||
if len(baseName) > unix.NAME_MAX {
|
||||
return "", syscall.ENAMETOOLONG
|
||||
}
|
||||
// If we have the iv and the encrypted directory name in the cache, we
|
||||
|
@ -9,6 +9,8 @@ import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/hanwen/go-fuse/fuse"
|
||||
)
|
||||
|
||||
@ -28,7 +30,7 @@ func testGetdents(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for i := 1; i <= syscall.NAME_MAX; i++ {
|
||||
for i := 1; i <= unix.NAME_MAX; i++ {
|
||||
n := strings.Repeat("x", i)
|
||||
err = ioutil.WriteFile(testDir+"/"+n, nil, 0600)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user