Skip to content

Commit ccb2dd7

Browse files
committed
printf2
1 parent e49954f commit ccb2dd7

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
From 4eed85553831e65803d04c96ba5f5feb6dc65076 Mon Sep 17 00:00:00 2001
2+
From: Kai Lueke <kailuke@microsoft.com>
3+
Date: Tue, 21 Nov 2023 17:39:23 +0100
4+
Subject: [PATCH] printf
5+
6+
---
7+
internal/exec/stages/disks/partitions.go | 12 ++++++++++++
8+
1 file changed, 12 insertions(+)
9+
10+
diff --git a/internal/exec/stages/disks/partitions.go b/internal/exec/stages/disks/partitions.go
11+
index 97591c2f..a624435b 100644
12+
--- a/internal/exec/stages/disks/partitions.go
13+
+++ b/internal/exec/stages/disks/partitions.go
14+
@@ -335,6 +335,7 @@ func blockDevHeld(blockDev string) (bool, error) {
15+
if err != nil {
16+
return false, fmt.Errorf("failed to retrieve holders of %q: %v", blockDev, err)
17+
}
18+
+ fmt.Printf("blockDevHeld: dir %v, entries: %v", holdersDir, entries)
19+
return len(entries) > 0, nil
20+
}
21+
22+
@@ -356,6 +357,7 @@ func blockDevMounted(blockDev string) (bool, error) {
23+
if err != nil {
24+
return false, fmt.Errorf("failed to resolve %q: %v", mountSource, err)
25+
}
26+
+ fmt.Printf("mountcheck: %v vs %v", mountSourceResolved, blockDevResolved)
27+
if mountSourceResolved == blockDevResolved {
28+
return true, nil
29+
}
30+
@@ -382,6 +384,7 @@ func blockDevPartitions(blockDev string) ([]string, error) {
31+
}
32+
var partitions []string
33+
for _, entry := range entries {
34+
+ fmt.Printf("blockDevPartitions: name: %v node prefix: %v\n", entry.Name(), blockDevNode+"p")
35+
if strings.HasPrefix(entry.Name(), blockDevNode+"p") {
36+
partitions = append(partitions, "/dev/"+entry.Name())
37+
}
38+
@@ -406,13 +409,16 @@ func blockDevInUse(blockDev string) (bool, []string, error) {
39+
if err != nil {
40+
return false, nil, fmt.Errorf("failed to retrieve partitions of %q: %v", blockDev, err)
41+
}
42+
+ fmt.Printf("blockDevInUse: partitions: %v\n", partitions)
43+
var activePartitions []string
44+
for _, partition := range partitions {
45+
held, err := blockDevHeld(partition)
46+
+ fmt.Printf("blockDevInUse: partition %v held: %v\n", partition, held)
47+
if err != nil {
48+
return false, nil, fmt.Errorf("failed to check if %q is held: %v", partition, err)
49+
}
50+
mounted, err := blockDevMounted(partition)
51+
+ fmt.Printf("blockDevInUse: partition %v mounted: %v\n", partition, mounted)
52+
if err != nil {
53+
return false, nil, fmt.Errorf("failed to check if %q is mounted: %v", partition, err)
54+
}
55+
@@ -433,6 +439,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
56+
if inUse && len(activeParts) == 0 {
57+
return fmt.Errorf("refusing to operate on directly active disk %q", devAlias)
58+
}
59+
+ fmt.Printf("PRINT: inUse: %v activeParts: %v\n", inUse, activeParts)
60+
if cutil.IsTrue(dev.WipeTable) {
61+
op := sgdisk.Begin(s.Logger, devAlias)
62+
s.Logger.Info("wiping partition table requested on %q", devAlias)
63+
@@ -459,6 +466,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
64+
if err != nil {
65+
return fmt.Errorf("failed to resolve %q: %v", devAlias, err)
66+
}
67+
+ fmt.Printf("PRINT: blockDevResolved: %v\n", blockDevResolved)
68+
69+
// get a list of parititions that have size and start 0 replaced with the real sizes
70+
// that would be used if all specified partitions were to be created anew.
71+
@@ -527,6 +535,7 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
72+
if partInUse && modification {
73+
return fmt.Errorf("refusing to modfiy active partition %d on %q", part.Number, devAlias)
74+
}
75+
+ fmt.Printf("PRINT: partInUse %v, modification %v\n", partInUse, modification)
76+
}
77+
78+
if err := op.Commit(); err != nil {
79+
@@ -538,10 +547,13 @@ func (s stage) partitionDisk(dev types.Disk, devAlias string) error {
80+
// kernel partition table with BLKPG but only uses BLKRRPART which fails
81+
// as soon as one partition of the disk is mounted
82+
cmd := exec.Command(distro.PartxCmd(), "-u", "-", blockDevResolved)
83+
+ fmt.Printf("PRINT: cmd: %v\n", cmd)
84+
if _, err := s.Logger.LogCmd(cmd, "triggering partition table reread on %q", devAlias); err != nil {
85+
return fmt.Errorf("re-reading partitions failed: %v", err)
86+
}
87+
+ fmt.Printf("PRINT: partx ran\n")
88+
}
89+
+ fmt.Printf("PRINT: wait for udev\n")
90+
91+
// It's best to wait here for the /dev/ABC entries to be
92+
// (re)created, not only for other parts of the initramfs but
93+
--
94+
2.42.0
95+

sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-9999.ebuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ PATCHES=(
6565
"${FILESDIR}/0021-internal-exec-stages-mount-Mount-oem.patch"
6666
"${FILESDIR}/0022-disks-Refuse-to-modify-disks-partitions-in-use.patch"
6767
"${FILESDIR}/0023-sgdisk-Run-partx-after-partition-changes.patch"
68+
"${FILESDIR}/0024-printf.patch"
6869
)
6970

7071
src_compile() {

0 commit comments

Comments
 (0)