diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-01-13 00:01:15 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-01-13 00:01:15 +0900 |
commit | 7637d300c5b1350fce808d5068b580694dbe7b1c (patch) | |
tree | 4a522e419e4127304fcb78328c891e76475badd9 | |
parent | 42ed6580fff22df60af5722ad181e7df4668c67b (diff) | |
download | poe-7637d300c5b1350fce808d5068b580694dbe7b1c.tar.gz |
tmpfsaa
-rw-r--r-- | Gemfile.lock | 8 | ||||
-rw-r--r-- | sandbox/playground.c | 31 | ||||
-rw-r--r-- | sandbox/sandbox.h | 4 |
3 files changed, 24 insertions, 19 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index ee40de7..e7fe235 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -84,7 +84,6 @@ GEM execjs coffee-script-source (1.10.0) concurrent-ruby (1.0.0) - daemons (1.2.3) em-hiredis (0.3.0) eventmachine (~> 1.0) hiredis (~> 0.5.0) @@ -117,6 +116,7 @@ GEM mysql2 (0.4.2) nokogiri (1.6.7.1) mini_portile2 (~> 2.0.0.rc2) + puma (2.15.3) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (2.0.0.alpha) @@ -171,10 +171,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thin (1.6.2) - daemons (>= 1.0.9) - eventmachine (>= 1.0.0) - rack (>= 1.0.0) thor (0.19.1) thread_safe (0.3.5) tilt (2.0.2) @@ -198,13 +194,13 @@ DEPENDENCIES haml jquery-rails mysql2 (>= 0.3.18, < 0.5) + puma quiet_assets rails (>= 5.0.0.beta1, < 5.1) sass-rails sinatra sprockets sprockets-es6 - thin uglifier (>= 1.3.0) BUNDLED WITH diff --git a/sandbox/playground.c b/sandbox/playground.c index edc9cdf..6b8e3f5 100644 --- a/sandbox/playground.c +++ b/sandbox/playground.c @@ -1,5 +1,6 @@ #include "sandbox.h" +static char *workbase = NULL; static char *upperdir = NULL; static char *workdir = NULL; static char *mergeddir = NULL; @@ -25,15 +26,22 @@ poe_init_playground(const char *base, const char *env) NONNEGATIVE(mkdir(POE_TEMPORARY_BASE, 0755)); } - workdir = strdup(POE_WORKDIR_TEMPLATE); - if (!workdir || !mkdtemp(workdir)) ERROR("failed to create workdir"); - NONNEGATIVE(chmod(workdir, 0755)); - upperdir = strdup(POE_UPPERDIR_TEMPLATE); - if (!upperdir || !mkdtemp(upperdir)) ERROR("failed to create upperdir"); - NONNEGATIVE(chmod(upperdir, 0755)); - mergeddir = strdup(POE_MERGEDDIR_TEMPLATE); - if (!mergeddir || !mkdtemp(mergeddir)) ERROR("failed to create mergeddir"); - NONNEGATIVE(chmod(mergeddir, 0755)); + // setup base (tmpfs) + NONNEGATIVE(asprintf(&workbase, POE_TEMPORARY_BASE "/%ld", (long)getpid())); // pid_t is signed, not larger than long + if (stat(workbase, &s) != -1) { + NONNEGATIVE(rmrf(workbase)); + } + NONNEGATIVE(mkdir(workbase, 0755)); + NONNEGATIVE(mount(NULL, workbase, "tmpfs", MS_NOSUID, "size=32m")); // TODO + + NONNEGATIVE(asprintf(&workdir, "%s/work", workbase)); + NONNEGATIVE(mkdir(workdir, 0755)); + + NONNEGATIVE(asprintf(&upperdir, "%s/upper", workbase)); + NONNEGATIVE(mkdir(upperdir, 0755)); + + NONNEGATIVE(asprintf(&mergeddir, "%s/merged", workbase)); + NONNEGATIVE(mkdir(mergeddir, 0755)); char *opts = NULL; NONNEGATIVE(asprintf(&opts, "lowerdir=%s:%s,upperdir=%s,workdir=%s", env, base, upperdir, workdir)); @@ -59,4 +67,9 @@ poe_destroy_playground() rmrf(upperdir); free(upperdir); } + if (workbase && stat(workbase, &s) != -1) { + umount(workbase); + rmrf(workbase); + free(workbase); + } } diff --git a/sandbox/sandbox.h b/sandbox/sandbox.h index 2068688..a635e07 100644 --- a/sandbox/sandbox.h +++ b/sandbox/sandbox.h @@ -32,11 +32,7 @@ #include <systemd/sd-daemon.h> #include <systemd/sd-event.h> -#define POE_LOWERDIR "/" #define POE_TEMPORARY_BASE "/tmp/poe" -#define POE_UPPERDIR_TEMPLATE POE_TEMPORARY_BASE "/upperXXXXXX" -#define POE_WORKDIR_TEMPLATE POE_TEMPORARY_BASE "/workXXXXXX" -#define POE_MERGEDDIR_TEMPLATE POE_TEMPORARY_BASE "/mergedXXXXXX" #define POE_USERNAME "nobody" #define POE_HOSTNAME "poe-sandbox" |