From: Stéphane Graber Date: Tue, 3 Dec 2013 21:45:13 +0000 (-0500) Subject: python3: Drop duplicate add_device_node function X-Git-Tag: lxc-1.0.0.beta1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af7d9cc56c07cdd7938fc93e17365240be4a5691;p=thirdparty%2Flxc.git python3: Drop duplicate add_device_node function It is now natively implemented in C, the new function takes the same arguments (same order, different names) and has been confirmed to work with lxc-device. Signed-off-by: Stéphane Graber --- diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py index ed1983d06..c3d840c45 100644 --- a/src/python-lxc/lxc/__init__.py +++ b/src/python-lxc/lxc/__init__.py @@ -160,49 +160,6 @@ class Container(_lxc.Container): self.network = ContainerNetworkList(self) - def add_device_node(self, path, destpath=None): - """ - Add block/char device to running container. - """ - - if not self.running: - return False - - if not destpath: - destpath = path - - if not os.path.exists(path): - return False - - # Lookup the source - path_stat = os.stat(path) - mode = stat.S_IMODE(path_stat.st_mode) - - # Allow the target - if stat.S_ISBLK(path_stat.st_mode): - self.set_cgroup_item("devices.allow", - "b %s:%s rwm" % - (int(path_stat.st_rdev / 256), - int(path_stat.st_rdev % 256))) - elif stat.S_ISCHR(path_stat.st_mode): - self.set_cgroup_item("devices.allow", - "c %s:%s rwm" % - (int(path_stat.st_rdev / 256), - int(path_stat.st_rdev % 256))) - - # Create the target - rootfs = "/proc/%s/root/" % self.init_pid - container_path = "%s/%s" % (rootfs, destpath) - - if os.path.exists(container_path): - os.remove(container_path) - - os.mknod(container_path, path_stat.st_mode, path_stat.st_rdev) - os.chmod(container_path, mode) - os.chown(container_path, 0, 0) - - return True - def add_device_net(self, name, destname=None): """ Add network device to running container.