1 /* Library function for creating a tree of directories. */
5 #include "tests/filesys/extended/mk-tree.h"
8 static void do_mkdir (const char *format, ...) PRINTF_FORMAT (1, 2);
9 static void do_touch (const char *format, ...) PRINTF_FORMAT (1, 2);
12 make_tree (int at, int bt, int ct, int dt)
18 msg ("creating /0/0/0/0 through /%d/%d/%d/%d...",
19 at - 1, bt - 1, ct - 1, dt - 1);
21 for (a = 0; a < at; a++)
24 for (b = 0; b < bt; b++)
26 do_mkdir ("/%d/%d", a, b);
27 for (c = 0; c < ct; c++)
29 do_mkdir ("/%d/%d/%d", a, b, c);
30 for (d = 0; d < dt; d++)
31 do_touch ("/%d/%d/%d/%d", a, b, c, d);
37 snprintf (try, sizeof try, "/%d/%d/%d/%d", 0, bt - 1, 0, dt - 1);
38 CHECK ((fd = open (try)) > 1, "open \"%s\"", try);
39 msg ("close \"%s\"", try);
44 do_mkdir (const char *format, ...)
49 va_start (args, format);
50 vsnprintf (dir, sizeof dir, format, args);
53 CHECK (mkdir (dir), "mkdir \"%s\"", dir);
57 do_touch (const char *format, ...)
62 va_start (args, format);
63 vsnprintf (file, sizeof file, format, args);
66 CHECK (create (file, 0), "create \"%s\"", file);