Skip to content

Commit

Permalink
printf2
Browse files Browse the repository at this point in the history
  • Loading branch information
pothos committed Nov 22, 2023
1 parent e49954f commit ccb2dd7
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
From 4eed85553831e65803d04c96ba5f5feb6dc65076 Mon Sep 17 00:00:00 2001
From: Kai Lueke <[email protected]>
Date: Tue, 21 Nov 2023 17:39:23 +0100
Subject: [PATCH] printf

---
internal/exec/stages/disks/partitions.go | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/internal/exec/stages/disks/partitions.go b/internal/exec/stages/disks/partitions.go
index 97591c2f..a624435b 100644
--- a/internal/exec/stages/disks/partitions.go
+++ b/internal/exec/stages/disks/partitions.go
@@ -335,6 +335,7 @@ func blockDevHeld(blockDev string) (bool, error) {
if err != nil {
return false, fmt.Errorf("failed to retrieve holders of %q: %v", blockDev, err)
}
+ fmt.Printf("blockDevHeld: dir %v, entries: %v", holdersDir, entries)
return len(entries) > 0, nil
}

@@ -356,6 +357,7 @@ func blockDevMounted(blockDev string) (bool, error) {
if err != nil {
return false, fmt.Errorf("failed to resolve %q: %v", mountSource, err)
}
+ fmt.Printf("mountcheck: %v vs %v", mountSourceResolved, blockDevResolved)
if mountSourceResolved == blockDevResolved {
return true, nil
}
@@ -382,6 +384,7 @@ func blockDevPartitions(blockDev string) ([]string, error) {
}
var partitions []string
for _, entry := range entries {
+ fmt.Printf("blockDevPartitions: name: %v node prefix: %v\n", entry.Name(), blockDevNode+"p")
if strings.HasPrefix(entry.Name(), blockDevNode+"p") {
partitions = append(partitions, "/dev/"+entry.Name())
}
@@ -406,13 +409,16 @@ func blockDevInUse(blockDev string) (bool, []string, error) {
if err != nil {
return false, nil, fmt.Errorf("failed to retrieve partitions of %q: %v", blockDev, err)
}
+ fmt.Printf("blockDevInUse: partitions: %v\n", partitions)
var activePartitions []string
for _, partition := range partitions {
held, err := blockDevHeld(partition)
+ fmt.Printf("blockDevInUse: partition %v held: %v\n", partition, held)
if err != nil {
return false, nil, fmt.Errorf("failed to check if %q is held: %v", partition, err)
}
mounted, err := blockDevMounted(partition)
+ fmt.Printf("blockDevInUse: partition %v mounted: %v\n", partition, mounted)
if err != nil {
return false, nil, fmt.Errorf("failed to check if %q is mounted: %v", partition, err)
}
@@ -433,6 +439,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
if inUse && len(activeParts) == 0 {
return fmt.Errorf("refusing to operate on directly active disk %q", devAlias)
}
+ fmt.Printf("PRINT: inUse: %v activeParts: %v\n", inUse, activeParts)
if cutil.IsTrue(dev.WipeTable) {
op := sgdisk.Begin(s.Logger, devAlias)
s.Logger.Info("wiping partition table requested on %q", devAlias)
@@ -459,6 +466,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
if err != nil {
return fmt.Errorf("failed to resolve %q: %v", devAlias, err)
}
+ fmt.Printf("PRINT: blockDevResolved: %v\n", blockDevResolved)

// get a list of parititions that have size and start 0 replaced with the real sizes
// that would be used if all specified partitions were to be created anew.
@@ -527,6 +535,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
if partInUse && modification {
return fmt.Errorf("refusing to modfiy active partition %d on %q", part.Number, devAlias)
}
+ fmt.Printf("PRINT: partInUse %v, modification %v\n", partInUse, modification)
}

if err := op.Commit(); err != nil {
@@ -538,10 +547,13 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
// kernel partition table with BLKPG but only uses BLKRRPART which fails
// as soon as one partition of the disk is mounted
cmd := exec.Command(distro.PartxCmd(), "-u", "-", blockDevResolved)
+ fmt.Printf("PRINT: cmd: %v\n", cmd)
if _, err := s.Logger.LogCmd(cmd, "triggering partition table reread on %q", devAlias); err != nil {
return fmt.Errorf("re-reading partitions failed: %v", err)
}
+ fmt.Printf("PRINT: partx ran\n")
}
+ fmt.Printf("PRINT: wait for udev\n")

// It's best to wait here for the /dev/ABC entries to be
// (re)created, not only for other parts of the initramfs but
--
2.42.0

Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ PATCHES=(
"${FILESDIR}/0021-internal-exec-stages-mount-Mount-oem.patch"
"${FILESDIR}/0022-disks-Refuse-to-modify-disks-partitions-in-use.patch"
"${FILESDIR}/0023-sgdisk-Run-partx-after-partition-changes.patch"
"${FILESDIR}/0024-printf.patch"
)

src_compile() {
Expand Down

0 comments on commit ccb2dd7

Please sign in to comment.