--- BasiliskII/src/extfs.cpp 2000/07/21 18:01:05 1.20 +++ BasiliskII/src/extfs.cpp 2001/07/11 19:26:13 1.27 @@ -1,7 +1,7 @@ /* * extfs.cpp - MacOS file system for native file system access * - * Basilisk II (C) 1997-2000 Christian Bauer + * Basilisk II (C) 1997-2001 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +49,6 @@ #endif #include "cpu_emulation.h" -#include "macos_util.h" #include "emul_op.h" #include "main.h" #include "disk.h" @@ -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; @@ -746,9 +730,6 @@ static int16 get_current_dir(uint32 pb, if (no_vol_name) WriteMacInt32(pb + ioNamePtr, name_ptr); int16 status = ReadMacInt16(fs_data + fsReturn); - int16 more_matches = ReadMacInt16(fs_data + fsReturn + 2); - int16 vRefNum = ReadMacInt16(fs_data + fsReturn + 4); - uint32 vcb = ReadMacInt32(fs_data + fsReturn + 6); D(bug(" UTDetermineVol() returned %d, status %d\n", r.d[0], status)); result = (int16)(r.d[0] & 0xffff); @@ -966,7 +947,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; @@ -983,7 +964,9 @@ static int16 fs_volume_mount(uint32 pb) r.a[0] = fs_data + fsReturn; r.a[1] = fs_data + fsReturn + 2; Execute68k(fs_data + fsAllocateVCB, &r); +#if DEBUG uint16 sysVCBLength = ReadMacInt16(fs_data + fsReturn); +#endif uint32 vcb = ReadMacInt32(fs_data + fsReturn + 2); D(bug(" UTAllocateVCB() returned %d, vcb %08lx, size %d\n", r.d[0], vcb, sysVCBLength)); if (r.d[0] & 0xffff) @@ -992,11 +975,11 @@ static int16 fs_volume_mount(uint32 pb) // Init VCB WriteMacInt16(vcb + vcbSigWord, 0x4244); #if defined(__BEOS__) || defined(WIN32) - WriteMacInt32(vcb + vcbCrDate, root_stat.st_crtime + TIME_OFFSET); + WriteMacInt32(vcb + vcbCrDate, TimeToMacTime(root_stat.st_crtime)); #else WriteMacInt32(vcb + vcbCrDate, 0); #endif - WriteMacInt32(vcb + vcbLsMod, root_stat.st_mtime + TIME_OFFSET); + WriteMacInt32(vcb + vcbLsMod, TimeToMacTime(root_stat.st_mtime)); WriteMacInt32(vcb + vcbVolBkUp, 0); WriteMacInt16(vcb + vcbNmFls, 1); //!! WriteMacInt16(vcb + vcbNmRtDirs, 1); //!! @@ -1055,11 +1038,11 @@ static int16 fs_get_vol_info(uint32 pb, if (ReadMacInt32(pb + ioNamePtr)) pstrcpy((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), VOLUME_NAME); #if defined(__BEOS__) || defined(WIN32) - WriteMacInt32(pb + ioVCrDate, root_stat.st_crtime + TIME_OFFSET); + WriteMacInt32(pb + ioVCrDate, TimeToMacTime(root_stat.st_crtime)); #else WriteMacInt32(pb + ioVCrDate, 0); #endif - WriteMacInt32(pb + ioVLsMod, root_stat.st_mtime + TIME_OFFSET); + WriteMacInt32(pb + ioVLsMod, TimeToMacTime(root_stat.st_mtime)); WriteMacInt16(pb + ioVAtrb, 0); WriteMacInt16(pb + ioVNmFls, 1); //!! WriteMacInt16(pb + ioVBitMap, 0); @@ -1247,13 +1230,13 @@ read_next_de: WriteMacInt32(pb + ioDirID, fs_item->id); #if defined(__BEOS__) || defined(WIN32) - WriteMacInt32(pb + ioFlCrDat, st.st_crtime + TIME_OFFSET); + WriteMacInt32(pb + ioFlCrDat, TimeToMacTime(st.st_crtime)); #else WriteMacInt32(pb + ioFlCrDat, 0); #endif - WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET); + WriteMacInt32(pb + ioFlMdDat, TimeToMacTime(st.st_mtime)); - get_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0); + get_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0, false); WriteMacInt16(pb + ioFlStBlk, 0); WriteMacInt32(pb + ioFlLgLen, st.st_size); @@ -1290,7 +1273,7 @@ static int16 fs_set_file_info(uint32 pb, return fnfErr; // Set Finder info - set_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0); + set_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0, false); //!! times return noErr; @@ -1369,7 +1352,7 @@ read_next_de: WriteMacInt32(pb + ioDirID, fs_item->id); WriteMacInt32(pb + ioFlParID, fs_item->parent_id); #if defined(__BEOS__) || defined(WIN32) - WriteMacInt32(pb + ioFlCrDat, st.st_crtime + TIME_OFFSET); + WriteMacInt32(pb + ioFlCrDat, TimeToMacTime(st.st_crtime)); #else WriteMacInt32(pb + ioFlCrDat, 0); #endif @@ -1379,10 +1362,10 @@ read_next_de: fs_item->mtime = mtime; cached = false; } - WriteMacInt32(pb + ioFlMdDat, mtime + TIME_OFFSET); + WriteMacInt32(pb + ioFlMdDat, TimeToMacTime(mtime)); WriteMacInt32(pb + ioFlBkDat, 0); - get_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo); + get_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo, S_ISDIR(st.st_mode)); if (S_ISDIR(st.st_mode)) { @@ -1438,7 +1421,7 @@ static int16 fs_set_cat_info(uint32 pb) return errno2oserr(); // Set Finder info - set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo); + set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo, S_ISDIR(st.st_mode)); //!! times return noErr; @@ -1526,7 +1509,7 @@ static int16 fs_open(uint32 pb, uint32 d WriteMacInt32(fcb + fcbVPtr, vcb); WriteMacInt32(fcb + fcbClmpSize, CLUMP_SIZE); - get_finfo(full_path, fs_data + fsPB, 0); + get_finfo(full_path, fs_data + fsPB, 0, false); WriteMacInt32(fcb + fcbFType, ReadMacInt32(fs_data + fsPB + fdType)); WriteMacInt32(fcb + fcbCatPos, fd); @@ -1584,7 +1567,7 @@ static int16 fs_get_fcb_info(uint32 pb, // Find FCB by index WriteMacInt16(pb + ioRefNum, 0); - for (int i=0; i