From 5219e9653638a67660cad09b3fea6ca3a5451b76 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 22 Nov 2022 15:01:14 +0100 Subject: [PATCH] devices/loopback: tolerate existing device node It is not an error if the device node already exist, which is e.g. the case when we are using `/dev` of the host. --- devices/org.osbuild.loopback | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/devices/org.osbuild.loopback b/devices/org.osbuild.loopback index 1b19b924..cc104391 100755 --- a/devices/org.osbuild.loopback +++ b/devices/org.osbuild.loopback @@ -18,11 +18,13 @@ documentation for `osbuil.util.udev.UdevInhibitor`. import argparse +import errno import os import sys from typing import Dict from osbuild import devices, loop +from osbuild.util import ctx from osbuild.util.udev import UdevInhibitor SCHEMA = """ @@ -106,7 +108,8 @@ class LoopbackService(devices.DeviceService): dir_fd = -1 try: dir_fd = os.open(devpath, os.O_CLOEXEC | os.O_PATH) - self.lo.mknod(dir_fd) + with ctx.suppress_oserror(errno.EEXIST): + self.lo.mknod(dir_fd) finally: if dir_fd > -1: os.close(dir_fd)