mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
common fstab and libc funcs
This commit is contained in:
@@ -22,12 +22,8 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
|
||||
from ctypes import c_int
|
||||
from ctypes import c_uint
|
||||
from ctypes import c_char_p
|
||||
from ... import libc
|
||||
|
||||
|
||||
# =====
|
||||
@@ -35,14 +31,6 @@ def main() -> None:
|
||||
if len(sys.argv) != 3:
|
||||
raise SystemExit(f"Usage: {sys.argv[0]} <file1> <file2>")
|
||||
|
||||
path = ctypes.util.find_library("c")
|
||||
if not path:
|
||||
raise SystemExit("Where is libc?")
|
||||
assert path
|
||||
libc = ctypes.CDLL(path)
|
||||
libc.renameat2.restype = c_int
|
||||
libc.renameat2.argtypes = [c_int, c_char_p, c_int, c_char_p, c_uint]
|
||||
|
||||
result = libc.renameat2(
|
||||
-100, # AT_FDCWD
|
||||
os.fsencode(sys.argv[1]),
|
||||
@@ -52,4 +40,4 @@ def main() -> None:
|
||||
)
|
||||
|
||||
if result != 0:
|
||||
raise SystemExit(f"{sys.argv[0]}: {os.strerror(ctypes.get_errno())}")
|
||||
raise SystemExit(f"{sys.argv[0]}: {os.strerror(libc.get_errno())}")
|
||||
|
||||
Reference in New Issue
Block a user