ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/extfs.cpp
(Generate patch)

Comparing BasiliskII/src/extfs.cpp (file contents):
Revision 1.1 by cebix, 1999-10-19T17:41:14Z vs.
Revision 1.6 by cebix, 1999-10-22T15:08:10Z

# Line 19 | Line 19
19   */
20  
21   /*
22 < TODO:
23 < LockRng
24 < UnlockRng
25 < (CatSearch)
26 < (MakeFSSpec)
27 < (GetVolMountInfoSize)
28 < (GetVolMountInfo)
29 < (GetForeignPrivs)
30 < (SetForeignPrivs)
31 < */
22 > *  SEE ALSO
23 > *    Guide to the File System Manager (from FSM 1.2 SDK)
24 > *
25 > *  TODO
26 > *    LockRng
27 > *    UnlockRng
28 > *    (CatSearch)
29 > *    (MakeFSSpec)
30 > *    (GetVolMountInfoSize)
31 > *    (GetVolMountInfo)
32 > *    (GetForeignPrivs)
33 > *    (SetForeignPrivs)
34 > */
35 >
36 > #include "sysdeps.h"
37  
38   #include <sys/types.h>
39   #include <sys/stat.h>
40 + #include <string.h>
41   #include <stdio.h>
42   #include <stdlib.h>
43   #include <unistd.h>
44 + #include <fcntl.h>
45   #include <dirent.h>
46   #include <errno.h>
47  
41 #include "sysdeps.h"
48   #include "cpu_emulation.h"
49   #include "macos_util.h"
50   #include "emul_op.h"
# Line 198 | Line 204 | static FSItem *find_fsitem(const char *n
204   const int MAX_PATH_LENGTH = 1024;
205   static char full_path[MAX_PATH_LENGTH];
206  
207 < static void add_path_component(const char *s)
207 > static void add_path_comp(const char *s)
208   {
209 <        int l = strlen(full_path);
204 <        if (l < MAX_PATH_LENGTH-1 && full_path[l-1] != '/') {
205 <                full_path[l] = '/';
206 <                full_path[l+1] = 0;
207 <        }
208 <        strncat(full_path, s, MAX_PATH_LENGTH-1);
209 >        add_path_component(full_path, s, MAX_PATH_LENGTH);
210   }
211  
212   static void get_path_for_fsitem(FSItem *p)
213   {
214 <        if (p->id == ROOT_ID) {
214 >        if (p->id == ROOT_PARENT_ID) {
215 >                full_path[0] = 0;
216 >        } else if (p->id == ROOT_ID) {
217                  strncpy(full_path, RootPath, MAX_PATH_LENGTH-1);
218                  full_path[MAX_PATH_LENGTH-1] = 0;
219          } else {
220                  get_path_for_fsitem(p->parent);
221 <                add_path_component(p->name);
221 >                add_path_comp(p->name);
222          }
223   }
224  
# Line 319 | Line 322 | void ExtFSInit(void)
322          cstr2pstr(FS_NAME, GetString(STR_EXTFS_NAME));
323          cstr2pstr(VOLUME_NAME, GetString(STR_EXTFS_VOLUME_NAME));
324  
325 <        // Create root FSItem
325 >        // Create root's parent FSItem
326          FSItem *p = new FSItem;
327          first_fs_item = last_fs_item = p;
328          p->next = NULL;
329 +        p->id = ROOT_PARENT_ID;
330 +        p->parent_id = 0;
331 +        p->parent = NULL;
332 +        p->name[0] = 0;
333 +
334 +        // Create root FSItem
335 +        p = new FSItem;
336 +        last_fs_item->next = p;
337 +        p->next = NULL;
338 +        last_fs_item = p;
339          p->id = ROOT_ID;
340          p->parent_id = ROOT_PARENT_ID;
341 <        p->parent = NULL;
341 >        p->parent = first_fs_item;
342          strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32);
343  
344          // Find path for root
# Line 376 | Line 389 | void InstallExtFS(void)
389          r.d[0] = gestaltFSAttr;
390          Execute68kTrap(0xa1ad, &r);     // Gestalt()
391          D(bug("FSAttr %ld, %08lx\n", r.d[0], r.a[0]));
392 <        if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager)))
392 >        if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) {
393 >                printf("WARNING: No FSM present, disabling ExtFS\n");
394                  return;
395 +        }
396  
397          // Yes, version >=1.2?
398          r.d[0] = gestaltFSMVersion;
399          Execute68kTrap(0xa1ad, &r);     // Gestalt()
400          D(bug("FSMVersion %ld, %08lx\n", r.d[0], r.a[0]));
401 <        if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120))
401 >        if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) {
402 >                printf("WARNING: FSM <1.2 found, disabling ExtFS\n");
403                  return;
404 +        }
405  
406          D(bug("FSM present\n"));
407  
# Line 420 | Line 437 | void InstallExtFS(void)
437          WriteMacInt16(p, 0x7006); p+= 2;        // UTAllocateVCB
438          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
439          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
440 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
440 >        WriteMacInt16(p, M68K_RTS); p+= 2;
441          if (p - fs_data != fsAddNewVCB)
442                  goto fsdat_error;
443          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 430 | Line 447 | void InstallExtFS(void)
447          WriteMacInt16(p, 0x7007); p+= 2;        // UTAddNewVCB
448          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
449          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
450 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
450 >        WriteMacInt16(p, M68K_RTS); p+= 2;
451          if (p - fs_data != fsDetermineVol)
452                  goto fsdat_error;
453          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 442 | Line 459 | void InstallExtFS(void)
459          WriteMacInt16(p, 0x701d); p+= 2;        // UTDetermineVol
460          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
461          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
462 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
462 >        WriteMacInt16(p, M68K_RTS); p+= 2;
463          if (p - fs_data != fsResolveWDCB)
464                  goto fsdat_error;
465          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 453 | Line 470 | void InstallExtFS(void)
470          WriteMacInt16(p, 0x700e); p+= 2;        // UTResolveWDCB
471          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
472          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
473 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
473 >        WriteMacInt16(p, M68K_RTS); p+= 2;
474          if (p - fs_data != fsGetDefaultVol)
475                  goto fsdat_error;
476          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 461 | Line 478 | void InstallExtFS(void)
478          WriteMacInt16(p, 0x7012); p+= 2;        // UTGetDefaultVol
479          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
480          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
481 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
481 >        WriteMacInt16(p, M68K_RTS); p+= 2;
482          if (p - fs_data != fsGetPathComponentName)
483                  goto fsdat_error;
484          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 469 | Line 486 | void InstallExtFS(void)
486          WriteMacInt16(p, 0x701c); p+= 2;        // UTGetPathComponentName
487          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
488          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
489 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
489 >        WriteMacInt16(p, M68K_RTS); p+= 2;
490          if (p - fs_data != fsParsePathname)
491                  goto fsdat_error;
492          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 478 | Line 495 | void InstallExtFS(void)
495          WriteMacInt16(p, 0x701b); p+= 2;        // UTParsePathname
496          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
497          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
498 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
498 >        WriteMacInt16(p, M68K_RTS); p+= 2;
499          if (p - fs_data != fsDisposeVCB)
500                  goto fsdat_error;
501          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 486 | Line 503 | void InstallExtFS(void)
503          WriteMacInt16(p, 0x7008); p+= 2;        // UTDisposeVCB
504          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
505          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
506 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
506 >        WriteMacInt16(p, M68K_RTS); p+= 2;
507          if (p - fs_data != fsCheckWDRefNum)
508                  goto fsdat_error;
509          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 494 | Line 511 | void InstallExtFS(void)
511          WriteMacInt16(p, 0x7013); p+= 2;        // UTCheckWDRefNum
512          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
513          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
514 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
514 >        WriteMacInt16(p, M68K_RTS); p+= 2;
515          if (p - fs_data != fsSetDefaultVol)
516                  goto fsdat_error;
517          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 504 | Line 521 | void InstallExtFS(void)
521          WriteMacInt16(p, 0x7011); p+= 2;        // UTSetDefaultVol
522          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
523          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
524 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
524 >        WriteMacInt16(p, M68K_RTS); p+= 2;
525          if (p - fs_data != fsAllocateFCB)
526                  goto fsdat_error;
527          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 513 | Line 530 | void InstallExtFS(void)
530          WriteMacInt16(p, 0x7000); p+= 2;        // UTAllocateFCB
531          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
532          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
533 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
533 >        WriteMacInt16(p, M68K_RTS); p+= 2;
534          if (p - fs_data != fsReleaseFCB)
535                  goto fsdat_error;
536          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 521 | Line 538 | void InstallExtFS(void)
538          WriteMacInt16(p, 0x7001); p+= 2;        // UTReleaseFCB
539          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
540          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
541 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
541 >        WriteMacInt16(p, M68K_RTS); p+= 2;
542          if (p - fs_data != fsIndexFCB)
543                  goto fsdat_error;
544          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 531 | Line 548 | void InstallExtFS(void)
548          WriteMacInt16(p, 0x7004); p+= 2;        // UTIndexFCB
549          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
550          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
551 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
551 >        WriteMacInt16(p, M68K_RTS); p+= 2;
552          if (p - fs_data != fsResolveFCB)
553                  goto fsdat_error;
554          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 540 | Line 557 | void InstallExtFS(void)
557          WriteMacInt16(p, 0x7005); p+= 2;        // UTResolveFCB
558          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
559          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
560 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
560 >        WriteMacInt16(p, M68K_RTS); p+= 2;
561          if (p - fs_data != fsAdjustEOF)
562                  goto fsdat_error;
563          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 548 | Line 565 | void InstallExtFS(void)
565          WriteMacInt16(p, 0x7010); p+= 2;        // UTAdjustEOF
566          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
567          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
568 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
568 >        WriteMacInt16(p, M68K_RTS); p+= 2;
569          if (p - fs_data != fsAllocateWDCB)
570                  goto fsdat_error;
571          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 556 | Line 573 | void InstallExtFS(void)
573          WriteMacInt16(p, 0x700c); p+= 2;        // UTAllocateWDCB
574          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
575          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
576 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
576 >        WriteMacInt16(p, M68K_RTS); p+= 2;
577          if (p - fs_data != fsReleaseWDCB)
578                  goto fsdat_error;
579          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 564 | Line 581 | void InstallExtFS(void)
581          WriteMacInt16(p, 0x700d); p+= 2;        // UTReleaseWDCB
582          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
583          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
584 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
584 >        WriteMacInt16(p, M68K_RTS); p+= 2;
585          if (p - fs_data != SIZEOF_fsdat)
586                  goto fsdat_error;
587  
# Line 679 | Line 696 | static int16 get_current_dir(uint32 pb,
696          int16 result;
697  
698          // Determine volume
699 < //      D(bug("  determining volume\n"));
699 >        D(bug("  determining volume, dirID %d\n", dirID));
700          r.a[0] = pb;
701          r.a[1] = fs_data + fsReturn;
702          r.a[2] = fs_data + fsReturn + 2;
# Line 697 | Line 714 | static int16 get_current_dir(uint32 pb,
714          int16 more_matches = ReadMacInt16(fs_data + fsReturn + 2);
715          int16 vRefNum = ReadMacInt16(fs_data + fsReturn + 4);
716          uint32 vcb = ReadMacInt32(fs_data + fsReturn + 6);
717 < //      D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
717 >        D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
718          result = r.d[0] & 0xffff;
719  
720          if (result == noErr) {
# Line 780 | Line 797 | static int16 get_item_and_path(uint32 pb
797          uint32 current_dir;
798          if ((result = get_current_dir(pb, dirID, current_dir, no_vol_name)) != noErr)
799                  return result;
800 +        D(bug("  current dir %08x\n", current_dir));
801          FSItem *p = find_fsitem_by_id(current_dir);
802          if (p == NULL)
803                  return dirNFErr;
# Line 793 | Line 811 | static int16 get_item_and_path(uint32 pb
811          WriteMacInt8(parseRec + ppFoundDelimiter, false);
812  
813          // Get length of volume name
814 < //      D(bug("  parsing pathname\n"));
814 >        D(bug("  parsing pathname\n"));
815          r.a[0] = parseRec + ppStartOffset;
816          r.a[1] = ReadMacInt32(parseRec + ppNamePtr);
817          Execute68k(fs_data + fsParsePathname, &r);
818 < //      D(bug("  UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset)));
818 >        D(bug("  UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset)));
819          result = r.d[0] & 0xffff;
820          if (result == noErr) {
821  
# Line 1076 | Line 1094 | static int16 fs_get_vol(uint32 pb)
1094   // Set default volume (WDParam)
1095   static int16 fs_set_vol(uint32 pb, bool hfs, uint32 vcb)
1096   {
1097 <        D(bug(" fs_set_vol(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID)));
1097 >        D(bug(" fs_set_vol(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioWDDirID)));
1098          M68kRegisters r;
1099  
1100          // Determine parameters
# Line 1132 | Line 1150 | static int16 fs_set_vol(uint32 pb, bool
1150   // Query file attributes (HFileParam)
1151   static int16 fs_get_file_info(uint32 pb, bool hfs, uint32 dirID)
1152   {
1153 <        D(bug(" fs_get_file_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), dirID));
1153 >        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));
1154  
1155          FSItem *fs_item;
1156 <        int16 dir_index = ReadMacInt16(pb + ioFDirIndex);
1157 <        if (dir_index == 0) {   // Query item specified by ioDirID and ioNamePtr
1156 >        int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex);
1157 >        if (dir_index <= 0) {           // Query item specified by ioDirID and ioNamePtr
1158  
1159                  // Find FSItem for given file
1160                  int16 result = get_item_and_path(pb, dirID, fs_item);
# Line 1171 | Line 1189 | read_next_de:
1189                                  goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1190                          //!! suppress directories
1191                  }
1192 <                add_path_component(de->d_name);
1192 >                add_path_comp(de->d_name);
1193  
1194                  // Get FSItem for queried item
1195                  fs_item = find_fsitem(de->d_name, p);
# Line 1228 | Line 1246 | read_next_de:
1246   // Set file attributes (HFileParam)
1247   static int16 fs_set_file_info(uint32 pb, bool hfs, uint32 dirID)
1248   {
1249 <        D(bug(" fs_set_file_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), dirID));
1249 >        D(bug(" fs_set_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));
1250  
1251          // Find FSItem for given file/dir
1252          FSItem *fs_item;
# Line 1253 | Line 1271 | static int16 fs_set_file_info(uint32 pb,
1271   // Query file/directory attributes
1272   static int16 fs_get_cat_info(uint32 pb)
1273   {
1274 <        D(bug(" fs_get_cat_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), ReadMacInt32(pb + ioDirID)));
1274 >        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)));
1275  
1276          FSItem *fs_item;
1277 <        int16 dir_index = ReadMacInt16(pb + ioFDirIndex);
1278 <        if (dir_index == -1) {          // Query directory specified by ioDirID
1277 >        int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex);
1278 >        if (dir_index < 0) {                    // Query directory specified by ioDirID
1279  
1280                  // Find FSItem for directory
1281                  fs_item = find_fsitem_by_id(ReadMacInt32(pb + ioDrDirID));
# Line 1299 | Line 1317 | read_next_de:
1317                          if (de->d_name[0] == '.')
1318                                  goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1319                  }
1320 <                add_path_component(de->d_name);
1320 >                add_path_comp(de->d_name);
1321  
1322                  // Get FSItem for queried item
1323                  fs_item = find_fsitem(de->d_name, p);
# Line 1387 | Line 1405 | read_next_de:
1405   // Set file/directory attributes
1406   static int16 fs_set_cat_info(uint32 pb)
1407   {
1408 <        D(bug(" fs_set_cat_info(%08lx), vRefNum %d, name %#s, idx %d, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt16(pb + ioFDirIndex), ReadMacInt32(pb + ioDirID)));
1408 >        D(bug(" fs_set_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)));
1409  
1410          // Find FSItem for given file/dir
1411          FSItem *fs_item;
# Line 1414 | Line 1432 | static int16 fs_set_cat_info(uint32 pb)
1432   // Open file
1433   static int16 fs_open(uint32 pb, uint32 dirID, uint32 vcb, bool resource_fork)
1434   {
1435 <        D(bug(" fs_open(%08lx), %s, vRefNum %d, name %#s, dirID %d, perm %d\n", pb, resource_fork ? "rsrc" : "data", ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID, ReadMacInt8(pb + ioPermssn)));
1435 >        D(bug(" fs_open(%08lx), %s, vRefNum %d, name %.31s, dirID %d, perm %d\n", pb, resource_fork ? "rsrc" : "data", ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID, ReadMacInt8(pb + ioPermssn)));
1436          M68kRegisters r;
1437  
1438          // Find FSItem for given file
# Line 1701 | Line 1719 | static int16 fs_set_fpos(uint32 pb)
1719                          if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_SET) < 0)
1720                                  return posErr;
1721                          break;
1722 +                case fsFromLEOF:
1723 +                        if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_END) < 0)
1724 +                                return posErr;
1725 +                        break;
1726                  case fsFromMark:
1727 <                        if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0)
1727 >                        if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0)
1728                                  return posErr;
1729 +                        break;
1730                  default:
1731                          break;
1732          }
# Line 1815 | Line 1838 | static int16 fs_write(uint32 pb)
1838   // Create file
1839   static int16 fs_create(uint32 pb, uint32 dirID)
1840   {
1841 <        D(bug(" fs_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID));
1841 >        D(bug(" fs_create(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID));
1842  
1843          // Find FSItem for given file
1844          FSItem *fs_item;
# Line 1840 | Line 1863 | static int16 fs_create(uint32 pb, uint32
1863   // Create directory
1864   static int16 fs_dir_create(uint32 pb)
1865   {
1866 <        D(bug(" fs_dir_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioDirID)));
1866 >        D(bug(" fs_dir_create(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioDirID)));
1867  
1868          // Find FSItem for given directory
1869          FSItem *fs_item;
# Line 1864 | Line 1887 | static int16 fs_dir_create(uint32 pb)
1887   // Delete file/directory
1888   static int16 fs_delete(uint32 pb, uint32 dirID)
1889   {
1890 <        D(bug(" fs_delete(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID));
1890 >        D(bug(" fs_delete(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID));
1891  
1892          // Find FSItem for given file/dir
1893          FSItem *fs_item;
# Line 1889 | Line 1912 | static int16 fs_delete(uint32 pb, uint32
1912   // Rename file/directory
1913   static int16 fs_rename(uint32 pb, uint32 dirID)
1914   {
1915 <        D(bug(" fs_rename(%08lx), vRefNum %d, name %#s, dirID %d, new name %#s\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID, Mac2HostAddr(ReadMacInt32(pb + ioMisc))));
1915 >        D(bug(" fs_rename(%08lx), vRefNum %d, name %.31s, dirID %d, new name %.31s\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID, Mac2HostAddr(ReadMacInt32(pb + ioMisc) + 1)));
1916  
1917          // Find path of given file/dir
1918          FSItem *fs_item;
# Line 1930 | Line 1953 | static int16 fs_rename(uint32 pb, uint32
1953   // Move file/directory (CMovePBRec)
1954   static int16 fs_cat_move(uint32 pb)
1955   {
1956 <        D(bug(" fs_cat_move(%08lx), vRefNum %d, name %#s, dirID %d, new name %#s, new dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioDirID), Mac2HostAddr(ReadMacInt32(pb + ioNewName)), ReadMacInt32(pb + ioNewDirID)));
1956 >        D(bug(" fs_cat_move(%08lx), vRefNum %d, name %.31s, dirID %d, new name %.31s, new dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioDirID), Mac2HostAddr(ReadMacInt32(pb + ioNewName) + 1), ReadMacInt32(pb + ioNewDirID)));
1957  
1958          // Find path of given file/dir
1959          FSItem *fs_item;
# Line 1952 | Line 1975 | static int16 fs_cat_move(uint32 pb)
1975                  return result;
1976  
1977          // Append old file/dir name
1978 <        add_path_component(fs_item->name);
1978 >        add_path_comp(fs_item->name);
1979  
1980          // Does the new name already exist?
1981          if (access(full_path, F_OK) == 0)
# Line 1977 | Line 2000 | static int16 fs_cat_move(uint32 pb)
2000   // Open working directory (WDParam)
2001   static int16 fs_open_wd(uint32 pb)
2002   {
2003 <        D(bug(" fs_open_wd(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID)));
2003 >        D(bug(" fs_open_wd(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), ReadMacInt32(pb + ioWDDirID)));
2004          M68kRegisters r;
2005  
2006          // Allocate WDCB

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines