Chameleon

Chameleon Commit Details

Date:2010-08-02 19:03:35 (13 years 8 months ago)
Author:Daniel Miranda
Commit:300
Parents: 299
Message:Merged changes from trunk up to r299
Changes:
M/branches/danielkza/i386/boot2/options.c
M/branches/danielkza/i386/libsaio/ntfs.h
M/branches/danielkza/i386/libsaio/cache.c
M/branches/danielkza
M/branches/danielkza/i386/libsaio/memvendors.h
M/branches/danielkza/i386/libsaio/saio_types.h
M/branches/danielkza/i386/libsaio/msdos.c
M/branches/danielkza/i386/libsa/libsa.h
M/branches/danielkza/i386/libsaio/ntfs_private.h
M/branches/danielkza/i386/libsaio/disk.c
M/branches/danielkza/i386/libsaio/ntfs.c

File differences

branches/danielkza/i386/libsaio/ntfs_private.h
276276
277277
278278
279
279
280280
281281
282282
u_int8_t bf_mftrecsz;/* MFT record size (clust) */
/* 0xF6 inducates 1/4 */
u_int32_t bf_ibsz;/* index buffer size */
u_int32_t bf_volsn;/* volume ser. num. */
u_int64_t bf_volsn;/* volume ser. num. */
};
/*
branches/danielkza/i386/libsaio/memvendors.h
410410
411411
412412
413
413
414414
415415
416416
{ 3, 0x10, "Agere Systems"},
{ 3, 0x91, "NeoMagic"},
{ 3, 0x92, "AuroraNetics"},
{ 3, 0x13, "Golden Empire"},
{ 3, 0x13, "Geil"},
{ 3, 0x94, "Mushkin"},
{ 3, 0x15, "Tioga Technologies"},
{ 3, 0x16, "Netlist"},
branches/danielkza/i386/libsaio/ntfs.c
295295
296296
297297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
298326
299327
300328
return;
}
long NTFSGetUUID(CICell ih, char *uuidStr)
{
bool NTFSProbe(const void*);
struct bootfile *boot;
void *buf = malloc(MAX_CLUSTER_SIZE);
if (!buf)
return -1;
/*
* Read the boot sector, check signatures, and do some minimal
* sanity checking. NOTE: the size of the read below is intended
* to be a multiple of all supported block sizes, so we don't
* have to determine or change the device's block size.
*/
Seek(ih, 0);
Read(ih, (long)buf, MAX_BLOCK_SIZE);
if(!NTFSProbe(buf))
return -1;
boot = (struct bootfile *) buf;
if(!boot->bf_volsn)
return -1;
return CreateUUIDString((uint8_t*)(&boot->bf_volsn), sizeof(boot->bf_volsn), uuidStr);
}
bool NTFSProbe(const void * buffer)
{
bool result = false;
branches/danielkza/i386/libsaio/ntfs.h
2222
2323
2424
25
25
extern void NTFSGetDescription(CICell ih, char *str, long strMaxLen);
extern bool NTFSProbe (const void *buf);
extern long NTFSGetUUID(CICell ih, char *uuidStr);
branches/danielkza/i386/libsaio/disk.c
874874
875875
876876
877
877
878
878879
879880
880881
......
16881689
16891690
16901691
1692
1693
16911694
16921695
1693
1696
16941697
1695
1696
1697
1698
1699
1700
1698
1699
1700
17011701
1702
1703
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
17041726
1705
1706
1727
1728
17071729
17081730
1709
1710
1711
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
17121747
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1748
1749
1750
1751
1752
17251753
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
17421754
1743
1744
1755
17451756
17461757
17471758
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
NTFSGetUUID,
NTFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
char* matchVolumeToString( BVRef bvr, const char* match, bool matchParcial)
{
char testStr[64];
char *ret = 0;
int len = 0;
if ( !bvr || !match || !*match)
return false;
return 0;
if ( bvr->biosdev >= 0x80 && bvr->biosdev < 0x100
&& ( bvr->flags & ( kBVFlagSystemVolume|kBVFlagForeignBoot ) ) )
{
// Trying to match hd(x,y) format.
int len;
char *ret = 0;
if ( bvr->biosdev < 0x80 || bvr->biosdev >= 0x100
|| !(bvr->flags & (kBVFlagSystemVolume|kBVFlagForeignBoot)) )
return 0;
len = sprintf(testStr, "hd(%d,%d)", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (matchParcial)
// Try to match hd(x,y) first.
len = snprintf(testStr, sizeof(testStr)-1, "hd(%d,%d)", BIOS_DEV_UNIT(bvr), bvr->part_no);
if ( matchParcial )
ret = strstr(match, testStr);
else if ( !strcmp(match, testStr) )
ret = (char*) match;
if(ret)
return ret+len;
// Try to match volume UUID.
if ( bvr->fs_getuuid && bvr->fs_getuuid(bvr, testStr) == 0 )
{
{
char* temp = malloc(64);
if(temp && bvr->description) {
bvr->description(bvr, temp, 63);
printf("Volume: UUID=%s, Label=%s\n", testStr, temp);
pause();
}
}
len = strlen(testStr);
if ( matchParcial )
ret = strstr(match, testStr);
else if (!strcmp(match, testStr))
ret = (char*)match;
else if ( !strcmp(match, testStr) )
ret = (char*) match;
if(ret)
return ret+len;
// Trying to match volume UUID.
if (bvr->fs_getuuid && bvr->fs_getuuid(bvr, testStr) == 0)
}
// Try to match volume label (always quoted).
if ( bvr->description )
{
char *temp = 0;
bvr->description(bvr, testStr, sizeof(testStr)-1);
len = strlen(testStr);
if ( !len )
return 0;
len += 2; /* quoted */
temp = malloc(len+1);
if(temp)
{
if (matchParcial)
ret = strstr(match, testStr);
else if (!strcmp(match, testStr))
ret = (char*)match;
if (ret)
return ret+strlen(testStr);
}
// Trying to match volume label (always quoted).
if (bvr->description)
{
char *ret = 0, *temp = 0;
len = snprintf(temp, len, "\"%s\"", testStr);
if ( matchParcial )
ret = strstr(match, temp);
else if ( !strcmp(match, temp) )
ret = (char*) match;
bvr->description(bvr, testStr, sizeof(testStr)-1);
if ( !(len = strlen(testStr)) )
return 0;
len+=2; /* quoted */
temp = malloc(len+1);
if(!temp)
return 0;
sprintf(temp, "\"%s\"", testStr);
if(matchParcial)
ret = strstr(match, temp);
else if(!strcmp(match, temp))
ret = (char*)match;
free(temp);
if(ret)
if (ret)
return ret+len;
}
}
branches/danielkza/i386/libsaio/cache.c
3939
4040
4141
42
42
4343
4444
4545
......
7474
7575
7676
77
77
7878
7979
8080
#define kCacheSize (0x100000)
#define kCacheMinBlockSize (0x200)
#define kCacheMaxBlockSize (0x4000)
#define kCacheMaxBlockSize (0x8000)
#define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize)
static CICell gCacheIH;
#endif
if ((blockSize < kCacheMinBlockSize) ||
(blockSize >= kCacheMaxBlockSize))
(blockSize > kCacheMaxBlockSize))
return;
gCacheBlockSize = blockSize;
branches/danielkza/i386/libsaio/saio_types.h
135135
136136
137137
138
138
139139
140140
141141
typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex,
char ** name, long * flags, long * time,
FinderInfo * finderInfo, long * infoValid);
typedef long (* FSGetUUID)(CICell ih, char *uuidStr);
typedef long (*FSGetUUID)(CICell ih, char *uuidStr);
typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen);
// Can be just pointed to free or a special free function
typedef void (*BVFree)(CICell ih);
branches/danielkza/i386/libsaio/msdos.c
5555
5656
5757
58
5859
5960
6061
......
7475
7576
7677
78
7779
7880
7981
......
151153
152154
153155
154
156
155157
156158
157159
......
220222
221223
222224
223
224225
225
226
227
228
226229
227230
228231
229232
230233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
231249
232250
233251
......
263281
264282
265283
266
267
284
268285
269
286
270287
271
288
289
272290
273
291
274292
275293
276
277
294
278295
279296
280297
#define LABEL_LENGTH11
#define MAX_DOS_BLOCKSIZE2048
#define MAX_CACHE_BLOCKSIZE 32768
#defineCLUST_FIRST2/* reserved cluster range */
#defineCLUST_RSRVD320x0ffffff8/* reserved cluster range */
static CICell msdoscurrent = 0;
static int msdosrootcluster = 0;
static int msdosfatbits = 0;
static int msdosCacheBlockSize = 0;
#if UNUSED
/*
if (msdoscurrent == ih)
{
CacheInit(ih, msdosclustersize);
CacheInit(ih, msdosCacheBlockSize);
return 0;
}
}
msdosclustersize = msdosbps * spc;
msdoscurrent = ih;
CacheInit(ih, msdosclustersize);
msdosCacheBlockSize = (msdosclustersize > MAX_CACHE_BLOCKSIZE) ? msdosclustersize : MAX_CACHE_BLOCKSIZE;
CacheInit(ih, msdosCacheBlockSize);
free (buf);
return 0;
}
static int
readSectorAligned(CICell ih, off_t readOffset, char *buf, int size)
{
long long sectorOffset = (uint64_t)readOffset / msdosCacheBlockSize * msdosCacheBlockSize;
long relOffset = readOffset % msdosCacheBlockSize;
char *cacheBuffer;
cacheBuffer = malloc(msdosCacheBlockSize);
CacheRead(ih, cacheBuffer, sectorOffset, msdosCacheBlockSize, true);
bcopy(cacheBuffer + relOffset, buf, size);
free(cacheBuffer);
return 0;
}
static int
msdosreadcluster (CICell ih, uint8_t *buf, int size, off_t *cluster)
{
off_t readOffset;
/* Read in "cluster" */
if (buf)
{
Seek(ih, readOffset);
Read(ih, (long)buf, size);
readSectorAligned(ih, readOffset, (char *)buf, size);
}
/* Find first sector of FAT */
readOffset = msdosressector*msdosbps;
readOffset = msdosressector * msdosbps;
/* Find sector containing "cluster" entry in FAT */
readOffset += ((uint64_t)*cluster * (uint64_t)msdosfatbits)/8;
readOffset += ((uint64_t)*cluster * (uint64_t)msdosfatbits) / 8;
/* Read one sector of the FAT */
Seek(ih, readOffset);
Read(ih, (long)tmpbuf, 4);
readSectorAligned(ih, readOffset, tmpbuf, 4);
switch (msdosfatbits) {
case 32:
branches/danielkza/i386/boot2/options.c
777777
778778
779779
780
780
781781
782782
783783
strlcpy(prompt, val, cnt);
} else {
name = malloc(80);
getBootVolumeDescription(gBootVolume, name, sizeof(name)-1, false);
getBootVolumeDescription(gBootVolume, name, 79, false);
prompt = malloc(256);
sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
free(name);
branches/danielkza/i386/libsa/libsa.h
132132
133133
134134
135
135136
136137
137138
* printf.c
*/
extern int sprintf(char *s, const char * format, ...);
extern int snprintf(char *s, long len, const char* fmt, ...);
extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
/*

Archive Download the corresponding diff file

Revision: 300