Filename length limits on linux?
See the Wikipedia page about file systems comparison, especially in column Maximum filename length.
Here are some filename length limits in popular file systems:
BTRFS 255 bytes exFAT 255 UTF-16 characters ext2 255 bytes ext3 255 bytes ext3cow 255 bytes ext4 255 bytes FAT32 8.3 (255 UCS-2 code units with VFAT LFNs) NTFS 255 characters XFS 255 bytes
I've read here that path length limit is in system headers. File name length limit is there too. On my system it's file:
and C-lang defines:
#define NAME_MAX 255 /* # chars in a file name */ #define PATH_MAX 4096 /* # chars in a path name including nul */
and some more.
I refer to other answers, please upvote them.
Are there any filename or path length limits on Linux?
Yes, filename and pathname lengths are limited by :
- file-system limits as stated by WerkkreW ;
- constants defined in
linux/limits.has stated by sfp.
To dynamically get these properties:
- Use functions
fpathconfas proposed by Michael Aaron Safyan
- Create a filename (or pathname) longer and longer as explained by dogbane
Use the command
getconfas proposed by tim that is also available on Linux:
$ getconf NAME_MAX /mnt/sda2/ 255 $ getconf PATH_MAX /mnt/sda3/ 4096
And for the sake of saving time (and anchoring it to memory):
ext2, ext3, ext4, zfs: no pathname limits; 255 bytes filename limit.
Those are file system name lengths. "linux" itself has some too. For instance, from bits/stdio_lim.h:
# define FILENAME_MAX 4096