Correct maximum filename length value (fixes #3338) #3355

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@afiskon
afiskon commented Jun 27, 2016

See discussion #3338

@afiskon afiskon Correct maximum filename length value (see #3338)
f702dfa
@AudriusButkevicius
Member

So it still doesn't explain the fact that the file that was failing for you was around 140 characters, nowhere close 179

@calmh
Member
calmh commented Jun 27, 2016

Better yet, does this work for you with encfs?

@afiskon
afiskon commented Jun 27, 2016

@AudriusButkevicius you should consider a full filename:

$ python3

>>> len("""/home/eax/Sync/books/by_topic/papers-redbook/.syncthing.032 - ARIES- A Transaction Recovery Method Supporting Fine-Granularity Locking and Partial Rollbacks Using Write-Ahead Logging.pdf.tmp""")

190
@calmh
Member
calmh commented Jun 27, 2016

@st-jenkins add to whitelist

@calmh
Member
calmh commented Jun 27, 2016 edited

No. I just confirmed this by installing it myself - the limit is per path component as you'd expect. The actual limit on my system was 175 characters:

root@ams:~/enctest# mkdir $(python -c 'print "y"*175')
root@ams:~/enctest# mkdir $(python -c 'print "z"*176')
mkdir: cannot create directory ‘zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz’: File name too long

It's fine to create a 175 character file in a 175 character directory and so on.

So the above patch looks good to me in principle, but it would be good to understand why this happened to you in the first place, to make sure we are not missing something. There may be encfs options that affect this. I selected the default paranoia mode:

Please choose from one of the following options:
 enter "x" for expert configuration mode,
 enter "p" for pre-configured paranoia mode,
 anything else, or an empty line will select standard mode.
?> p

Paranoia configuration selected.

Configuration finished.  The filesystem to be created has
the following properties:   
Filesystem cipher: "ssl/aes", version 3:0:2
Filename encoding: "nameio/block", version 3:0:1
Key Size: 256 bits
Block Size: 1024 bytes, including 8 byte MAC header
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File data IV is chained to filename IV.
File holes passed through to ciphertext.
@calmh calmh commented on the diff Jun 27, 2016
lib/model/tempname.go
@@ -20,6 +20,13 @@ type tempNamer struct {
var defTempNamer tempNamer
+// (max filename length supported by FS) - len(".syncthing.") - len(".tmp")
+// Worst case is EncFS which according to man page supports filenames up to
+// "approximately" 3*(N-2)/4 characters where N is a limit of underlying FS.
+// If underlying FS is ext4 in practice it means that maximum filename length
+// is 188 characters. Minus len(".syncthing."), minus len(".tmp") gives:
+const maxFilenameLength = 173
@calmh
calmh Jun 27, 2016 edited Member

I'd make this

const maxFilenameLength = 175 - len(".syncthing.") - len(".tmp")

to match observed reality. The "approximately" was very approximate indeed in my test case above. Included the len calculations in the constant makes some of the explanation redundant.

@calmh calmh added a commit to calmh/syncthing that referenced this pull request Jun 27, 2016
@calmh calmh lib/model: Decrease max temp filename length (fixes #3338, fixes #3355) b427ae4
@calmh calmh added a commit to calmh/syncthing that referenced this pull request Jun 27, 2016
@calmh calmh lib/model: Decrease max temp filename length (fixes #3338, fixes #3355) ad0bfe7
@st-review st-review pushed a commit that closed this pull request Jun 27, 2016
@calmh calmh lib/model: Decrease max temp filename length (fixes #3338, fixes #3355)
GitHub-Pull-Request: #3356
a165838
@st-review st-review closed this in a165838 Jun 27, 2016
@calmh calmh added a commit to calmh/syncthing that referenced this pull request Jun 27, 2016
@calmh calmh Merge branch 'master' into protobufs
* master:
  lib/events: Introduce per-subscription event IDs (fixes #3335)
  lib/model: Decrease max temp filename length (fixes #3338, fixes #3355)
  gui: Suggest lower case only folder ID (fixes #3128)
  lib/events: Add logging/receiving benchmark
  lib/db: Fix alignment crash on 32 bit platforms
  gui, man: Update docs & translations
  gui: Add addresses for disconnected devices (fixes #3340)
  lib/config: Retain slash at end of path after expanding ~ (fixes #2782)
  lib/nat: Avoid concurrent reset of NAT timer (fixes #3337)
  lib/model: Refactor CheckFolderHealth into separate methods
77834d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment