Page 1 of 1

[Bug] SET PART NUM (Answered by TeraByte as, as designed)

Posted: Fri Aug 27, 2021 11:51 am
by nemesis
Hi TeraByte,

I think I found a bug in your code base. Specificaly the "SET PART NUM" function. The entry uses a different index shema.

Code to reproduse:

Code: Select all

Sub Main()
    PrintL("Provide HD number")
    hdNumber = GetKey() - 48
    Ext("LIST HD " # hdNumber # " /f /u /w /t /a=2048")
    PrintL("Provide from partition index")
    from = GetKey() - 48
    PrintL("Provide to partition index")
    dest = GetKey() - 48
    command = "SET PART NUM " # hdNumber # " " # from # " " # dest
    PrintL("Running command: " # command)
    Ext("SET PART NUM " # hdNumber # " " # from # " " # dest)
    Ext("LIST HD " # hdNumber # " /f /u /w /t /a=2048")
End Sub
Result:
Capture.jpg
Capture.jpg (122.1 KiB) Viewed 11867 times
PS the size restrictions for uploads are VERY low!

Re: [Bug] SET PART NUM

Posted: Fri Aug 27, 2021 6:45 pm
by Eric
You should use "set part num 0 7 4" to give the ID 0x5 to partition 0x7.
The num starts from 0, not from 1 (it is 0 based).
The same thing applied on MBR disks (where "set part id" doesn't work).

Re: [Bug] SET PART NUM

Posted: Fri Aug 27, 2021 7:01 pm
by Eric
Take care that Windows may reorder all those IDs on some cases. I don't remember exactly when (probably just when connecting the disk, or when booting into that disk, or when creating a partition...), but I know that such thing may appears.

Re: [Bug] SET PART NUM

Posted: Fri Aug 27, 2021 9:43 pm
by nemesis
hi Eric, thnx. I came to the same conclusion. however both partition identifiers describe the same thing one current the other new. I'd say that constitutes either a bug over very bad design.

tbscript is a bit of mess concerning indexes tbh.

I reorder them whenever I need them and they're wrong so no worries.

regards, davy

Re: [Bug] SET PART NUM

Posted: Sat Aug 28, 2021 3:10 pm
by TeraByte Support
If you type "help set part num" it will give you the format.
SET PART NUM phyhdnum partid entrynum
entrynum - partition table entry number from 0-n.
So it makes since. You're asking it to move a given partition (by id) to a particular partition table entry num.

Also since those ID's are in hex, you can use the same by appending 0x to your number. So 0x1B would be same as entering 27

Re: [Bug] SET PART NUM

Posted: Sat Aug 28, 2021 9:10 pm
by nemesis
Hi,

thnx for the help command, I did not know that!

Isn't the Partition Id the same as the table entry number except for it being off by 1? So why stick to the Id in one instance and to the number representing the same thing somewhere else? It just creates confusion, makes the code it's used in excessively complex and difficult to read. Stating it's a zero based array doesn't explain anything, it just raises more question. Also the partid parameter name is inconsistently used through out these functions.

The id's are just int's right? Which are binary, they can be represented in either hex and decimal.

I understand tbscript is not a full fledged programming language and is based off of VB6. But still consistency and proper naming are key to writing good code.

This is meant as feedback not as negativity. I think the quality of the documentation and samples do not do your great support and products justice!

With kind regards,

Davy

Re: [Bug] SET PART NUM (Answered by TeraByte as, as designed)

Posted: Sun Aug 29, 2021 8:09 am
by TeraByte Support
The partition ID is part of the EMBR spec. MBR doesn't have them so the partition entry+1 is used, GPT for convenience the partition table entry+1 is used as well so you don't have to always deal with GUIDs. Likewise extended partition volumes are a combination of the partition entry and optionally sequential or set to a fixed random value. It's going to be labeled id or partid or partitionid based on how long the help line would be, but it's all the same thing.