Voodooprojects

Chameleon => Feature Requests => Topic started by: zarac on June 19, 2010, 10:41:32 PM

Title: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zarac on June 19, 2010, 10:41:32 PM
could it be possible to expand the functionality of "Default Partition" by adding other ways of identifying the partition?

for instance using volume UUID:
Code: [Select]
"Default Partition"=UUID(EC541531-1D67-3116-A981-6521E97E20FE)
or by device tree:
Code: [Select]
"Default Partition"=PCI0@0/IDE1@1F,2/PRIM@0/PMP@0
the reason i'm asking this is because my disk numbers change depending on how many usb sticks or external disks (usb and esata) i have plugged during boot. for instance, my snow leopard volume can be seen as anything from disk0s2 to disk3s2.

needless to say, chameleon often tries to boot the wrong partition here.

thanks for reading :)

Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zarac on June 23, 2010, 02:39:27 PM
nobody else has this problem?

i cannot circumvent this problem because my ich9 ahci is flakey, so esata hot-swap doesn't work every time.
then i have to reboot osx with esata plugged in, and my "default partition" isn't there anymore.

well, nevermind. Boot Think deals with this perfectly - even though i'd rather use Chameleon because it's open source.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on July 19, 2010, 01:35:45 AM
Hi zarac,

Just committed your feature request into trunk:

http://forge.voodooprojects.org/p/chameleon/source/commit/182/

Now you can freely swap your disks, the booter should find the given partition if you use this alternate format for
the "Default Partition" option:

Code: [Select]
<key>Default Partition</key>                                                                                               
<string>0A81F3B1-51D9-3335-B3E3-169C3640360D</string>

Bye,
zef
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zarac on July 19, 2010, 01:31:47 PM
thank you, i appreciate it!
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on July 27, 2010, 01:00:15 PM
Since we're on the subject, I wrote a patch so devices can be specified as hd(x,y), UUID, and also a label enclosed in quotes. Unlike what's currently committed, it works for renaming, hiding and selecting partitions as default.

It took quite a bit more work than I expected because I had to write code to handle XML entities, which I needed because they're the 'right way' to do things, but mainly because PList Editor uses them.

Some examples that I tested and should work now (based on trunk revision 264) follow. Quotes are mandatory with a single exception: they're optional in the new name to assign to a renamed partition.

Code: ('xml') [Select]
<key>Rename Partition</key>
<string>"Windows" Windows 7; B8EA194F-69BE-35A4-AFF6-C51FCD0DA656 Mac OS X SL; hd(1,1) Hidden Partition</string>
<key>Hide Partition</key>
<string>hd(1,2) "Hidden Partition"</string>
<key>Default Partition</key>
<string>"Mac OS X SL"</string>

Any testers?
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Terc on July 27, 2010, 08:49:01 PM
Whoah.  Very slick.
Even zef's commit would have been nice, but I _really_ like this.  I'm booting from chameleon on a usb onto a raid, so I've always had to specify the disk.  Labels or uuid would be such a blessing.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on July 28, 2010, 04:58:26 AM
@Terc:

Here's a compiled version for you, if you'd like to help with testing.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Terc on July 28, 2010, 07:35:57 AM
I'll give it a shot tomorrow.  I was up way too late last night.  Thanks for building it for me though, I'll let you know how it goes.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zarac on July 28, 2010, 12:59:14 PM
whoa! nice development.
i'm on vacation and away from my hackintosh, but will test this as soon as i return home.

thank you!
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on July 29, 2010, 12:29:26 AM
@danielkza:

Thanks, this looks pretty awesome! Just added your patch to my todo list :)
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on July 29, 2010, 09:03:30 AM
@zef:

Thank you. But...

I think I found some small mistakes, that I'll be correcting soon. It'd be a good idea to hold it for a while before commiting :P
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on July 29, 2010, 11:44:37 AM
@zef:

Thank you. But...

I think I found some small mistakes, that I'll be correcting soon. It'd be a good idea to hold it for a while before commiting :P

How about creating a branch for you in the repo, then you can fix the issues and later we can merge back your changes?

I would need your forge login name to do that.

Thanks!

Bye,
zef
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on July 31, 2010, 05:44:29 AM
@zef:

Just created an account named danielkza on forge.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on July 31, 2010, 05:12:53 PM
Hi danielkza,

Created a branch for you:

http://forge.voodooprojects.org/p/chameleon/source/tree/HEAD/branches/danielkza

You can use your forge login + extra password to get write access for the repo (visit this url: http://forge.voodooprojects.org/p/chameleon/source/help/)

Thanks for your efforts! :)

Bye,
zef
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on August 21, 2010, 09:38:43 PM
@Danielkza:

Many thanks for your efforts! Merged back your changes with some modifications into the trunk (starting at r413):

http://forge.voodooprojects.org/p/chameleon/source/commit/416/

Tested the new features on the "Hide Partition" option with NTFS partitions' volume labels and volume serials. So far so good :)

Let me know if I missed or messed something :)

Bye,
zef
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on August 22, 2010, 02:48:55 AM
@zef:

I found quite a bit of problems that I intend to fix soon. I've started working on them yesterday after I found out renaming a partition whose name is a substring of the alias doesn't work. The only way to fix that is to actually parse the string instead of (lazily) looking up substrings and hoping it works.

Edit: I think everything is working as it should now. I'll commit to my branch after I do some cleanup.
Edit2: Just clarifying, the problems were not your fault. They're now fixed in my branch anyway: all the basic tests I could think of worked, but I obviously need confirmation from other people as well.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on August 26, 2010, 11:05:13 AM
Thx! I will merge back your changes as soon as I can! :)
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Azimutz on August 28, 2010, 02:21:07 AM
Hi Danielkza, Zef,

Zane reported this stuff here (http://forum.voodooprojects.org/index.php/topic,1024.msg8004.html#msg8004), on the pic; i managed to isolate it to when the Default volume (showed on Timeout) is renamed. It happens just on Timeout screen and used theme seems irrelevant (used Legacy & Embed).
It was definitely introduced with rev 432.
Waiting on Zane's feedback...

Also "Rename Partition" related, the alias needs to be wrapped in "" if it contains spaces, else
Quote
OS X Install
for instance, will only show
Quote
OS

Feel reported :)
See ya later...
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on August 28, 2010, 03:03:26 PM
@Azimutz:
I found out the second bug myself just yesterday, and luckily it's an easy fix. I'll have to investigate the first one further: maybe I'm overwriting memory somehow?!

Thanks for the feedback.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on August 28, 2010, 05:55:44 PM
@Danielkza:

Please review the usage of sizeof() calls as well:

For example:

Code: [Select]
char dummy[80];
getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );

sizeof(dummy) is 4 since dummy is a pointer.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on August 28, 2010, 07:32:58 PM
Hi Danielkza, Zef,

Zane reported this stuff here (http://forum.voodooprojects.org/index.php/topic,1024.msg8004.html#msg8004), on the pic; i managed to isolate it to when the Default volume (showed on Timeout) is renamed. It happens just on Timeout screen and used theme seems irrelevant (used Legacy & Embed).

Roger that, I'm working on it! :)

EDIT: Try this one: http://forge.voodooprojects.org/p/chameleon/source/commit/438/

Also "Rename Partition" related, the alias needs to be wrapped in "" if it contains spaces, else
Quote
OS X Install
for instance, will only show
Quote
OS

I don't see any issue here since space is a delimiter, you need to enclose in quotes in other places as well.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on August 28, 2010, 09:23:21 PM
@Danielkza:

Please review the usage of sizeof() calls as well:

For example:

Code: [Select]
char dummy[80];
getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );

sizeof(dummy) is 4 since dummy is a pointer.
dummy is an array of characters, and sizeof works as it should.

http://en.wikipedia.org/wiki/Sizeof#Using_sizeof_with_arrays

I can understand if you want to avoid it, but you need to use (size of the array)-1 for it to be correct, unlike what's in the modifications you made before commiting:

Code: ('cpp') [Select]
char dummy[80];
// mine (right)
getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );
// trunk (wrong)
getBootVolumeDescription( gBootVolume, dummy, 80, true );

Edit: Uh oh, after browsing a bit through the source, I found quite many instances of the similar mistakes. Luckily Chameleon runs on its own: we'd have tons of buffer overflows otherwise. An example:

dumpPhysAddr @ i386/libsaio/mem.c

Code: [Select]
// ...
        strncat(buffer, str, sizeof(buffer));
    }
    strncat(buffer,"  ", sizeof(buffer));
    for (j=0; j < (len%STEP); j++)  {
        sprintf(str, "%c", DC(ad[i+j])); 
        strncat(buffer, str, sizeof(buffer));
// ...

Quote from: 'The Open Group'
char *strncat(char *restrict s1, const char *restrict s2, size_t n);

The strncat() function shall append not more than n bytes (a null byte and bytes that follow it are not appended) from the array pointed to by s2 to the end of the string pointed to by s1. The initial byte of s2 overwrites the null byte at the end of s1. A terminating null byte is always appended to the result. If copying takes place between objects that overlap, the behavior is undefined.

If n chars from s2 are copied plus the terminating null, s1 should be at least n+1 chars in size. Or, if you prefer, n should be sizeof(buffer)-1.


Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on August 28, 2010, 11:29:34 PM
If n chars from s2 are copied plus the terminating null, s1 should be at least n+1 chars in size. Or, if you prefer, n should be sizeof(buffer)-1.

Sorry, you're totally right! :)
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Azimutz on August 29, 2010, 03:08:34 AM
Zef, Danielkza,

confirming the fix on rev 438

The other issue... well, it's more like issues :) as i already had my hands on it, took some time to check the trio
Default/Rename/Hide Partition and some other...

Default Partition:
At least BootHelp.txt (BH.txt) needs edit; "label" (enclosed in quotes) doesn't work , even if the label has spaces!
No quotes works, even if the label has spaces.

Rename Partition:
the stuff i mentioned on the last post; this
Code: [Select]
<key>Rename Partition</key>
<string>"Mac OS X Install DVD" OS X Install</string>
always worked fine till rev 432 (without quotes) and that's how i thought it worked based on previous BH.txt info.
Judging by Danielkza answer and the actual BH.txt, i assume that's how he meant it to work!?

Hide Partition:
this
Code: [Select]
<key>Hide Partition</key>
<string>Windows 7 Mac OS X Install DVD</string>
works perfectly! (yep, i removed "& kBVFlagForeignBoot" to test)

So, it's mainly a BootHelp thing (or not); when compared with the comments on the code, things get a bit confuse.
On a slightly diff note... none of the keys with spaces on the name (on BH.txt), work quoted.
Didn't tested Rescan Prompt and Scan Single Drive, but i guess...

That's it.. Thanks.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on August 29, 2010, 03:49:08 AM
@Azimuts:

Default Partition: it worked for me, but maybe I missed something. I'll take a look at it, together with all the other stuff, now that I have some spare time.

Rename Partition: I intend a quoted name plus an unquoted alias to work, but now that I think about it, I'm not sure if it's actually a good idea. We'll have to choose beetween consistency (every partition with spaces must be quoted) or ease of use (quotes aren't strictly needed: a semicolon or the end of the string will delimit the alias just fine).

BootHelp.txt indeed needs some work. But this should be postponed until the final behavior is decided.

Hide Partition: What you mentioned was actually an accidental match from the 'lazy' old code. It looped through each partition checking if the label was present in the 'Default Partition' key. Something like 'Windows 7LOLWUT' would (wrongfully) match a partition labeled 'Windows 7'.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Azimutz on August 29, 2010, 05:37:24 AM
Danielkza,

this is the real issue i was pointing:
Quote
We'll have to choose beetween consistency (every partition with spaces   must be quoted) or ease of use (quotes aren't strictly needed: a   semicolon or the end of the string will delimit the alias just fine).
on the user side, my opinion is the simple the better! But ultimately, quotes or not, consistency and efficiency win.
On the code side, i guess ease of maintenance wins.

Let's see what Zef has to say...
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: danielkza on August 29, 2010, 07:33:34 AM
I just though of something that could be useful, and has the indirect consequence of solving the matter by needing all labels with spaces to be quoted.

Would specifying multiple default partitions (the first one, left-to-right, that matches anything makes that partition default) be of use to someone besides me? I'd use it to boot from my USB drive automatically if it's inserted.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: zef on August 29, 2010, 08:40:53 AM
I just though of something that could be useful, and has the indirect consequence of solving the matter by needing all labels with spaces to be quoted.

Would specifying multiple default partitions (the first one, left-to-right, that matches anything makes that partition default) be of use to someone besides me? I'd use it to boot from my USB drive automatically if it's inserted.

It would be great!

And I would vote for using quotes with labels containing spaces in all cases.

Thanks for your efforts! :)
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Azimutz on August 29, 2010, 01:54:13 PM
Yeah, that could be handy... never crossed my mind :) good inspiration, Danielkza.

Hey, i'm ok with quotes on stuff with spaces. Just make it a standart.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Azimutz on September 10, 2010, 07:58:24 PM
I just though of something that could be useful, and has the indirect consequence of solving the matter by needing all labels with spaces to be quoted.

Would specifying multiple default partitions (the first one, left-to-right, that matches anything makes that partition default) be of use to someone besides me? I'd use it to boot from my USB drive automatically if it's inserted.
Hi Danielkza,

what's the status on the quoted stuff? mainly the quotes + spaces stuff...
No pressure :)
Thanks.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: AuralArch on September 15, 2010, 04:21:18 AM
This is awesome guys!  How much of this IS currently integrated into the trunk?  And how exactly can it be used.  It needs some documentation in the boothelp file...  I'll try it out, but the hide/rename partition by UUID will be especially helpful since I have more than one disk with "System Reserved" partition.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: Azimutz on September 15, 2010, 10:55:43 AM
AuralArch,

this stuff is all in the trunk, mentioned on BootHelp and if you read the last posts you'll even get a decent picture of the problems :) but, it doesn't hurt to mention again...
There's just a problem with "" and spaces, mainly names of keys with spaces are supposed to be wrapped in quotes like they are showed on BootHelp, but e.g. "Hide Partition" will not work so, for now ditch the "".
If you want to hide all System Reserved partitions at once, just add this to Boot.plist:
Code: [Select]
    <key>Hide Partition</key>
    <string>System Reserved</string>
all volumes that match the string will be hidden. As you can see "" are also not needed on the string (volume label) like they are supposed to; can't remember if they break the key or not?!

Hope it helps...
Stay safe.
Title: Re: Support for volume UUID and/or device tree lookup in "Default Partition"
Post by: AuralArch on October 22, 2010, 03:38:37 PM
Azimutz,  (& @danielkza)

Thank you so much for you quick reply & explanation, it was very helpful.  I apologize for such a delayed response. I intended to post a reply that same night.

So, It turned out that somehow an old version of the help file had been distributed with the version of Chameleon I was using at the time.  I didn't test it out though because I originally came here for sources because I needed to customize 'ati.c' in order to get my video cards working & displays all working properly.
I actually had read the whole topic but I was still unclear on some of the details- and of course I didn't know it had already been integrated because I had an obsolete help file. But I basically got it mostly figured out.
It still seems a bit quirky to me, although it's probably just syntax/formatting details that I'm unaware of or don't fully/properly understand.

The process of figuring out the specifics of the syntax, like exactly when to use & when not to use quotes involved some trail and error because at first it didn't seem to be following the pattern of: use "" with anything containing space(s) but I think that does work now- although it still works in certain cases of spaces without ""...

There are still some other details that I have yet to figure out as well.

The hardest part of the process was getting my multiple "System Reserved" partitions renamed accurately to reflect the operating system they boot. (Since I primarily use Chameleon as bootloader, I have all of the other OS's bootloaders configured to skip their menus.)  I obviously could't use their label to rename them individually, their UUID doesn't work since it's a windows drive & it hasn't been assigned yet (if I understand what I read elsewhere properly- unless I'm not doing it right?). The remaining option: using 'hd(x,y)' is also problematic because those numeric assignments of the drives are not constant for me.
Natually adding or removing drives can typically affects the order of the drives, but sometimes they just randomly change- when I haven't made any changes to the system at all- just "restart".  I can't figure out any patterns or causes for some of these re-structuring of the disk #s in Chameleon especially since it happens fairly infrequently.

I don't know enough to know whether the BIOS is responsible for this or Chameleon itself.
Also, Chameleon sometimes does not load the right OS (it doesn't load the OS/bootloader on that partition-  especially if it's not the (numerical) first "System Reserved" partition in Chameleon's list, in which case the first one is loaded or: if it doesn't load the first "System Reserved"'s bootloader in Chameleon's list, then it loads the first one to be posted in BIOS- OR it just loads the first the bootloader from the 1st active partition with a bootloader (using BIOS/POST order).  TOTALLY bizarre!!!  (Only glitches like that if I trying to boot from a "System Reserved" partition when there are at least two present.)

Do you (or anybody) have any thoughts, ideas or insights that might be helpful?

It would be very helpful to my situation if I were able to use the IODeviceTree path to rename partitions (or UUIDs for NTFS partitions, even better!).  If either/both of those is already possible then I'm a moran because I can't get it to work!

I would also propose that the Chameleon help file be more explicit in its description of the exact syntax to be used for the partition related keys.  Such as:
1. how to separate the entries (apparently that is a semicolon most of the time, and a comma in certain circumstances)
2. where and how to use (and not to use) spaces
3. where and how to use (and not to use) quotation marks
4. when/for which partitions UUIDs can be used (and can not be used)
5. if the entries must be in any order & what that may be (BIOS/POST order, all entries of one type (UUIDs, labels...) grouped together, or in a certain order

The strangest practice which I've had to adopt which I can not explain is: in an attempt to hide one of my "System Reserved" partitions which boots an installation which I only use in an emergency. My only option is to use 'hd(x,y)' to specify the partition.  However, it doesn't work if it's the first item in the string followed by a colon.  But it does work if I put it at the end as the last item.  Strange!
(I may be mistaken about whether this was effective, but I found an old Boot.plist file in which I was using only the 'hd(x,y)' method, and I was separating the entries with commas. I haven't test if that still works for that type of entry.)

I know this is not an issue of relatively high importance to this project as a whole, and further development may or may not contitnue soon, or at all.  But I would be very gladly volunteer to assist in testing whatever changes/new features anyone develops. I have lots of hard drives with a plethora of different OSes installed on them in various "positions" on the drives some configured in RAID 1 & 0 arrays.  So it's easy for me to test many, more complicated/intricate configurations.
Given detailed & concise instructions I can follow them exactly and give precise & detailed reports of the results & experiences.


It would be a nice, helpful feature that I would appreciate for Chameleon to automatically (or using a key) hide all of partitions (with possibility to show them if needed) any partitions which are not marked as "active"


Thanks in advance to anyone who reads this, especially anyone who helps me learn more!