Chameleon

Chameleon Commit Details

Date:2010-08-26 22:06:20 (10 years 2 months ago)
Author:Tamás Kosárszky
Commit:432
Parents: 431
Message:Applied danielkza's changes (r424, r425).
Changes:
M/trunk/i386/libsa/libsa.h
M/trunk/i386/libsaio/disk.c
M/trunk/i386/boot2/options.c
M/trunk/i386/libsa/string.c
M/trunk/i386/libsaio/disk.h

File differences

trunk/i386/libsaio/disk.c
16021602
16031603
16041604
1605
1606
1605
1606
1607
1608
1609
1610
1611
1612
1613
16071614
16081615
16091616
......
16851692
16861693
16871694
1688
1695
16891696
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
17051697
1706
1707
1708
1709
1710
1711
1698
17121699
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
17461726
17471727
1748
1749
1728
1729
1730
1731
1732
1733
17501734
1751
1752
1753
1754
1735
17551736
17561737
17571738
......
17591740
17601741
17611742
1762
1763
1764
1743
1744
1745
1746
17651747
1766
1767
1748
1749
17681750
1769
1770
1771
1772
1773
1774
1775
1751
1752
1753
17761754
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1755
1756
17871757
17881758
1789
1790
1791
1792
1759
1760
17931761
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
18141773
18151774
1816
1775
18171776
18181777
18191778
......
18421801
18431802
18441803
1845
1846
1804
18471805
18481806
18491807
......
18691827
18701828
18711829
1872
1830
18731831
18741832
18751833
*/
if ( (newBVR->flags & kBVFlagForeignBoot) )
{
if(val && matchVolumeToString(newBVR, val, true))
newBVR->visible = false;
char *start, *next = val;
long len = 0;
do
{
start = strbreak(next, &next, &len);
if(len && matchVolumeToString(newBVR, start, len) )
newBVR->visible = false;
}
while ( next && *next );
}
/*
//==========================================================================
static char * matchStrings(const char * str1, const char * str2, bool matchPartial)
bool matchVolumeToString( BVRef bvr, const char* match, long matchLen)
{
char * ret = NULL;
if (matchPartial)
ret = strstr(str1, str2);
else if (!strcmp(str1, str2))
ret = (char *)str1;
if(ret)
ret += strlen(str2);
return ret;
}
char * matchVolumeToString(BVRef bvr, const char * match, bool matchPartial)
{
char testStr[128];
char tempStr[128];
char * ret = NULL;
int len = 0;
*tempStr = '\0';
if ( !bvr || !match || !*match)
return NULL;
if ( bvr->biosdev < 0x80 || bvr->biosdev >= 0x100
|| !(bvr->flags & (kBVFlagSystemVolume|kBVFlagForeignBoot)) )
return NULL;
// Try to match hd(x,y) first.
sprintf(testStr, "hd(%d,%d)", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (ret = matchStrings(match, testStr, matchPartial))
return ret;
// Try to match volume UUID.
if ( bvr->fs_getuuid && !(bvr->fs_getuuid(bvr, testStr)) )
{
if (ret = matchStrings(match, testStr, matchPartial))
return ret;
}
// Try to match volume label (always quoted).
if (bvr->description)
{
// Gather volume label into tempStr.
bvr->description(bvr, tempStr, sizeof(tempStr) - 1);
len = strlen(tempStr);
if (len == 0)
return NULL;
sprintf(testStr, "\"%s\"", tempStr);
if (ret = matchStrings(match, testStr, matchPartial))
return ret;
}
return NULL;
return 0;
if ( bvr->biosdev < 0x80 || bvr->biosdev >= 0x100 )
return 0;
// Try to match hd(x,y) first.
sprintf(testStr, "hd(%d,%d)", BIOS_DEV_UNIT(bvr), bvr->part_no);
if ( matchLen ? !strncmp(match, testStr, matchLen) : !strcmp(match, testStr) )
return true;
// Try to match volume UUID.
if ( bvr->fs_getuuid && bvr->fs_getuuid(bvr, testStr) == 0)
{
if( matchLen ? !strncmp(match, testStr, matchLen) : !strcmp(match, testStr) )
return true;
}
// Try to match volume label (always quoted).
if ( bvr->description )
{
bvr->description(bvr, testStr, sizeof(testStr)-1);
if( matchLen ? !strncmp(match, testStr, matchLen) : !strcmp(match, testStr) )
return true;
}
return false;
}
/* If Rename Partition has defined an alias, then extract it for description purpose */
bool getVolumeLabelAlias( BVRef bvr, char* str, long strMaxLen)
/* If Rename Partition has defined an alias, then extract it for description purpose
* The format for the rename string is the following:
* hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" etc; ...
*/
bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen)
{
/* The format for the rename string is the following:
* hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" etc; ...
*/
char *aliasList, *next;
char *aliasList, *entryStart, *entryNext;
if ( !str || strMaxLen <= 0)
return false;
aliasList = XMLDecode(getStringForKey(kRenamePartition, &bootInfo->bootConfig));
if ( !aliasList )
return false;
next = aliasList;
while ( next && *next )
for ( entryStart = entryNext = aliasList;
entryNext && *entryNext;
entryStart = entryNext )
{
char *start, *aliasStart, *aliasEnd;
char *ret;
char *volStart, *volEnd, *aliasStart;
long volLen, aliasLen;
start = aliasStart = (char*)matchVolumeToString(bvr, next, true);
if ( !start || !*start )
break;
/* Find and delimit the current entry's end */
next = strstr(start, ";");
if ( next )
// Delimit current entry
entryNext = strchr(entryStart, ';');
if ( entryNext )
{
/* Not enough characters for a successful match: we'd need at least
* one space and another char. before the semicolon
*/
if ( next-start < 2 ) {
next++;
continue;
}
*next = '\0';
next++;
*entryNext = '\0';
entryNext++;
}
/* Check for at least one space, but ignore the rest of them */
while ( isspace(*aliasStart) )
aliasStart++;
if ( start == aliasStart )
volStart = strbreak(entryStart, &volEnd, &volLen);
if(!volLen)
continue;
switch ( *aliasStart )
{
case '\0':
break;
case '"':
/* If a starting quote is found, skip it, then find the ending one,
* and replace it for a string terminator.
*/
aliasStart++;
aliasEnd = strstr(aliasStart, "\"");
if ( !aliasEnd || aliasStart == aliasEnd )
break;
*aliasEnd = '\0';
default:
ret = strncpy(str, aliasStart, strMaxLen);
free(aliasList);
return ret != 0;
aliasStart = strbreak(volEnd, 0, &aliasLen);
if(!aliasLen)
continue;
if ( matchVolumeToString(bvr, volStart, volLen) )
{
strncpy(str, aliasStart, min(strMaxLen, aliasLen));
free(aliasList);
return true;
}
}
free(aliasList);
return false;
}
/* See if a partition rename is preferred */
if(getVolumeLabelAlias(bvr, p, strMaxLen)) {
verbose("Renamed: %s\n", p);
strncpy(bvr->label, p, sizeof(bvr->label) - 1);
strncpy(bvr->label, p, strMaxLen);
return; // we're done here no need to seek for real name
}
}
// Set the devices label
strncpy(bvr->label, p, sizeof(bvr->label)-1);
sprintf(bvr->label, p);
}
//==========================================================================
trunk/i386/libsaio/disk.h
99
1010
1111
12
12
1313
1414
#ifndef __LIBSAIO_DISK_H
#define __LIBSAIO_DISK_H
char* matchVolumeToString( BVRef bvr, const char* match, bool matchPartial);
bool matchVolumeToString( BVRef bvr, const char* match, long strMaxLen);
#endif /* __LIBSAIO_DISK_H */
trunk/i386/boot2/options.c
111111
112112
113113
114
114
115115
116116
117117
......
781781
782782
783783
784
784
785785
786786
787787
......
858858
859859
860860
861
861
862862
863863
864864
position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) );
char dummy[80];
getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );
getBootVolumeDescription( gBootVolume, dummy, 80, true );
drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, true );
drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos );
strlcpy(prompt, val, cnt);
} else {
name = malloc(80);
getBootVolumeDescription(gBootVolume, name, sizeof(name) - 1, false);
getBootVolumeDescription(gBootVolume, name, 80, false);
prompt = malloc(256);
sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
free(name);
// Associate a menu item for each BVRef.
for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) {
if (bvr->visible) {
getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[0].name) - 1, true);
getBootVolumeDescription(bvr, menuItems[i].name, 80, true);
menuItems[i].param = (void *) bvr;
if (bvr == menuBVR) {
selectIndex = i;
trunk/i386/libsa/libsa.h
107107
108108
109109
110
111
112
110113
111114
112115
extern int strncasecmp(const char * s1, const char * s2, size_t n);
#endif
extern char * strchr(const char *str, int c);
extern char * strbreak(const char *str, char **next, long *len);
extern uint8_t checksum8( void * start, unsigned int length );
/*
trunk/i386/libsa/string.c
257257
258258
259259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
260309
261310
262311
}
#endif
char* strchr(const char *str, int c)
{
do
{
if(*str == c)
return (char*)str;
}
while(*(str++));
return 0;
}
char* strbreak(const char *str, char **next, long *len)
{
char *start = (char*)str, *end;
bool quoted = false;
if ( !start || !len )
return 0;
*len = 0;
while ( isspace(*start) )
start++;
if (*start == '"')
{
start++;
end = strchr(start, '"');
if(end)
quoted = true;
else
end = strchr(start, '\0');
}
else
{
for ( end = start; *end && !isspace(*end); end++ )
{}
}
*len = end - start;
if(next)
*next = quoted ? end+1 : end;
return start;
}
/* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */
uint8_t checksum8( void * start, unsigned int length )
{

Archive Download the corresponding diff file

Revision: 432