Quote:
Originally Posted by Spect73
Actually, note 16 of that wiki article points out that linux has a maximum pathname of 4096.
|
Sorry for necro-ing this six years later, but that information is incorrect and this is turning up fairly high in Google results.
Linux itself and the ext* filesystems have no path length limit.
The misconception around 4096 bytes comes from the
PATH_MAX constant, which determines the maximum path length
supported by certain POSIX functions, like
realpath(3) and
getwd(3).
However, it is
not a limit on path lengths themselves and it can be
worked around.
(It's also part of the reason
getcwd(3) was created, which allows you to specify the size of the output buffer and, if it's too short, the function will raise an error that means "Call me again with a longer output buffer.")
For example, this simple Python test program will exceed the 4096-byte limit without ill effect under ext3:
Code:
import os
for X in range(20):
os.mkdir('x' * 255)
os.chdir('x' * 255)
However, you might find yourself having trouble
cd-ing down into that if your shell is configured to display the full path in your prompt rather than just the current folder's name, like my
bash is.
However, my
zsh, which just shows the folder name, can cd into it without trouble and the
pwd builtin, which is probably using
getcwd(3) under the hood, retrieves the whole 5000+-character path without issue.