A file system errno, "Too many links": this error reports that a link(2) operation would result in the target file having too many links, greater than the pre-defined constant "LINK_MAX" (which is usually 32767). This applies firstly to the user-executed link(2) call, but it also applies directory creation. The upshot of this is that you may not have over 32765 subdirectories in one directory, but this would be stupidly expensive to do in the first place, and completely impractical.

Background: when a directory is created, its dirent for ".." must be linked to the parent directory. Therefore, for every subdirectory created, the parent directory will gain one link back to it. In ancient Unix, the mkdir(2) operation was really just separate open(2), write(2), and link(2) calls, making corruption easy and of course having no atomicity. Now, the entire process is atomic: the parent directory must be locked while creating the subdirectory, and the vnode operation for "link" is called, then the lock released. This removes the danger of corruption which Unix once had.

Log in or registerto write something here or to contact authors.