remove myfuser to detect the instance
authorGui Chen <gui.chen@intel.com>
Fri, 9 Aug 2013 08:42:53 +0000 (04:42 -0400)
committerGui Chen <gui.chen@intel.com>
Tue, 13 Aug 2013 09:23:53 +0000 (05:23 -0400)
the detection of .chroot.lock is not so correct in logic,
if the .chroot.lock is used by another process, it works;
if it is used by this process, it faults. so fuser is not
working as expected here. also removing fuser will break
a dependency of 'fuser' command

Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/utils/fs_related.py

index b9b9a97..5802c27 100644 (file)
@@ -88,23 +88,6 @@ def resize2fs(fs, size):
     else:
         return runner.show([resize2fs, fs, "%sK" % (size / 1024,)])
 
-def my_fuser(fp):
-    fuser = find_binary_path("fuser")
-    if not os.path.exists(fp):
-        return False
-
-    rc = runner.quiet([fuser, "-s", fp])
-    if rc == 0:
-        for pid in runner.outs([fuser, fp]).split():
-            fd = open("/proc/%s/cmdline" % pid, "r")
-            cmdline = fd.read()
-            fd.close()
-            if cmdline[:-1] == "/bin/bash":
-                return True
-
-    # not found
-    return False
-
 class BindChrootMount:
     """Represents a bind mount of a directory into a chroot."""
     def __init__(self, src, chroot, dest = None, option = None):
@@ -134,10 +117,6 @@ class BindChrootMount:
 
         return False
 
-    def has_chroot_instance(self):
-        lock = os.path.join(self.root, ".chroot.lock")
-        return my_fuser(lock)
-
     def mount(self):
         if self.mounted or self.ismounted():
             return
@@ -159,9 +138,6 @@ class BindChrootMount:
                 os.symlink(self.src, dest)
 
     def unmount(self):
-        if self.has_chroot_instance():
-            return
-
         if self.ismounted():
             runner.show([self.umountcmd, "-l", self.dest])
         self.mounted = False