From: Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Maxin John <maxin.john-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Michael Kerrisk
<mtk.manpages-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] mkdir.2: Add EMLINK error
Date: Sat, 26 Jun 2010 14:20:55 +0200 [thread overview]
Message-ID: <AANLkTimpRw4edRJSyyL0dTcVswrDoK7hoIETCEI_pvP1@mail.gmail.com> (raw)
In-Reply-To: <AANLkTilRbs4OTZxAdH_XDZB_EeQDXiKp2kflmO8djV8j-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Hello Maxin,
On Mon, Jun 21, 2010 at 5:48 PM, Maxin John <maxin.john-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Dear Michael,
>
> While executing the below given program in ext3 file system, I came
> across the EMLINK error in mkdir(2) syscall.
>
> # cat test_max_directories.c
>
> #include <stdio.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <stdlib.h>
> #include <errno.h>
>
> int main()
> {
> char dirname[50];
> int i;
> /* The max number of subdirectories in one directory for ext3 is 32000 */
> int limit = 32001;
>
> for (i = 0; i < limit; i++) {
> sprintf(dirname, "testdir%d", i);
> if ((mkdir(dirname, 00777)) == -1) {
> perror("Error in creating directory!");
> printf("errno = %d\n", errno);
> exit(1);
> }
> }
> return 0;
> }
>
>
> # ./a.out
> Error in creating directory!: Too many links
> errno = 29
>
> An strace of this execution shows that the mkdir(2) call generates an
> EMLINK error when it reaches the limit of maximum number of sub
> directories in one directory
>
> #strace ./a.out
> -----------------------------------
> .....
> mkdir("testdir31998", 0777) = -1 EMLINK (Too many links)
> dup(2) = 3
> fcntl64(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
> brk(0) = 0x804a000
> brk(0x806b000) = 0x806b000
> fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0xb7f71000
> _llseek(3, 0, 0xbffc3078, SEEK_CUR) = -1 ESPIPE (Illegal seek)
> write(3, "Error in creating directory!: To"..., 45Error in creating
> directory!: Too many links
> ) = 45
> close(3) = 0
> munmap(0xb7f71000, 4096) = 0
> fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0xb7f71000
> write(1, "errno = 29\n", 11errno = 29
> ) = 11
> exit_group(1) = ?
> Process 16246 detached
> -----------------------------------
>
> However, reference to EMLINK is not present in the mkdir(2) man page.
> The following patch adds the EMLINK error in the man page of mkdir(2).
>
> Kindly let me know if there are any issues.
Thanks for the very precise and well supported bug report!
Yes, the page should be fixed. However:
> -------
>
> diff --git a/man2/mkdir.2 b/man2/mkdir.2
> index e6cb28c..d01bafd 100644
> --- a/man2/mkdir.2
> +++ b/man2/mkdir.2
> @@ -73,6 +73,10 @@ is a symbolic link, dangling or not.
> Too many symbolic links were encountered in resolving
> .IR pathname .
> .TP
> +.B EMLINK
> +The new directory cannot be created because the number of sub directories
> +in a directory is limited to LINK_MAX defined by the file system.
> +.TP
> .B ENAMETOOLONG
> .IR pathname " was too long."
> .TP
>
> -------
It's slightly more accurate to talk of links than subdirectories, I
think )that's what POSIX does). So instead, I applied the below patch.
Thanks!
Michael
--- a/man2/mkdir.2
+++ b/man2/mkdir.2
@@ -73,6 +73,10 @@ is a symbolic link, dangling or not.
Too many symbolic links were encountered in resolving
.IR pathname .
.TP
+.B EMLINK
+The number of links to the parent directory would exceed
+.BR LINK_MAX .
+.TP
.B ENAMETOOLONG
.IR pathname " was too long."
.TP
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface" http://blog.man7.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2010-06-26 12:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-21 15:48 [PATCH] mkdir.2: Add EMLINK error Maxin John
[not found] ` <AANLkTilRbs4OTZxAdH_XDZB_EeQDXiKp2kflmO8djV8j-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-06-24 4:52 ` Maxin John
[not found] ` <AANLkTingDQui6HBFX3A3yh7Nhy00YJN1-j9aox88rROz-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-06-26 6:45 ` Maxin John
2010-06-26 12:20 ` Michael Kerrisk [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTimpRw4edRJSyyL0dTcVswrDoK7hoIETCEI_pvP1@mail.gmail.com \
--to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=maxin.john-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=mtk.manpages-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).