From nobody@FreeBSD.org  Wed Apr 23 15:56:44 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2F48E10656BE
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 23 Apr 2008 15:56:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 0B0D88FC23
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 23 Apr 2008 15:56:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m3NFuHRF089132
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 23 Apr 2008 15:56:17 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m3NFuHl1089131;
	Wed, 23 Apr 2008 15:56:17 GMT
	(envelope-from nobody)
Message-Id: <200804231556.m3NFuHl1089131@www.freebsd.org>
Date: Wed, 23 Apr 2008 15:56:17 GMT
From: Oleg Koreshkov <okor@zone.salut.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mkdir(2) can return EMLINK, but EMLINK is not listed as possible error code in mkdir(2) manpage
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         123019
>Category:       docs
>Synopsis:       [patch] 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:    danger
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 23 16:00:02 UTC 2008
>Closed-Date:    Mon Jun 30 09:11:14 UTC 2008
>Last-Modified:  Mon Jun 30 09:20:01 UTC 2008
>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:
Responsible-Changed-From-To: freebsd-bugs->freebsd-doc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Apr 23 17:12:54 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123019 
Responsible-Changed-From-To: freebsd-doc->danger 
Responsible-Changed-By: danger 
Responsible-Changed-When: Thu Jun 26 12:15:49 UTC 2008 
Responsible-Changed-Why:  
Take 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123019 
State-Changed-From-To: open->patched 
State-Changed-By: danger 
State-Changed-When: Thu Jun 26 12:16:15 UTC 2008 
State-Changed-Why:  
I have committed a bit different patch, however thank you for your 
submission. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123019 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/123019: commit references a PR
Date: Thu, 26 Jun 2008 12:16:07 +0000 (UTC)

 danger      2008-06-26 12:15:38 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libc/sys         mkdir.2 
   Log:
   SVN rev 180030 on 2008-06-26 12:15:38Z by danger
   
   - add description of the MLINK error
   
   PR:             docs/123019
   MFC after:      3 days
   
   Revision  Changes    Path
   1.27      +3 -0      src/lib/libc/sys/mkdir.2
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/123019: commit references a PR
Date: Mon, 30 Jun 2008 09:06:39 +0000 (UTC)

 danger      2008-06-30 09:06:19 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     lib/libc/sys         mkdir.2 
   Log:
   SVN rev 180114 on 2008-06-30 09:06:19Z by danger
   
   - MFC rev. 180030 and 180113:
     - add description of the MLINK error
     - bump a date
   
   PR:             docs/123019
   
   Revision  Changes    Path
   1.24.2.2  +4 -1      src/lib/libc/sys/mkdir.2
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/123019: commit references a PR
Date: Mon, 30 Jun 2008 09:08:44 +0000 (UTC)

 danger      2008-06-30 09:08:29 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     lib/libc/sys         mkdir.2 
   Log:
   SVN rev 180115 on 2008-06-30 09:08:29Z by danger
   
   - MFC rev. 180030 and 180113:
     - add description of the MLINK error
     - bump a date
   
   PR:             docs/123019
   
   Revision   Changes    Path
   1.19.12.2  +4 -1      src/lib/libc/sys/mkdir.2
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: danger 
State-Changed-When: Mon Jun 30 09:10:27 UTC 2008 
State-Changed-Why:  
Close this one as it has been merged to RELENG_[765] 

http://www.freebsd.org/cgi/query-pr.cgi?pr=123019 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/123019: commit references a PR
Date: Mon, 30 Jun 2008 09:10:27 +0000 (UTC)

 danger      2008-06-30 09:10:04 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_5)
     lib/libc/sys         mkdir.2 
   Log:
   SVN rev 180116 on 2008-06-30 09:10:04Z by danger
   
   - MFC rev. 180030 and 180113:
     - add description of the MLINK error
     - bump a date
   
   PR:             docs/123019
   
   Revision  Changes    Path
   1.19.6.1  +4 -1      src/lib/libc/sys/mkdir.2
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
