Skip to content

Instantly share code, notes, and snippets.

@thomasdullien
Created August 25, 2021 14:55
Show Gist options
  • Save thomasdullien/59bcb659cf213f453bf527e889394a66 to your computer and use it in GitHub Desktop.
Save thomasdullien/59bcb659cf213f453bf527e889394a66 to your computer and use it in GitHub Desktop.
Source code for a container that creates a large directory tree
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"]
#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