aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/portage/dbapi/_SyncfsProcess.py')
-rw-r--r--lib/portage/dbapi/_SyncfsProcess.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/portage/dbapi/_SyncfsProcess.py b/lib/portage/dbapi/_SyncfsProcess.py
index 6aa04fa58..300ae5398 100644
--- a/lib/portage/dbapi/_SyncfsProcess.py
+++ b/lib/portage/dbapi/_SyncfsProcess.py
@@ -1,8 +1,10 @@
-# Copyright 2012 Gentoo Foundation
+# Copyright 2012-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
+import functools
+
from portage import os
-from portage.util._ctypes import find_library, LoadLibrary
+from portage.util._ctypes import load_libc
from portage.util._async.ForkProcess import ForkProcess
@@ -16,27 +18,24 @@ class SyncfsProcess(ForkProcess):
__slots__ = ("paths",)
+ def _start(self):
+ self.target = functools.partial(self._target, self._get_syncfs, self.paths)
+ super()._start()
+
@staticmethod
def _get_syncfs():
-
- filename = find_library("c")
- if filename is not None:
- library = LoadLibrary(filename)
- if library is not None:
- try:
- return library.syncfs
- except AttributeError:
- pass
-
+ (libc, _) = load_libc()
+ if libc is not None:
+ return getattr(libc, "syncfs", None)
return None
- def _run(self):
-
+ @staticmethod
+ def _target(get_syncfs, paths):
syncfs_failed = False
- syncfs = self._get_syncfs()
+ syncfs = get_syncfs()
if syncfs is not None:
- for path in self.paths:
+ for path in paths:
try:
fd = os.open(path, os.O_RDONLY)
except OSError: