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

User discussion and information resource forum for the TeraByte OS Deployment Tool Suite.
Post Reply
nemesis
Posts: 76
Joined: Mon Jun 21, 2021 12:25 pm

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

Post 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 9264 times
PS the size restrictions for uploads are VERY low!
Last edited by nemesis on Sat Aug 28, 2021 9:13 pm, edited 1 time in total.
Eric
Posts: 224
Joined: Mon Sep 05, 2011 6:53 pm
Location: France

Re: [Bug] SET PART NUM

Post 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).
Last edited by Eric on Fri Aug 27, 2021 7:02 pm, edited 1 time in total.
Eric
Posts: 224
Joined: Mon Sep 05, 2011 6:53 pm
Location: France

Re: [Bug] SET PART NUM

Post 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.
nemesis
Posts: 76
Joined: Mon Jun 21, 2021 12:25 pm

Re: [Bug] SET PART NUM

Post 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
TeraByte Support
Posts: 3596
Joined: Thu May 05, 2011 10:37 pm

Re: [Bug] SET PART NUM

Post 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
nemesis
Posts: 76
Joined: Mon Jun 21, 2021 12:25 pm

Re: [Bug] SET PART NUM

Post 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
TeraByte Support
Posts: 3596
Joined: Thu May 05, 2011 10:37 pm

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

Post 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.
Post Reply