From 36d6f176cd1de50fd4fbf4afa5eb32eb8fddc5a1 Mon Sep 17 00:00:00 2001 From: jiangqianrong Date: Fri, 6 Mar 2026 19:35:59 +0800 Subject: [PATCH] Print DFX msg for create partition func Signed-off-by: jiangqianrong --- gpt.cc | 23 +++++++++++++++++++---- gptcl.cc | 2 ++ support.cc | 4 +++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gpt.cc b/gpt.cc index 602a8ac..30f501b 100644 --- a/gpt.cc +++ b/gpt.cc @@ -1991,9 +1991,21 @@ uint32_t GPTData::CreatePartition(uint32_t partNum, uint64_t startSector, uint64 partitions[partNum].SetLastLBA(endSector); partitions[partNum].SetType(DEFAULT_GPT_TYPE); partitions[partNum].RandomizeUniqueGUID(); - } else retval = 0; // if free space until endSector - } else retval = 0; // if startSector is free - } else retval = 0; // if legal partition number + } else { + cerr << "Insufficent space: startSector: " << startSector << ", endSector: " << endSector + << ", maxSector: " << FindLastInFree(startSector) << ".\n"; + retval = 0; // if free space until endSector + } + } else { + cerr << "startSector: " << startSector << ", endSector: " << endSector + << ", free startSector: "<< (IsFree(startSector) ? "true" : "false") << ".\n"; + retval = 0; // if startSector is free + } + } else { + cerr << "partNum: " << (partNum + 1) << ", numParts: " << numParts + << ", IsFreePartNum: " << (IsFreePartNum(partNum) ? "true" : "false") << ".\n"; + retval = 0; // if legal partition number + } return retval; } // GPTData::CreatePartition(partNum, startSector, endSector) @@ -2152,7 +2164,10 @@ int GPTData::ChangePartType(uint32_t partNum, PartType theGUID) { if (!IsFreePartNum(partNum)) { partitions[partNum].SetType(theGUID); - } else retval = 0; + } else { + cerr << "partNum: " << partNum << ", numParts: " << numParts << ".\n"; + retval = 0; + } return retval; } // GPTData::ChangePartType() diff --git a/gptcl.cc b/gptcl.cc index 13bfb36..3417995 100644 --- a/gptcl.cc +++ b/gptcl.cc @@ -319,6 +319,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { break; case 'n': JustLooking(0); + cout << "Create partition option: " << newPartInfo << ".\n"; newPartNum = (int) GetInt(newPartInfo, 1) - 1; if (newPartNum < 0) newPartNum = FindFirstFreePart(); @@ -398,6 +399,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { break; case 't': JustLooking(0); + cout << "Change typecode option: " << (typeCode ? typeCode : "NULL") << ".\n"; partNum = (int) GetInt(typeCode, 1) - 1; if (partNum < 0) partNum = newPartNum; diff --git a/support.cc b/support.cc index 4449364..c971fb9 100644 --- a/support.cc +++ b/support.cc @@ -223,8 +223,10 @@ uint64_t IeeeToInt(string inValue, uint64_t sSize, uint64_t low, uint64_t high, response = high - response; } // if - if (badInput) + if (badInput) { + cerr << "Invalid input: '" << inValue << "', response: " << response << ".\n"; response = UINT64_C(0); + } return response; } // IeeeToInt()