1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <string.h>
- #include <err.h>
- #define MAXLEVELS 5
- int
- main(void)
- {
- int i;
- const char *onename = "testdir";
- char dirname[512];
- strcpy(dirname, onename);
- for (i=0; i<MAXLEVELS; i++) {
- printf("Creating directory: %s\n", dirname);
- if (mkdir(dirname, 0755)) {
- err(1, "%s: mkdir", dirname);
- }
-
- strcat(dirname, "/");
- strcat(dirname, onename);
- }
- printf("Passed directory creation test.\n");
- for (i=0; i<MAXLEVELS; i++) {
- dirname[strlen(dirname) - strlen(onename) - 1] = 0;
- printf("Removing directory: %s\n", dirname);
- if (rmdir(dirname)) {
- err(1, "%s: rmdir", dirname);
- }
- }
- printf("Passed directory removal test.\n");
- return 0;
- }
|