LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-18-2013, 03:21 AM   #1
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Smile Linux Path Limitation


hi gurus, what's the path limitation for ext? file systems.

Thanks
 
Old 10-18-2013, 03:27 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Are you talking about the maximum amount of sub-directories?

If so:

ext2/ext3 -> 32.000
ext4 -> unlimited

Infor from: ext4 (Increasing the 32,000 subdirectory limit section)
 
Old 10-18-2013, 03:40 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Thanks druuna, i'm talking about the path length. sorry for not being detailed.

because for Win OS it's about 260 chars. path length limitation.

so for Linux does the same thing apply also?
 
Old 10-18-2013, 03:58 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
For ext[234]:
- Maximum filename length: 255 bytes (characters)
- Maximum pathname length: No limit defined

Source: Comparison of file systems (Limits section)
 
1 members found this post helpful.
Old 10-18-2013, 04:42 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
wow..this is cool.

But i'm just thinking that even though our file server is Samba, the workstation is Windows.

The limit will still apply to the UNC path of the Win workstation.

anyway, thanks again
 
Old 10-26-2013, 04:35 PM   #6
Spect73
Member
 
Registered: Aug 2013
Distribution: Slackware 14.1
Posts: 128

Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
For ext[234]:
- Maximum filename length: 255 bytes (characters)
- Maximum pathname length: No limit defined

Source: Comparison of file systems (Limits section)
Actually, note 16 of that wiki article points out that linux has a maximum pathname of 4096. On my 32 bit
flavor of Slackware 14, this is indeed the limit.

Coordially
 
1 members found this post helpful.
Old 09-01-2019, 05:38 AM   #7
ssokolow
LQ Newbie
 
Registered: Aug 2004
Location: Canada
Posts: 28

Rep: Reputation: 16
Quote:
Originally Posted by Spect73 View Post
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.
 
Old 09-01-2019, 06:53 PM   #8
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
i once played around with a small script that would create a directory and cd into it the number of times given, decrementing that number as it went, stopping when it decremented to zero. i ran it for 1000000 and went to bed. in the morning it was done. then i ran "rm -fr" on it and got an error message about the path being too long. so i wrote another script to descend all the way, then ascend doing "rmdir" as it went. when i got back from work, it was done. i reformatted that drive afterwards. if i were to do that today, i would do it in a cloud instance so it could just vanish when i'm done.

i'm guessing rm has its limits or uses PATH_MAX.

i'm trying figure out how to make it into a loop.

Last edited by Skaperen; 09-01-2019 at 07:00 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
2GB file limitation on linux knc Linux - Server 5 04-27-2013 06:03 AM
32bit and 64bit linux file size limitation Swakoo Linux - General 2 09-05-2007 07:21 AM
does linux has limitation when copy many files at once? sirpelidor Linux - General 4 12-18-2006 03:57 PM
Limitation of process memeory consumption on Linux james_chao_2000 Programming 16 03-20-2006 02:45 AM
Is there a file size limitation in Linux? lazyboy0001 Linux - Software 12 08-12-2004 08:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration