summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGui Chen <gui.chen@intel.com>2013-05-15 03:18:22 -0400
committerGui Chen <gui.chen@intel.com>2013-05-15 04:01:35 -0400
commit4316f75e1b905c5b0fab33c9940f2214de2344d8 (patch)
treeb8bdd2045d414ddc84b9ce3b569a96302c8f00eb
parent8374edede439c61e50625d1da18200d84a4322e5 (diff)
downloadmic-4316f75e1b905c5b0fab33c9940f2214de2344d8.tar.gz
mic-4316f75e1b905c5b0fab33c9940f2214de2344d8.tar.bz2
mic-4316f75e1b905c5b0fab33c9940f2214de2344d8.zip
fix '/var/lock' non-existent throw traceback
Signed-off-by: Gui Chen <gui.chen@intel.com>
-rw-r--r--mic/chroot.py2
-rw-r--r--mic/utils/fs_related.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/mic/chroot.py b/mic/chroot.py
index 546c0c8..99fb9a2 100644
--- a/mic/chroot.py
+++ b/mic/chroot.py
@@ -142,6 +142,8 @@ def setup_chrootenv(chrootdir, bindmounts = None, mountparent = True):
"""Default bind mounts"""
for pt in BIND_MOUNTS:
+ if not os.path.exists(pt):
+ continue
chrootmounts.append(fs_related.BindChrootMount(pt,
chrootdir,
None))
diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py
index e4e5c50..06e9d84 100644
--- a/mic/utils/fs_related.py
+++ b/mic/utils/fs_related.py
@@ -949,10 +949,15 @@ class LoopDevice(object):
os.unlink(self.device)
DEVICE_PIDFILE_DIR = "/var/tmp/mic/device"
+DEVICE_LOCKFILE = "/var/lock/__mic_loopdev.lock"
def get_loop_device(losetupcmd, lofile):
+ global DEVICE_PIDFILE_DIR
+ global DEVICE_LOCKFILE
+
import fcntl
- fp = open("/var/lock/__mic_loopdev.lock", 'w')
+ makedirs(os.path.dirname(DEVICE_LOCKFILE))
+ fp = open(DEVICE_LOCKFILE, 'w')
fcntl.flock(fp, fcntl.LOCK_EX)
try:
loopdev = None
@@ -993,7 +998,7 @@ def get_loop_device(losetupcmd, lofile):
try:
fcntl.flock(fp, fcntl.LOCK_UN)
fp.close()
- os.unlink('/var/lock/__mic_loopdev.lock')
+ os.unlink(DEVICE_LOCKFILE)
except:
pass