Search code examples
operating-systemfilesystemsnaming

Why do file systems limit maximum length of a file name?


Most posts i read just give info about the maximum file name length's. But, i want to understand why there's this limit. Why can't file name's be big. I see that few file systems have put a limit of 255 bytes. Why not 1 MB or anything more than 255 bytes. I probably would never have a file name of length more than 100 characters. But, this question is about why the limit?


Solution

  • long file name costs much more space and time than you can imagine
    the 255 bytes limit of file name length is a long time trade off between human
    onvenience and space/time efficiency
    and backward compatibility , of course

    back to the dark old days , the capacity of hard drive capacity was count by MB or a few GB
    file name are often stored in some fixed length C structs ,
    and the size of the struct was mostly round by the factor of 512 byte,
    which is the size of a physical sector ,so that it can be read out by a single touch of the head

    if the file system put a limit of 1MB on filename, it would run out of harddisk space with only a few hundred files. and memory limits also applys.....