Created
August 25, 2021 14:55
-
-
Save thomasdullien/59bcb659cf213f453bf527e889394a66 to your computer and use it in GitHub Desktop.
Source code for a container that creates a large directory tree
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
FROM ubuntu:bionic | |
RUN chmod 777 /tmp | |
RUN apt-get update && apt-get -y upgrade | |
RUN apt-get install -y git wget cmake sudo gcc-7 g++-7 python3-pip zlib1g-dev g++ | |
RUN mkdir /code | |
COPY ./main.cpp /code | |
RUN g++ /code/main.cpp -o /code/a.out | |
RUN chmod +x /code/a.out | |
WORKDIR /code | |
ENTRYPOINT ["/code/a.out"] |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <cstring> | |
#include <sys/stat.h> | |
#include <sys/types.h> | |
int base = 256; | |
int main(int argc, char**argv) { | |
char buf[256]; | |
memset(buf, 0, sizeof(buf)); | |
sprintf(buf, "garbage"); | |
int res = mkdir(buf, 0700); | |
if (res != 0) { | |
printf("Failed to create directory %s\n", buf); | |
} | |
for (int i=0; i < base; ++i) { | |
sprintf(buf, "garbage/%d", i); | |
int res = mkdir(buf, 0700); | |
if (res != 0) { | |
printf("Failed to create directory %s\n", buf); | |
} | |
for (int j=0; j < base; ++j) { | |
sprintf(buf, "garbage/%d/%d", i, j); | |
res = mkdir(buf, 0700); | |
if (res != 0) { | |
printf("Failed to create directory %s\n", buf); | |
} | |
for (int k=0; k < base; ++k ) { | |
sprintf(buf, "garbage/%d/%d/%d", i, j, k); | |
res = mkdir(buf, 0700); | |
if (res != 0) { | |
printf("Failed to create directory %s\n", buf); | |
} | |
} | |
} | |
} | |
while(1) { | |
printf("Printing a message, then sleeping a bit.\n"); | |
sleep(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment