Index: branches/danielkza/i386/libsaio/ntfs_private.h =================================================================== --- branches/danielkza/i386/libsaio/ntfs_private.h (revision 299) +++ branches/danielkza/i386/libsaio/ntfs_private.h (revision 300) @@ -276,7 +276,7 @@ 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. */ }; /* Index: branches/danielkza/i386/libsaio/memvendors.h =================================================================== --- branches/danielkza/i386/libsaio/memvendors.h (revision 299) +++ branches/danielkza/i386/libsaio/memvendors.h (revision 300) @@ -410,7 +410,7 @@ { 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"}, Index: branches/danielkza/i386/libsaio/ntfs.c =================================================================== --- branches/danielkza/i386/libsaio/ntfs.c (revision 299) +++ branches/danielkza/i386/libsaio/ntfs.c (revision 300) @@ -295,6 +295,34 @@ 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; Index: branches/danielkza/i386/libsaio/ntfs.h =================================================================== --- branches/danielkza/i386/libsaio/ntfs.h (revision 299) +++ branches/danielkza/i386/libsaio/ntfs.h (revision 300) @@ -22,4 +22,4 @@ extern void NTFSGetDescription(CICell ih, char *str, long strMaxLen); extern bool NTFSProbe (const void *buf); - +extern long NTFSGetUUID(CICell ih, char *uuidStr); Index: branches/danielkza/i386/libsaio/disk.c =================================================================== --- branches/danielkza/i386/libsaio/disk.c (revision 299) +++ branches/danielkza/i386/libsaio/disk.c (revision 300) @@ -874,7 +874,8 @@ biosdev, partno, part->relsect, part, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + NTFSGetUUID, NTFSGetDescription, (BVFree)free, 0, kBIOSDevTypeHardDrive, 0); @@ -1688,60 +1689,70 @@ 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; } } Index: branches/danielkza/i386/libsaio/cache.c =================================================================== --- branches/danielkza/i386/libsaio/cache.c (revision 299) +++ branches/danielkza/i386/libsaio/cache.c (revision 300) @@ -39,7 +39,7 @@ #define kCacheSize (0x100000) #define kCacheMinBlockSize (0x200) -#define kCacheMaxBlockSize (0x4000) +#define kCacheMaxBlockSize (0x8000) #define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize) static CICell gCacheIH; @@ -74,7 +74,7 @@ #endif if ((blockSize < kCacheMinBlockSize) || - (blockSize >= kCacheMaxBlockSize)) + (blockSize > kCacheMaxBlockSize)) return; gCacheBlockSize = blockSize; Index: branches/danielkza/i386/libsaio/saio_types.h =================================================================== --- branches/danielkza/i386/libsaio/saio_types.h (revision 299) +++ branches/danielkza/i386/libsaio/saio_types.h (revision 300) @@ -135,7 +135,7 @@ 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); Index: branches/danielkza/i386/libsaio/msdos.c =================================================================== --- branches/danielkza/i386/libsaio/msdos.c (revision 299) +++ branches/danielkza/i386/libsaio/msdos.c (revision 300) @@ -55,6 +55,7 @@ #define LABEL_LENGTH 11 #define MAX_DOS_BLOCKSIZE 2048 +#define MAX_CACHE_BLOCKSIZE 32768 #define CLUST_FIRST 2/* reserved cluster range */ #define CLUST_RSRVD32 0x0ffffff8 /* reserved cluster range */ @@ -74,6 +75,7 @@ static CICell msdoscurrent = 0; static int msdosrootcluster = 0; static int msdosfatbits = 0; +static int msdosCacheBlockSize = 0; #if UNUSED /* @@ -151,7 +153,7 @@ if (msdoscurrent == ih) { - CacheInit(ih, msdosclustersize); + CacheInit(ih, msdosCacheBlockSize); return 0; } @@ -220,14 +222,30 @@ } 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; @@ -263,18 +281,17 @@ /* 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: Index: branches/danielkza/i386/boot2/options.c =================================================================== --- branches/danielkza/i386/boot2/options.c (revision 299) +++ branches/danielkza/i386/boot2/options.c (revision 300) @@ -777,7 +777,7 @@ 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); Index: branches/danielkza/i386/libsa/libsa.h =================================================================== --- branches/danielkza/i386/libsa/libsa.h (revision 299) +++ branches/danielkza/i386/libsa/libsa.h (revision 300) @@ -132,6 +132,7 @@ * 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); /* Property changes on: branches/danielkza ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r288-299