forked from TrueCloudLab/rclone
mount, cmount: don't pass huge filenames (>4k) to FUSE as it can't cope
This commit is contained in:
parent
76f5e273d2
commit
59026c4761
3 changed files with 18 additions and 2 deletions
|
@ -246,7 +246,12 @@ func (fsys *FS) Readdir(dirPath string,
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
node, ok := item.(vfs.Node)
|
node, ok := item.(vfs.Node)
|
||||||
if ok {
|
if ok {
|
||||||
fill(node.Name(), nil, 0)
|
name := node.Name()
|
||||||
|
if len(name) > mountlib.MaxLeafSize {
|
||||||
|
fs.Errorf(dirPath, "Name too long (%d bytes) for FUSE, skipping: %s", len(name), name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fill(name, nil, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemsRead = len(items)
|
itemsRead = len(items)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
fusefs "bazil.org/fuse/fs"
|
fusefs "bazil.org/fuse/fs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rclone/rclone/cmd/mountlib"
|
"github.com/rclone/rclone/cmd/mountlib"
|
||||||
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fs/log"
|
"github.com/rclone/rclone/fs/log"
|
||||||
"github.com/rclone/rclone/vfs"
|
"github.com/rclone/rclone/vfs"
|
||||||
)
|
)
|
||||||
|
@ -96,10 +97,15 @@ func (d *Dir) ReadDirAll(ctx context.Context) (dirents []fuse.Dirent, err error)
|
||||||
return nil, translateError(err)
|
return nil, translateError(err)
|
||||||
}
|
}
|
||||||
for _, node := range items {
|
for _, node := range items {
|
||||||
|
name := node.Name()
|
||||||
|
if len(name) >= mountlib.MaxLeafSize {
|
||||||
|
fs.Errorf(d, "Name too long (%d bytes) for FUSE, skipping: %s", len(name), name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
var dirent = fuse.Dirent{
|
var dirent = fuse.Dirent{
|
||||||
// Inode FIXME ???
|
// Inode FIXME ???
|
||||||
Type: fuse.DT_File,
|
Type: fuse.DT_File,
|
||||||
Name: node.Name(),
|
Name: name,
|
||||||
}
|
}
|
||||||
if node.IsDir() {
|
if node.IsDir() {
|
||||||
dirent.Type = fuse.DT_Dir
|
dirent.Type = fuse.DT_Dir
|
||||||
|
|
|
@ -38,6 +38,11 @@ var (
|
||||||
DaemonTimeout time.Duration // OSXFUSE only
|
DaemonTimeout time.Duration // OSXFUSE only
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Global constants
|
||||||
|
const (
|
||||||
|
MaxLeafSize = 4095 // don't pass file names longer than this
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// DaemonTimeout defaults to non zero for macOS
|
// DaemonTimeout defaults to non zero for macOS
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
|
|
Loading…
Reference in a new issue