Skip to content

Instantly share code, notes, and snippets.

@kiryl
Created November 29, 2012 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiryl/4169200 to your computer and use it in GitHub Desktop.
Save kiryl/4169200 to your computer and use it in GitHub Desktop.
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#define NR 1000
int main(int argc, char **argv)
{
int i, j, fd;
char name[PATH_MAX];
for (i = 0; i < NR; i++) {
sprintf(name, "d%d", i);
if (mkdir(name, 0777))
return errno;
if (chdir(name))
return errno;
for (j = 0; j < NR; j++) {
sprintf(name, "f%d", j);
fd = open(name, O_CREAT|O_WRONLY);
if (fd < 0)
return errno;
if (dprintf(fd, "%d\n", j) < 0)
return errno;
if (close(fd))
return errno;
}
if (chdir(".."))
return errno;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment