misc/123019: mkdir(2) can return EMLINK,
but EMLINK is not listed as possible error code in mkdir(2) manpage
Oleg Koreshkov
okor at zone.salut.ru
Wed Apr 23 16:00:03 UTC 2008
>Number: 123019
>Category: misc
>Synopsis: mkdir(2) can return EMLINK, but EMLINK is not listed as possible error code in mkdir(2) manpage
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: doc-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Apr 23 16:00:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Oleg Koreshkov
>Release: 6.3-RELEASE
>Organization:
a lot of
>Environment:
FreeBSD 6.3-RELEASE-p2 i386
>Description:
Create directory that contains 32766(7?) subdirectories.
try to create another one subdirectory and you would get:
mkdir: Too many links
However man 2 mkdir doesn't list EMLINK in ERRORS section.
It looks like it happen due to overflow of st_nlink in inode,
but nlink_t is defined as __uint16_t in /usr/include/sys/_types.h:
typedef __uint16_t __nlink_t; /* link count */
So there should be possible to create 65534 subdirectories?
>How-To-Repeat:
Create directory that contains 32766(7?) subdirectories.
try to create another one subdirectory and you would get:
# ls -al | wc -l
32768
# mkdir 9999999999999
mkdir: 9999999999999: Too many links
>Fix:
For example you can update mkdir(2) manpage with following patch:
--- mkdir.2 2008-04-23 19:42:06.000000000 +0400
+++ mkdir.2 2008-04-23 19:45:13.000000000 +0400
@@ -104,6 +104,8 @@
.Fa path
argument
points outside the process's allocated address space.
+.It Bq Er EMLINK
+The directory contains too many subdirectories.
.El
.Sh SEE ALSO
.Xr chmod 2 ,
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list