--- BasiliskII/src/extfs.cpp 1999/10/20 17:23:53 1.4 +++ BasiliskII/src/extfs.cpp 1999/10/27 16:59:35 1.7 @@ -72,7 +72,7 @@ enum { 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,27 +201,23 @@ 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_component(const char *s) +static void add_path_comp(const char *s) { - int l = strlen(full_path); - if (l < MAX_PATH_LENGTH-1 && full_path[l-1] != '/') { - full_path[l] = '/'; - full_path[l+1] = 0; - } - strncat(full_path, s, MAX_PATH_LENGTH-1); + add_path_component(full_path, s); } static void get_path_for_fsitem(FSItem *p) { - if (p->id == ROOT_ID) { + if (p->id == ROOT_PARENT_ID) { + full_path[0] = 0; + } else if (p->id == ROOT_ID) { strncpy(full_path, RootPath, MAX_PATH_LENGTH-1); full_path[MAX_PATH_LENGTH-1] = 0; } else { get_path_for_fsitem(p->parent); - add_path_component(p->name); + add_path_comp(p->name); } } @@ -440,7 +436,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7006); p+= 2; // UTAllocateVCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsAddNewVCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -450,7 +446,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7007); p+= 2; // UTAddNewVCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsDetermineVol) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -462,18 +458,18 @@ void InstallExtFS(void) WriteMacInt16(p, 0x701d); p+= 2; // UTDetermineVol WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; 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 WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsGetDefaultVol) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -481,7 +477,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7012); p+= 2; // UTGetDefaultVol WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsGetPathComponentName) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -489,7 +485,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x701c); p+= 2; // UTGetPathComponentName WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsParsePathname) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -498,7 +494,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x701b); p+= 2; // UTParsePathname WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsDisposeVCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -506,7 +502,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7008); p+= 2; // UTDisposeVCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsCheckWDRefNum) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -514,7 +510,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7013); p+= 2; // UTCheckWDRefNum WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsSetDefaultVol) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -524,7 +520,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7011); p+= 2; // UTSetDefaultVol WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsAllocateFCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -533,7 +529,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7000); p+= 2; // UTAllocateFCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsReleaseFCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -541,7 +537,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7001); p+= 2; // UTReleaseFCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsIndexFCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -551,7 +547,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7004); p+= 2; // UTIndexFCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsResolveFCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -560,7 +556,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7005); p+= 2; // UTResolveFCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsAdjustEOF) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -568,7 +564,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x7010); p+= 2; // UTAdjustEOF WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsAllocateWDCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -576,7 +572,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x700c); p+= 2; // UTAllocateWDCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != fsReleaseWDCB) goto fsdat_error; WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) @@ -584,7 +580,7 @@ void InstallExtFS(void) WriteMacInt16(p, 0x700d); p+= 2; // UTReleaseWDCB WriteMacInt16(p, 0xa824); p+= 2; // FSMgr WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 - WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; + WriteMacInt16(p, M68K_RTS); p+= 2; if (p - fs_data != SIZEOF_fsdat) goto fsdat_error; @@ -736,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); @@ -1156,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 @@ -1192,7 +1190,7 @@ read_next_de: goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) //!! suppress directories } - add_path_component(de->d_name); + add_path_comp(de->d_name); // Get FSItem for queried item fs_item = find_fsitem(de->d_name, p); @@ -1277,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 @@ -1320,7 +1318,7 @@ read_next_de: if (de->d_name[0] == '.') goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) } - add_path_component(de->d_name); + add_path_comp(de->d_name); // Get FSItem for queried item fs_item = find_fsitem(de->d_name, p); @@ -1978,7 +1976,7 @@ static int16 fs_cat_move(uint32 pb) return result; // Append old file/dir name - add_path_component(fs_item->name); + add_path_comp(fs_item->name); // Does the new name already exist? if (access(full_path, F_OK) == 0) @@ -2010,7 +2008,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]; }