kern/165392: Multiple mkdir/rmdir fails with errno 31

Vsevolod Volkov vvv at
Wed Feb 22 11:00:30 UTC 2012

>Number:         165392
>Category:       kern
>Synopsis:       Multiple mkdir/rmdir fails with errno 31
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 22 11:00:22 UTC 2012
>Originator:     Vsevolod Volkov
>Release:        9.0-RELEASE amd64/i386
FreeBSD 9.0-RELEASE #0: Mon Feb 13 12:12:58 EET 2012 amd64
FreeBSD 9.0-RELEASE #1: Thu Feb  9 16:29:18 EET 2012 i386
Multiple sequence of mkdir and rmdir causes mkdir failure with errno 31. Usualy it happens on 32765 iteration.
Compile and execute the following program:

#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int main (void)
  int i;
  char dir[100];
  for (i = 0; i < 50000; i++)
    snprintf (dir, sizeof(dir), "empty_dir/%d", i);
    printf ("%s\n", dir);
    if (mkdir (dir, 0700) == -1)
      printf ("mkdir %s: (errno %d)\n", dir, errno);
    if (rmdir (dir) == -1)
      printf ("rmdir %s: (errno %d)\n", dir, errno);
  return 0;

gcc -o test1 test1.c
mkdir empty_dir


More information about the freebsd-bugs mailing list