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.
This commit is contained in:
parent
f8ca0cf4bc
commit
5219e96536
1 changed files with 4 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue