--- BasiliskII/src/extfs.cpp 1999/10/22 15:08:10 1.6 +++ BasiliskII/src/extfs.cpp 1999/11/03 19:08:52 1.10 @@ -65,14 +65,14 @@ enum { fsHFSProcStub = 6, fsDrvStatus = 12, // Drive Status record fsFSD = 42, // File system descriptor - fsPB = 238, // IOParam (for mounting) + fsPB = 238, // IOParam (for mounting and renaming) fsVMI = 288, // VoumeMountInfoHeader (for mounting) fsParseRec = 296, // ParsePathRec struct fsReturn = 306, // Area for return data of 68k routines fsAllocateVCB = 562, // UTAllocateVCB(uint16 *sysVCBLength{a0}, uint32 *vcb{a1}) fsAddNewVCB = 578, // UTAddNewVCB(int drive_number{d0}, int16 *vRefNum{a1}, uint32 vcb{a1}) fsDetermineVol = 594, // UTDetermineVol(uint32 pb{a0}, int16 *status{a1}, int16 *more_matches{a2}, int16 *vRefNum{a3}, uint32 *vcb{a4}) - fsResolveWDCB = 614, // UTResolveWDCB(int16 vRefNum{d0}, uint32 *wdcb{a0}) + fsResolveWDCB = 614, // UTResolveWDCB(uint32 procID{d0}, int16 index{d1}, int16 vRefNum{d0}, uint32 *wdcb{a0}) fsGetDefaultVol = 632, // UTGetDefaultVol(uint32 wdpb{a0}) fsGetPathComponentName = 644, // UTGetPathComponentName(uint32 rec{a0}) fsParsePathname = 656, // UTParsePathname(uint32 *start{a0}, uint32 name{a1}) @@ -201,12 +201,11 @@ static FSItem *find_fsitem(const char *n * Get full path (->full_path) for given FSItem */ -const int MAX_PATH_LENGTH = 1024; static char full_path[MAX_PATH_LENGTH]; static void add_path_comp(const char *s) { - add_path_component(full_path, s, MAX_PATH_LENGTH); + add_path_component(full_path, s); } static void get_path_for_fsitem(FSItem *p) @@ -463,9 +462,9 @@ void InstallExtFS(void) if (p - fs_data != fsResolveWDCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) - WriteMacInt16(p, 0x42a7); p+= 2; // clr.l -(sp) - WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) - WriteMacInt16(p, 0x3f00); p+= 2; // move.w d0,-(sp) + WriteMacInt16(p, 0x2f00); p+= 2; // move.l d0,-(sp) + WriteMacInt16(p, 0x3f01); p+= 2; // move.w d1,-(sp) + WriteMacInt16(p, 0x3f02); p+= 2; // move.w d2,-(sp) WriteMacInt16(p, 0x2f08); p+= 2; // move.l a0,-(sp) WriteMacInt16(p, 0x700e); p+= 2; // UTResolveWDCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr @@ -605,7 +604,7 @@ void InstallExtFS(void) WriteMacInt16(fs_data + fsFSD + fsdLength, SIZEOF_FSDRec); WriteMacInt16(fs_data + fsFSD + fsdVersion, fsdVersion1); WriteMacInt16(fs_data + fsFSD + fileSystemFSID, MY_FSID); - memcpy(Mac2HostAddr(fs_data + fsFSD + fileSystemName), FS_NAME, 32); + Host2Mac_memcpy(fs_data + fsFSD + fileSystemName, FS_NAME, 32); WriteMacInt32(fs_data + fsFSD + fileSystemCommProc, fs_data + fsCommProcStub); WriteMacInt32(fs_data + fsFSD + fsdHFSCI + compInterfProc, fs_data + fsHFSProcStub); WriteMacInt32(fs_data + fsFSD + fsdHFSCI + stackTop, fs_stack + STACK_SIZE); @@ -659,7 +658,7 @@ int16 ExtFSComm(uint16 message, uint32 p case ffsGetIconMessage: { // Get disk/drive icon if (ReadMacInt8(paramBlock + iconType) == kLargeIcon && ReadMacInt32(paramBlock + requestSize) >= sizeof(ExtFSIcon)) { - memcpy(Mac2HostAddr(ReadMacInt32(paramBlock + iconBufferPtr)), ExtFSIcon, sizeof(ExtFSIcon)); + Host2Mac_memcpy(ReadMacInt32(paramBlock + iconBufferPtr), ExtFSIcon, sizeof(ExtFSIcon)); WriteMacInt32(paramBlock + actualSize, sizeof(ExtFSIcon)); return noErr; } else @@ -733,7 +732,9 @@ static int16 get_current_dir(uint32 pb, current_dir = dirID; else { D(bug(" resolving WDCB\n")); - r.d[0] = ReadMacInt16(pb + ioVRefNum); + r.d[0] = 0; + r.d[1] = 0; + r.d[2] = ReadMacInt16(pb + ioVRefNum); r.a[0] = fs_data + fsReturn; Execute68k(fs_data + fsResolveWDCB, &r); uint32 wdcb = ReadMacInt32(fs_data + fsReturn); @@ -968,7 +969,7 @@ static int16 fs_volume_mount(uint32 pb) WriteMacInt32(vcb + vcbClpSiz, 1024); WriteMacInt32(vcb + vcbNxtCNID, next_cnid); WriteMacInt16(vcb + vcbFreeBks, 0xffff); //!! - memcpy(Mac2HostAddr(vcb + vcbVN), VOLUME_NAME, 28); + Host2Mac_memcpy(vcb + vcbVN, VOLUME_NAME, 28); WriteMacInt16(vcb + vcbFSID, MY_FSID); WriteMacInt32(vcb + vcbFilCnt, 1); //!! WriteMacInt32(vcb + vcbDirCnt, 1); //!! @@ -1042,7 +1043,7 @@ static int16 fs_get_vol_info(uint32 pb, WriteMacInt32(pb + ioVWrCnt, 0); WriteMacInt32(pb + ioVFilCnt, 1); //!! WriteMacInt32(pb + ioVDirCnt, 1); //!! - memset(Mac2HostAddr(pb + ioVFndrInfo), 0, 32); + Mac_memset(pb + ioVFndrInfo, 0, 32); } return noErr; } @@ -1072,7 +1073,7 @@ static int16 fs_get_vol_parms(uint32 pb) uint32 actual = ReadMacInt32(pb + ioReqCount); if (actual > sizeof(vol)) actual = sizeof(vol); - memcpy(Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), vol, actual); + Host2Mac_memcpy(ReadMacInt32(pb + ioBuffer), vol, actual); WriteMacInt32(pb + ioActCount, actual); return noErr; } @@ -1153,7 +1154,7 @@ static int16 fs_get_file_info(uint32 pb, D(bug(" fs_get_file_info(%08lx), vRefNum %d, name %.31s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt16(pb + ioFDirIndex), dirID)); FSItem *fs_item; - int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex); + int16 dir_index = ReadMacInt16(pb + ioFDirIndex); if (dir_index <= 0) { // Query item specified by ioDirID and ioNamePtr // Find FSItem for given file @@ -1217,7 +1218,7 @@ read_next_de: #endif WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET); - memset(Mac2HostAddr(pb + ioFlFndrInfo), 0, SIZEOF_FInfo); + 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); @@ -1236,7 +1237,7 @@ read_next_de: if (hfs) { WriteMacInt32(pb + ioFlBkDat, 0); - memset(Mac2HostAddr(pb + ioFlXFndrInfo), 0, SIZEOF_FXInfo); + Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo); WriteMacInt32(pb + ioFlParID, fs_item->parent_id); WriteMacInt32(pb + ioFlClpSiz, 0); } @@ -1274,7 +1275,7 @@ static int16 fs_get_cat_info(uint32 pb) D(bug(" fs_get_cat_info(%08lx), vRefNum %d, name %.31s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt16(pb + ioFDirIndex), ReadMacInt32(pb + ioDirID))); FSItem *fs_item; - int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex); + int16 dir_index = ReadMacInt16(pb + ioFDirIndex); if (dir_index < 0) { // Query directory specified by ioDirID // Find FSItem for directory @@ -1354,8 +1355,8 @@ read_next_de: WriteMacInt32(pb + ioFlMdDat, mtime); WriteMacInt32(pb + ioFlBkDat, 0); if (S_ISDIR(st.st_mode)) { - memset(Mac2HostAddr(pb + ioDrUsrWds), 0, SIZEOF_DInfo); - memset(Mac2HostAddr(pb + ioDrFndrInfo), 0, SIZEOF_DXInfo); + 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); @@ -1381,8 +1382,8 @@ read_next_de: } WriteMacInt16(pb + ioDrNmFls, count); } else { - memset(Mac2HostAddr(pb + ioFlFndrInfo), 0, SIZEOF_FInfo); - memset(Mac2HostAddr(pb + ioFlXFndrInfo), 0, SIZEOF_FXInfo); + 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); @@ -1851,7 +1852,7 @@ static int16 fs_create(uint32 pb, uint32 return dupFNErr; // Create file - int fd = creat(full_path, 0664); + int fd = creat(full_path, 0666); if (fd < 0) return errno2oserr(); else { @@ -1876,7 +1877,7 @@ static int16 fs_dir_create(uint32 pb) return dupFNErr; // Create directory - if (mkdir(full_path, 0775) < 0) + if (mkdir(full_path, 0777) < 0) return errno2oserr(); else { WriteMacInt32(pb + ioDirID, fs_item->id); @@ -1925,11 +1926,10 @@ static int16 fs_rename(uint32 pb, uint32 strcpy(old_path, full_path); // Find path for new name - uint8 new_pb[SIZEOF_IOParam]; - memcpy(new_pb, Mac2HostAddr(pb), SIZEOF_IOParam); - WriteMacInt32((uint32)new_pb + ioNamePtr, ReadMacInt32(pb + ioMisc)); + Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam); + WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioMisc)); FSItem *new_item; - result = get_item_and_path((uint32)new_pb, dirID, new_item); + result = get_item_and_path(fs_data + fsPB, dirID, new_item); if (result != noErr) return result; @@ -1966,11 +1966,10 @@ static int16 fs_cat_move(uint32 pb) strcpy(old_path, full_path); // Find path for new directory - uint8 new_pb[SIZEOF_IOParam]; - memcpy(new_pb, Mac2HostAddr(pb), SIZEOF_IOParam); - WriteMacInt32((uint32)new_pb + ioNamePtr, ReadMacInt32(pb + ioNewName)); + Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam); + WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioNewName)); FSItem *new_dir_item; - result = get_item_and_path((uint32)new_pb, ReadMacInt32(pb + ioNewDirID), new_dir_item); + result = get_item_and_path(fs_data + fsPB, ReadMacInt32(pb + ioNewDirID), new_dir_item); if (result != noErr) return result; @@ -2007,7 +2006,7 @@ static int16 fs_open_wd(uint32 pb) D(bug(" allocating WDCB\n")); r.a[0] = pb; Execute68k(fs_data + fsAllocateWDCB, &r); - D(bug(" UTAllocateWDCB returned %d\n", r.d[0])); + D(bug(" UTAllocateWDCB returned %d, refNum is %d\n", r.d[0], ReadMacInt16(pb + ioVRefNum))); return r.d[0]; } @@ -2036,7 +2035,7 @@ static int16 fs_get_wd_info(uint32 pb, u WriteMacInt32(pb + ioWDProcID, 0); WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(vcb + vcbVRefNum)); if (ReadMacInt32(pb + ioNamePtr)) - memcpy(Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), Mac2HostAddr(vcb + vcbVN), 28); + Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), vcb + vcbVN, 28); WriteMacInt32(pb + ioWDDirID, ROOT_ID); return noErr; } @@ -2057,7 +2056,7 @@ static int16 fs_get_wd_info(uint32 pb, u WriteMacInt16(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID)); WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(ReadMacInt32(wdcb + wdVCBPtr) + vcbVRefNum)); if (ReadMacInt32(pb + ioNamePtr)) - memcpy(Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), Mac2HostAddr(ReadMacInt32(wdcb + wdVCBPtr) + vcbVN), 28); + Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), ReadMacInt32(wdcb + wdVCBPtr) + vcbVN, 28); WriteMacInt32(pb + ioWDDirID, ReadMacInt32(wdcb + wdDirID)); return noErr; }