Created
November 29, 2012 13:48
-
-
Save kiryl/4169200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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