]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Rename blkpg functions
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 21 Aug 2022 10:46:31 +0000 (12:46 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 29 Aug 2022 09:55:22 +0000 (11:55 +0200)
Let's rename these to be named after the operation they execute

mkosi/__init__.py
mkosi/backend.py
mkosi/syscall.py

index 892683b86a86ef8e406d46c0b9b190b7f14d64c8..d674f240f59df06749766d3fa4bf605ba20311df 100644 (file)
@@ -106,7 +106,7 @@ from .backend import (
     write_grub_config,
 )
 from .manifest import Manifest
-from .syscall import ioctl_partition_add, ioctl_partition_remove, reflink
+from .syscall import blkpg_add_partition, blkpg_del_partition, reflink
 
 complete_step = MkosiPrinter.complete_step
 
@@ -959,7 +959,7 @@ def attach_image_loopback(image: Optional[BinaryIO], table: Optional[PartitionTa
         # the BLKPKG BLKPG_ADD_PARTITION ioctl().
         with open(loopdev, 'rb+') as f:
             for p in table.partitions.values():
-                ioctl_partition_add(f.fileno(), p.number, table.partition_offset(p), table.partition_size(p))
+                blkpg_add_partition(f.fileno(), p.number, table.partition_offset(p), table.partition_size(p))
 
     try:
         yield loopdev
@@ -969,7 +969,7 @@ def attach_image_loopback(image: Optional[BinaryIO], table: Optional[PartitionTa
             # avoid race conditions by explicitly removing all partition devices before detaching the loop
             # device using the BLKPG BLKPG_DEL_PARTITION ioctl().
             for p in table.partitions.values():
-                ioctl_partition_remove(f.fileno(), p.number)
+                blkpg_del_partition(f.fileno(), p.number)
 
             run(["losetup", "--detach", loopdev])
 
index 6ea3f8afac5144c3a4582c1ef9e3f22078bf7138..6b3e42791389dcefcb196227ad3ddaa780f51aed 100644 (file)
@@ -37,7 +37,7 @@ from typing import (
     cast,
 )
 
-from .syscall import ioctl_partition_add, ioctl_partition_remove
+from .syscall import blkpg_add_partition, blkpg_del_partition
 
 PathString = Union[Path, str]
 
@@ -414,7 +414,7 @@ class PartitionTable:
             with open(device, 'rb+') as f:
                 for p in self.partitions.values():
                     try:
-                        ioctl_partition_remove(f.fileno(), p.number)
+                        blkpg_del_partition(f.fileno(), p.number)
                     except OSError as e:
                         if e.errno != errno.ENXIO:
                             raise
@@ -431,7 +431,7 @@ class PartitionTable:
             # Make sure we re-add all partitions after modifying the partition table.
             with open(device, 'rb+') as f:
                 for p in self.partitions.values():
-                    ioctl_partition_add(f.fileno(), p.number, self.partition_offset(p), self.partition_size(p))
+                    blkpg_add_partition(f.fileno(), p.number, self.partition_offset(p), self.partition_size(p))
 
 
 @dataclasses.dataclass
index f7cfce271a0e6def0d85070ed63c67db49f65409..e3f364f1125357d35efbd9e0a792b337bb99a5cc 100644 (file)
@@ -57,7 +57,7 @@ class blkpg_partition(ctypes.Structure):
     ]
 
 
-def ioctl_partition_add(fd: int, nr: int, start: int, size: int) -> None:
+def blkpg_add_partition(fd: int, nr: int, start: int, size: int) -> None:
     bp = blkpg_partition(pno=nr, start=start, length=size)
     ba = blkpg_ioctl_arg(op=BLKPG_ADD_PARTITION, data=ctypes.addressof(bp), datalen=ctypes.sizeof(bp))
     try:
@@ -68,7 +68,7 @@ def ioctl_partition_add(fd: int, nr: int, start: int, size: int) -> None:
             raise
 
 
-def ioctl_partition_remove(fd: int, nr: int) -> None:
+def blkpg_del_partition(fd: int, nr: int) -> None:
     bp = blkpg_partition(pno=nr)
     ba = blkpg_ioctl_arg(op=BLKPG_DEL_PARTITION, data=ctypes.addressof(bp), datalen=ctypes.sizeof(bp))
     try: