[CRIU] [PATCH] p.haul: images: create img_dir if it doesn't exist, v2
Ruslan Kuprieiev
kupruser at gmail.com
Mon Oct 13 23:19:53 PDT 2014
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
images.py | 1 +
util.py | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/images.py b/images.py
index ef5691f..a4d465c 100644
--- a/images.py
+++ b/images.py
@@ -76,6 +76,7 @@ class phaul_images:
self._keep_on_close = opts["keep_images"]
suf = time.strftime("-%y.%m.%d-%H.%M", time.localtime())
+ util.makedirs(opts["img_path"])
wdir = tempfile.mkdtemp(suf, "%s-" % self._typ, opts["img_path"])
self._wdir = opendir(wdir)
self._img_path = os.path.join(self._wdir.name(), "img")
diff --git a/util.py b/util.py
index 15f1c3f..9883bef 100644
--- a/util.py
+++ b/util.py
@@ -1,5 +1,6 @@
import os
import fcntl
+import errno
class net_dev:
def init(self):
@@ -35,3 +36,11 @@ def set_cloexec(sk):
flags = fcntl.fcntl(sk, fcntl.F_GETFD)
fcntl.fcntl(sk, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC)
+def makedirs(dirpath):
+ try:
+ os.makedirs(dirpath)
+ except OSError as er:
+ if er.errno == errno.EEXIST and os.path.isdir(dirpath):
+ pass
+ else:
+ raise
--
1.9.3
More information about the CRIU
mailing list