--- BasiliskII/src/extfs.cpp 2000/07/14 21:42:05 1.19 +++ BasiliskII/src/extfs.cpp 2000/07/25 15:19:39 1.23 @@ -49,7 +49,6 @@ #endif #include "cpu_emulation.h" -#include "macos_util.h" #include "emul_op.h" #include "main.h" #include "disk.h" @@ -72,7 +71,7 @@ enum { fsHFSProcStub = 6, fsDrvStatus = 12, // Drive Status record fsFSD = 42, // File system descriptor - fsPB = 238, // IOParam (for mounting and renaming) + fsPB = 238, // IOParam (for mounting and renaming), also used for temporary storage fsVMI = 288, // VoumeMountInfoHeader (for mounting) fsParseRec = 296, // ParsePathRec struct fsReturn = 306, // Area for return data of 68k routines @@ -108,8 +107,8 @@ static bool ready = false; static struct stat root_stat; // File system ID/media type -const int16 MY_FSID = 'ba'; -const uint32 MY_MEDIA_TYPE = 'basi'; +const int16 MY_FSID = EMULATOR_ID_2; +const uint32 MY_MEDIA_TYPE = EMULATOR_ID_4; // CNID of root and root's parent const uint32 ROOT_ID = 2; @@ -277,21 +276,6 @@ static void cstr2pstr(char *dst, const c } } -// Convert pascal string to C string -static void pstr2cstr(char *dst, const char *src) -{ - int size = *src++; - while (size--) { - char c = *src++; - // Note: we are converting Mac '/' characters to host ':' characters here - // '/' is not a path separator as this function is only used on object names - if (c == '/') - c = ':'; - *dst++ = c; - } - *dst = 0; -} - // Convert string (no length byte) to C string, length given separately static void strn2cstr(char *dst, const char *src, int size) { @@ -423,7 +407,7 @@ void InstallExtFS(void) // FSM present? r.d[0] = gestaltFSAttr; Execute68kTrap(0xa1ad, &r); // Gestalt() - D(bug("FSAttr %ld, %08lx\n", r.d[0], r.a[0])); + D(bug("FSAttr %d, %08x\n", r.d[0], r.a[0])); if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) { printf("WARNING: No FSM present, disabling ExtFS\n"); return; @@ -432,7 +416,7 @@ void InstallExtFS(void) // Yes, version >=1.2? r.d[0] = gestaltFSMVersion; Execute68kTrap(0xa1ad, &r); // Gestalt() - D(bug("FSMVersion %ld, %08lx\n", r.d[0], r.a[0])); + D(bug("FSMVersion %d, %08x\n", r.d[0], r.a[0])); if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) { printf("WARNING: FSM <1.2 found, disabling ExtFS\n"); return; @@ -702,7 +686,7 @@ int16 ExtFSComm(uint16 message, uint32 p } case ffsIDDiskMessage: { // Check if volume is handled by our FS - if (ReadMacInt16(paramBlock + ioVRefNum) == drive_number) + if ((int16)ReadMacInt16(paramBlock + ioVRefNum) == drive_number) return noErr; else return extFSErr; @@ -966,7 +950,7 @@ static uint32 find_fcb(int16 refNum) static int16 fs_mount_vol(uint32 pb) { D(bug(" fs_mount_vol(%08lx), vRefNum %d\n", pb, ReadMacInt16(pb + ioVRefNum))); - if (ReadMacInt16(pb + ioVRefNum) == drive_number) + if ((int16)ReadMacInt16(pb + ioVRefNum) == drive_number) return noErr; else return extFSErr; @@ -1253,14 +1237,7 @@ read_next_de: #endif WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET); - Mac_memset(pb + ioFlFndrInfo, 0, SIZEOF_FInfo); - uint32 type, creator; // pb may point to kernel space, but stack is switched - get_finder_type(full_path, type, creator); - WriteMacInt32(pb + ioFlFndrInfo + fdType, type); - WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator); - uint16 fflags; - get_finder_flags(full_path, fflags); - WriteMacInt16(pb + ioFlFndrInfo + fdFlags, fflags); + get_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0); WriteMacInt16(pb + ioFlStBlk, 0); WriteMacInt32(pb + ioFlLgLen, st.st_size); @@ -1272,7 +1249,6 @@ read_next_de: if (hfs) { WriteMacInt32(pb + ioFlBkDat, 0); - Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo); WriteMacInt32(pb + ioFlParID, fs_item->parent_id); WriteMacInt32(pb + ioFlClpSiz, 0); } @@ -1297,9 +1273,9 @@ static int16 fs_set_file_info(uint32 pb, if (S_ISDIR(st.st_mode)) return fnfErr; - // Set attributes - set_finder_type(full_path, ReadMacInt32(pb + ioFlFndrInfo + fdType), ReadMacInt32(pb + ioFlFndrInfo + fdCreator)); - set_finder_flags(full_path, ReadMacInt16(pb + ioFlFndrInfo + fdFlags)); + // Set Finder info + set_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0); + //!! times return noErr; } @@ -1389,12 +1365,10 @@ read_next_de: } WriteMacInt32(pb + ioFlMdDat, mtime + TIME_OFFSET); WriteMacInt32(pb + ioFlBkDat, 0); + + get_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo); + if (S_ISDIR(st.st_mode)) { - Mac_memset(pb + ioDrUsrWds, 0, SIZEOF_DInfo); - Mac_memset(pb + ioDrFndrInfo, 0, SIZEOF_DXInfo); - uint16 fflags; // pb may point to kernel space, but stack is switched - get_finder_flags(full_path, fflags); - WriteMacInt16(pb + ioDrUsrWds + frFlags, fflags); // Determine number of files in directory (cached) int count; @@ -1419,15 +1393,6 @@ read_next_de: } WriteMacInt16(pb + ioDrNmFls, count); } else { - Mac_memset(pb + ioFlFndrInfo, 0, SIZEOF_FInfo); - Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo); - uint32 type, creator; // pb may point to kernel space, but stack is switched - get_finder_type(full_path, type, creator); - WriteMacInt32(pb + ioFlFndrInfo + fdType, type); - WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator); - uint16 fflags; - get_finder_flags(full_path, fflags); - WriteMacInt16(pb + ioFlFndrInfo + fdFlags, fflags); WriteMacInt16(pb + ioFlStBlk, 0); WriteMacInt32(pb + ioFlLgLen, st.st_size); WriteMacInt32(pb + ioFlPyLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1); @@ -1456,13 +1421,9 @@ static int16 fs_set_cat_info(uint32 pb) if (stat(full_path, &st) < 0) return errno2oserr(); - // Set attributes - if (S_ISDIR(st.st_mode)) { - set_finder_flags(full_path, ReadMacInt16(pb + ioDrUsrWds + frFlags)); - } else { - set_finder_type(full_path, ReadMacInt32(pb + ioFlFndrInfo + fdType), ReadMacInt32(pb + ioFlFndrInfo + fdCreator)); - set_finder_flags(full_path, ReadMacInt16(pb + ioFlFndrInfo + fdFlags)); - } + // Set Finder info + set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo); + //!! times return noErr; } @@ -1548,9 +1509,10 @@ static int16 fs_open(uint32 pb, uint32 d WriteMacInt32(fcb + fcbCrPs, 0); WriteMacInt32(fcb + fcbVPtr, vcb); WriteMacInt32(fcb + fcbClmpSize, CLUMP_SIZE); - uint32 type, creator; // BeOS: fcb may point to kernel space, but stack is switched - get_finder_type(full_path, type, creator); - WriteMacInt32(fcb + fcbFType, type); + + get_finfo(full_path, fs_data + fsPB, 0); + WriteMacInt32(fcb + fcbFType, ReadMacInt32(fs_data + fsPB + fdType)); + WriteMacInt32(fcb + fcbCatPos, fd); WriteMacInt32(fcb + fcbDirID, fs_item->parent_id); cstr2pstr((char *)Mac2HostAddr(fcb + fcbCName), fs_item->name); @@ -1606,7 +1568,7 @@ static int16 fs_get_fcb_info(uint32 pb, // Find FCB by index WriteMacInt16(pb + ioRefNum, 0); - for (int i=0; i