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.3 by cebix, 1999-10-20T15:13:53Z vs.
Revision 1.21 by cebix, 2000-07-22T16:07:16Z

# Line 1 | Line 1
1   /*
2 < *  extfs.cpp - MacOS file system for access native file system access
2 > *  extfs.cpp - MacOS file system for native file system access
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2000 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 40 | Line 40
40   #include <string.h>
41   #include <stdio.h>
42   #include <stdlib.h>
43 #include <unistd.h>
43   #include <fcntl.h>
45 #include <dirent.h>
44   #include <errno.h>
45  
46 + #ifndef WIN32
47 + #include <unistd.h>
48 + #include <dirent.h>
49 + #endif
50 +
51   #include "cpu_emulation.h"
52   #include "macos_util.h"
53   #include "emul_op.h"
# Line 55 | Line 58
58   #include "extfs.h"
59   #include "extfs_defs.h"
60  
61 + #ifdef WIN32
62 + # include "posix_emu.h"
63 + #endif
64 +
65   #define DEBUG 0
66   #include "debug.h"
67  
# Line 65 | Line 72 | enum {
72          fsHFSProcStub = 6,
73          fsDrvStatus = 12,                               // Drive Status record
74          fsFSD = 42,                                             // File system descriptor
75 <        fsPB = 238,                                             // IOParam (for mounting)
75 >        fsPB = 238,                                             // IOParam (for mounting and renaming), also used for temporary storage
76          fsVMI = 288,                                    // VoumeMountInfoHeader (for mounting)
77          fsParseRec = 296,                               // ParsePathRec struct
78          fsReturn = 306,                                 // Area for return data of 68k routines
79          fsAllocateVCB = 562,                    // UTAllocateVCB(uint16 *sysVCBLength{a0}, uint32 *vcb{a1})
80          fsAddNewVCB = 578,                              // UTAddNewVCB(int drive_number{d0}, int16 *vRefNum{a1}, uint32 vcb{a1})
81          fsDetermineVol = 594,                   // UTDetermineVol(uint32 pb{a0}, int16 *status{a1}, int16 *more_matches{a2}, int16 *vRefNum{a3}, uint32 *vcb{a4})
82 <        fsResolveWDCB = 614,                    // UTResolveWDCB(int16 vRefNum{d0}, uint32 *wdcb{a0})
82 >        fsResolveWDCB = 614,                    // UTResolveWDCB(uint32 procID{d0}, int16 index{d1}, int16 vRefNum{d0}, uint32 *wdcb{a0})
83          fsGetDefaultVol = 632,                  // UTGetDefaultVol(uint32 wdpb{a0})
84          fsGetPathComponentName = 644,   // UTGetPathComponentName(uint32 rec{a0})
85          fsParsePathname = 656,                  // UTParsePathname(uint32 *start{a0}, uint32 name{a1})
# Line 101 | Line 108 | static bool ready = false;
108   static struct stat root_stat;
109  
110   // File system ID/media type
111 < const int16 MY_FSID = 'ba';
112 < const uint32 MY_MEDIA_TYPE = 'basi';
111 > const int16 MY_FSID = 0x6261;   // 'ba'
112 > const uint32 MY_MEDIA_TYPE = FOURCC('b','a','s','i');
113  
114   // CNID of root and root's parent
115   const uint32 ROOT_ID = 2;
# Line 111 | Line 118 | const uint32 ROOT_PARENT_ID = 1;
118   // File system stack size
119   const int STACK_SIZE = 0x10000;
120  
121 + // Allocation block and clump size as reported to MacOS (these are of course
122 + // not the real values and have no meaning on the host OS)
123 + const int AL_BLK_SIZE = 0x4000;
124 + const int CLUMP_SIZE = 0x4000;
125 +
126   // Drive number of our pseudo-drive
127   static int drive_number;
128  
# Line 201 | Line 213 | static FSItem *find_fsitem(const char *n
213   *  Get full path (->full_path) for given FSItem
214   */
215  
204 const int MAX_PATH_LENGTH = 1024;
216   static char full_path[MAX_PATH_LENGTH];
217  
218 < static void add_path_component(const char *s)
218 > static void add_path_comp(const char *s)
219   {
220 <        int l = strlen(full_path);
210 <        if (l < MAX_PATH_LENGTH-1 && full_path[l-1] != '/') {
211 <                full_path[l] = '/';
212 <                full_path[l+1] = 0;
213 <        }
214 <        strncat(full_path, s, MAX_PATH_LENGTH-1);
220 >        add_path_component(full_path, s);
221   }
222  
223   static void get_path_for_fsitem(FSItem *p)
224   {
225 <        if (p->id == ROOT_ID) {
225 >        if (p->id == ROOT_PARENT_ID) {
226 >                full_path[0] = 0;
227 >        } else if (p->id == ROOT_ID) {
228                  strncpy(full_path, RootPath, MAX_PATH_LENGTH-1);
229                  full_path[MAX_PATH_LENGTH-1] = 0;
230          } else {
231                  get_path_for_fsitem(p->parent);
232 <                add_path_component(p->name);
232 >                add_path_comp(p->name);
233 >        }
234 > }
235 >
236 >
237 > /*
238 > *  Exchange parent CNIDs in all FSItems
239 > */
240 >
241 > static void swap_parent_ids(uint32 parent1, uint32 parent2)
242 > {
243 >        FSItem *p = first_fs_item;
244 >        while (p) {
245 >                if (p->parent_id == parent1)
246 >                        p->parent_id = parent2;
247 >                else if (p->parent_id == parent2)
248 >                        p->parent_id = parent1;
249 >                p = p->next;
250          }
251   }
252  
# Line 244 | Line 269 | static void cstr2pstr(char *dst, const c
269          *dst++ = strlen(src);
270          char c;
271          while ((c = *src++) != 0) {
272 +                // Note: we are converting host ':' characters to Mac '/' characters here
273 +                // '/' is not a path separator as this function is only used on object names
274                  if (c == ':')
275                          c = '/';
276                  *dst++ = c;
277          }
278   }
279  
253 // Convert pascal string to C string
254 static void pstr2cstr(char *dst, const char *src)
255 {
256        int size = *src++;
257        while (size--) {
258                char c = *src++;
259                if (c == '/')
260                        c = ':';
261                *dst++ = c;
262        }
263        *dst = 0;
264 }
265
280   // Convert string (no length byte) to C string, length given separately
281   static void strn2cstr(char *dst, const char *src, int size)
282   {
283          while (size--) {
284                  char c = *src++;
285 +                // Note: we are converting Mac '/' characters to host ':' characters here
286 +                // '/' is not a path separator as this function is only used on object names
287                  if (c == '/')
288                          c = ':';
289                  *dst++ = c;
# Line 325 | Line 341 | void ExtFSInit(void)
341          cstr2pstr(FS_NAME, GetString(STR_EXTFS_NAME));
342          cstr2pstr(VOLUME_NAME, GetString(STR_EXTFS_VOLUME_NAME));
343  
344 <        // Create root FSItem
344 >        // Create root's parent FSItem
345          FSItem *p = new FSItem;
346          first_fs_item = last_fs_item = p;
347          p->next = NULL;
348 +        p->id = ROOT_PARENT_ID;
349 +        p->parent_id = 0;
350 +        p->parent = NULL;
351 +        p->name[0] = 0;
352 +
353 +        // Create root FSItem
354 +        p = new FSItem;
355 +        last_fs_item->next = p;
356 +        p->next = NULL;
357 +        last_fs_item = p;
358          p->id = ROOT_ID;
359          p->parent_id = ROOT_PARENT_ID;
360 <        p->parent = NULL;
360 >        p->parent = first_fs_item;
361          strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32);
362 +        p->name[31] = 0;
363  
364          // Find path for root
365          if ((RootPath = PrefsFindString("extfs")) != NULL) {
# Line 381 | Line 408 | void InstallExtFS(void)
408          // FSM present?
409          r.d[0] = gestaltFSAttr;
410          Execute68kTrap(0xa1ad, &r);     // Gestalt()
411 <        D(bug("FSAttr %ld, %08lx\n", r.d[0], r.a[0]));
411 >        D(bug("FSAttr %d, %08x\n", r.d[0], r.a[0]));
412          if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) {
413                  printf("WARNING: No FSM present, disabling ExtFS\n");
414                  return;
# Line 390 | Line 417 | void InstallExtFS(void)
417          // Yes, version >=1.2?
418          r.d[0] = gestaltFSMVersion;
419          Execute68kTrap(0xa1ad, &r);     // Gestalt()
420 <        D(bug("FSMVersion %ld, %08lx\n", r.d[0], r.a[0]));
420 >        D(bug("FSMVersion %d, %08x\n", r.d[0], r.a[0]));
421          if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) {
422                  printf("WARNING: FSM <1.2 found, disabling ExtFS\n");
423                  return;
# Line 430 | Line 457 | void InstallExtFS(void)
457          WriteMacInt16(p, 0x7006); p+= 2;        // UTAllocateVCB
458          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
459          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
460 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
460 >        WriteMacInt16(p, M68K_RTS); p+= 2;
461          if (p - fs_data != fsAddNewVCB)
462                  goto fsdat_error;
463          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 440 | Line 467 | void InstallExtFS(void)
467          WriteMacInt16(p, 0x7007); p+= 2;        // UTAddNewVCB
468          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
469          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
470 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
470 >        WriteMacInt16(p, M68K_RTS); p+= 2;
471          if (p - fs_data != fsDetermineVol)
472                  goto fsdat_error;
473          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 452 | Line 479 | void InstallExtFS(void)
479          WriteMacInt16(p, 0x701d); p+= 2;        // UTDetermineVol
480          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
481          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
482 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
482 >        WriteMacInt16(p, M68K_RTS); p+= 2;
483          if (p - fs_data != fsResolveWDCB)
484                  goto fsdat_error;
485          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
486 <        WriteMacInt16(p, 0x42a7); p+= 2;        // clr.l -(sp)
487 <        WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
488 <        WriteMacInt16(p, 0x3f00); p+= 2;        // move.w d0,-(sp)
486 >        WriteMacInt16(p, 0x2f00); p+= 2;        // move.l d0,-(sp)
487 >        WriteMacInt16(p, 0x3f01); p+= 2;        // move.w d1,-(sp)
488 >        WriteMacInt16(p, 0x3f02); p+= 2;        // move.w d2,-(sp)
489          WriteMacInt16(p, 0x2f08); p+= 2;        // move.l a0,-(sp)
490          WriteMacInt16(p, 0x700e); p+= 2;        // UTResolveWDCB
491          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
492          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
493 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
493 >        WriteMacInt16(p, M68K_RTS); p+= 2;
494          if (p - fs_data != fsGetDefaultVol)
495                  goto fsdat_error;
496          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 471 | Line 498 | void InstallExtFS(void)
498          WriteMacInt16(p, 0x7012); p+= 2;        // UTGetDefaultVol
499          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
500          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
501 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
501 >        WriteMacInt16(p, M68K_RTS); p+= 2;
502          if (p - fs_data != fsGetPathComponentName)
503                  goto fsdat_error;
504          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 479 | Line 506 | void InstallExtFS(void)
506          WriteMacInt16(p, 0x701c); p+= 2;        // UTGetPathComponentName
507          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
508          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
509 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
509 >        WriteMacInt16(p, M68K_RTS); p+= 2;
510          if (p - fs_data != fsParsePathname)
511                  goto fsdat_error;
512          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 488 | Line 515 | void InstallExtFS(void)
515          WriteMacInt16(p, 0x701b); p+= 2;        // UTParsePathname
516          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
517          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
518 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
518 >        WriteMacInt16(p, M68K_RTS); p+= 2;
519          if (p - fs_data != fsDisposeVCB)
520                  goto fsdat_error;
521          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 496 | Line 523 | void InstallExtFS(void)
523          WriteMacInt16(p, 0x7008); p+= 2;        // UTDisposeVCB
524          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
525          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
526 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
526 >        WriteMacInt16(p, M68K_RTS); p+= 2;
527          if (p - fs_data != fsCheckWDRefNum)
528                  goto fsdat_error;
529          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 504 | Line 531 | void InstallExtFS(void)
531          WriteMacInt16(p, 0x7013); p+= 2;        // UTCheckWDRefNum
532          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
533          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
534 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
534 >        WriteMacInt16(p, M68K_RTS); p+= 2;
535          if (p - fs_data != fsSetDefaultVol)
536                  goto fsdat_error;
537          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 514 | Line 541 | void InstallExtFS(void)
541          WriteMacInt16(p, 0x7011); p+= 2;        // UTSetDefaultVol
542          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
543          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
544 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
544 >        WriteMacInt16(p, M68K_RTS); p+= 2;
545          if (p - fs_data != fsAllocateFCB)
546                  goto fsdat_error;
547          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 523 | Line 550 | void InstallExtFS(void)
550          WriteMacInt16(p, 0x7000); p+= 2;        // UTAllocateFCB
551          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
552          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
553 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
553 >        WriteMacInt16(p, M68K_RTS); p+= 2;
554          if (p - fs_data != fsReleaseFCB)
555                  goto fsdat_error;
556          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 531 | Line 558 | void InstallExtFS(void)
558          WriteMacInt16(p, 0x7001); p+= 2;        // UTReleaseFCB
559          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
560          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
561 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
561 >        WriteMacInt16(p, M68K_RTS); p+= 2;
562          if (p - fs_data != fsIndexFCB)
563                  goto fsdat_error;
564          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 541 | Line 568 | void InstallExtFS(void)
568          WriteMacInt16(p, 0x7004); p+= 2;        // UTIndexFCB
569          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
570          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
571 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
571 >        WriteMacInt16(p, M68K_RTS); p+= 2;
572          if (p - fs_data != fsResolveFCB)
573                  goto fsdat_error;
574          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 550 | Line 577 | void InstallExtFS(void)
577          WriteMacInt16(p, 0x7005); p+= 2;        // UTResolveFCB
578          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
579          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
580 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
580 >        WriteMacInt16(p, M68K_RTS); p+= 2;
581          if (p - fs_data != fsAdjustEOF)
582                  goto fsdat_error;
583          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 558 | Line 585 | void InstallExtFS(void)
585          WriteMacInt16(p, 0x7010); p+= 2;        // UTAdjustEOF
586          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
587          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
588 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
588 >        WriteMacInt16(p, M68K_RTS); p+= 2;
589          if (p - fs_data != fsAllocateWDCB)
590                  goto fsdat_error;
591          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 566 | Line 593 | void InstallExtFS(void)
593          WriteMacInt16(p, 0x700c); p+= 2;        // UTAllocateWDCB
594          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
595          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
596 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
596 >        WriteMacInt16(p, M68K_RTS); p+= 2;
597          if (p - fs_data != fsReleaseWDCB)
598                  goto fsdat_error;
599          WriteMacInt16(p, 0x4267); p+= 2;        // clr.w -(sp)
# Line 574 | Line 601 | void InstallExtFS(void)
601          WriteMacInt16(p, 0x700d); p+= 2;        // UTReleaseWDCB
602          WriteMacInt16(p, 0xa824); p+= 2;        // FSMgr
603          WriteMacInt16(p, 0x301f); p+= 2;        // move.w (sp)+,d0
604 <        WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2;
604 >        WriteMacInt16(p, M68K_RTS); p+= 2;
605          if (p - fs_data != SIZEOF_fsdat)
606                  goto fsdat_error;
607  
# Line 598 | Line 625 | void InstallExtFS(void)
625          WriteMacInt16(fs_data + fsFSD + fsdLength, SIZEOF_FSDRec);
626          WriteMacInt16(fs_data + fsFSD + fsdVersion, fsdVersion1);
627          WriteMacInt16(fs_data + fsFSD + fileSystemFSID, MY_FSID);
628 <        memcpy(Mac2HostAddr(fs_data + fsFSD + fileSystemName), FS_NAME, 32);
628 >        Host2Mac_memcpy(fs_data + fsFSD + fileSystemName, FS_NAME, 32);
629          WriteMacInt32(fs_data + fsFSD + fileSystemCommProc, fs_data + fsCommProcStub);
630          WriteMacInt32(fs_data + fsFSD + fsdHFSCI + compInterfProc, fs_data + fsHFSProcStub);
631          WriteMacInt32(fs_data + fsFSD + fsdHFSCI + stackTop, fs_stack + STACK_SIZE);
# Line 652 | Line 679 | int16 ExtFSComm(uint16 message, uint32 p
679  
680                  case ffsGetIconMessage: {               // Get disk/drive icon
681                          if (ReadMacInt8(paramBlock + iconType) == kLargeIcon && ReadMacInt32(paramBlock + requestSize) >= sizeof(ExtFSIcon)) {
682 <                                memcpy(Mac2HostAddr(ReadMacInt32(paramBlock + iconBufferPtr)), ExtFSIcon, sizeof(ExtFSIcon));
682 >                                Host2Mac_memcpy(ReadMacInt32(paramBlock + iconBufferPtr), ExtFSIcon, sizeof(ExtFSIcon));
683                                  WriteMacInt32(paramBlock + actualSize, sizeof(ExtFSIcon));
684                                  return noErr;
685                          } else
# Line 660 | Line 687 | int16 ExtFSComm(uint16 message, uint32 p
687                  }
688  
689                  case ffsIDDiskMessage: {                // Check if volume is handled by our FS
690 <                        if (ReadMacInt16(paramBlock + ioVRefNum) == drive_number)
690 >                        if ((int16)ReadMacInt16(paramBlock + ioVRefNum) == drive_number)
691                                  return noErr;
692                          else
693                                  return extFSErr;
# Line 689 | Line 716 | static int16 get_current_dir(uint32 pb,
716          int16 result;
717  
718          // Determine volume
719 < //      D(bug("  determining volume\n"));
719 >        D(bug("  determining volume, dirID %d\n", dirID));
720          r.a[0] = pb;
721          r.a[1] = fs_data + fsReturn;
722          r.a[2] = fs_data + fsReturn + 2;
# Line 707 | Line 734 | static int16 get_current_dir(uint32 pb,
734          int16 more_matches = ReadMacInt16(fs_data + fsReturn + 2);
735          int16 vRefNum = ReadMacInt16(fs_data + fsReturn + 4);
736          uint32 vcb = ReadMacInt32(fs_data + fsReturn + 6);
737 < //      D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
738 <        result = r.d[0] & 0xffff;
737 >        D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
738 >        result = (int16)(r.d[0] & 0xffff);
739  
740          if (result == noErr) {
741                  switch (status) {
# Line 726 | Line 753 | static int16 get_current_dir(uint32 pb,
753                                          current_dir = dirID;
754                                  else {
755                                          D(bug("  resolving WDCB\n"));
756 <                                        r.d[0] = ReadMacInt16(pb + ioVRefNum);
756 >                                        r.d[0] = 0;
757 >                                        r.d[1] = 0;
758 >                                        r.d[2] = ReadMacInt16(pb + ioVRefNum);
759                                          r.a[0] = fs_data + fsReturn;
760                                          Execute68k(fs_data + fsResolveWDCB, &r);
761                                          uint32 wdcb = ReadMacInt32(fs_data + fsReturn);
762                                          D(bug("  UTResolveWDCB() returned %d, dirID %d\n", r.d[0], ReadMacInt32(wdcb + wdDirID)));
763 <                                        result = r.d[0] & 0xffff;
763 >                                        result = (int16)(r.d[0] & 0xffff);
764                                          if (result == noErr)
765                                                  current_dir = ReadMacInt32(wdcb + wdDirID);
766                                  }
# Line 747 | Line 776 | static int16 get_current_dir(uint32 pb,
776                                          r.a[0] = wdpb;
777                                          Execute68k(fs_data + fsGetDefaultVol, &r);
778                                          D(bug("  UTGetDefaultVol() returned %d, dirID %d\n", r.d[0], ReadMacInt32(wdpb + ioWDDirID)));
779 <                                        result = r.d[0] & 0xffff;
779 >                                        result = (int16)(r.d[0] & 0xffff);
780                                          if (result == noErr)
781                                                  current_dir = ReadMacInt32(wdpb + ioWDDirID);
782                                  }
# Line 773 | Line 802 | static int16 get_path_component_name(uin
802          r.a[0] = rec;
803          Execute68k(fs_data + fsGetPathComponentName, &r);
804   //      D(bug("  UTGetPathComponentName returned %d\n", r.d[0]));
805 <        return r.d[0] & 0xffff;
805 >        return (int16)(r.d[0] & 0xffff);
806   }
807  
808  
# Line 790 | Line 819 | static int16 get_item_and_path(uint32 pb
819          uint32 current_dir;
820          if ((result = get_current_dir(pb, dirID, current_dir, no_vol_name)) != noErr)
821                  return result;
822 +        D(bug("  current dir %08x\n", current_dir));
823          FSItem *p = find_fsitem_by_id(current_dir);
824          if (p == NULL)
825                  return dirNFErr;
# Line 803 | Line 833 | static int16 get_item_and_path(uint32 pb
833          WriteMacInt8(parseRec + ppFoundDelimiter, false);
834  
835          // Get length of volume name
836 < //      D(bug("  parsing pathname\n"));
836 >        D(bug("  parsing pathname\n"));
837          r.a[0] = parseRec + ppStartOffset;
838          r.a[1] = ReadMacInt32(parseRec + ppNamePtr);
839          Execute68k(fs_data + fsParsePathname, &r);
840 < //      D(bug("  UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset)));
841 <        result = r.d[0] & 0xffff;
840 >        D(bug("  UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset)));
841 >        result = (int16)(r.d[0] & 0xffff);
842          if (result == noErr) {
843  
844                  // Check for leading delimiter of the partial pathname
# Line 921 | Line 951 | static uint32 find_fcb(int16 refNum)
951   static int16 fs_mount_vol(uint32 pb)
952   {
953          D(bug(" fs_mount_vol(%08lx), vRefNum %d\n", pb, ReadMacInt16(pb + ioVRefNum)));
954 <        if (ReadMacInt16(pb + ioVRefNum) == drive_number)
954 >        if ((int16)ReadMacInt16(pb + ioVRefNum) == drive_number)
955                  return noErr;
956          else
957                  return extFSErr;
# Line 942 | Line 972 | static int16 fs_volume_mount(uint32 pb)
972          uint32 vcb = ReadMacInt32(fs_data + fsReturn + 2);
973          D(bug("  UTAllocateVCB() returned %d, vcb %08lx, size %d\n", r.d[0], vcb, sysVCBLength));
974          if (r.d[0] & 0xffff)
975 <                return r.d[0];
975 >                return (int16)r.d[0];
976  
977          // Init VCB
978          WriteMacInt16(vcb + vcbSigWord, 0x4244);
979 < #ifdef __BEOS__
979 > #if defined(__BEOS__) || defined(WIN32)
980          WriteMacInt32(vcb + vcbCrDate, root_stat.st_crtime + TIME_OFFSET);
981   #else
982          WriteMacInt32(vcb + vcbCrDate, 0);
# Line 956 | Line 986 | static int16 fs_volume_mount(uint32 pb)
986          WriteMacInt16(vcb + vcbNmFls, 1);                       //!!
987          WriteMacInt16(vcb + vcbNmRtDirs, 1);            //!!
988          WriteMacInt16(vcb + vcbNmAlBlks, 0xffff);       //!!
989 <        WriteMacInt32(vcb + vcbAlBlkSiz, 1024);
990 <        WriteMacInt32(vcb + vcbClpSiz, 1024);
989 >        WriteMacInt32(vcb + vcbAlBlkSiz, AL_BLK_SIZE);
990 >        WriteMacInt32(vcb + vcbClpSiz, CLUMP_SIZE);
991          WriteMacInt32(vcb + vcbNxtCNID, next_cnid);
992          WriteMacInt16(vcb + vcbFreeBks, 0xffff);        //!!
993 <        memcpy(Mac2HostAddr(vcb + vcbVN), VOLUME_NAME, 28);
993 >        Host2Mac_memcpy(vcb + vcbVN, VOLUME_NAME, 28);
994          WriteMacInt16(vcb + vcbFSID, MY_FSID);
995          WriteMacInt32(vcb + vcbFilCnt, 1);                      //!!
996          WriteMacInt32(vcb + vcbDirCnt, 1);                      //!!
# Line 971 | Line 1001 | static int16 fs_volume_mount(uint32 pb)
1001          r.a[0] = fs_data + fsReturn;
1002          r.a[1] = vcb;
1003          Execute68k(fs_data + fsAddNewVCB, &r);
1004 <        int16 vRefNum = ReadMacInt32(fs_data + fsReturn);
1004 >        int16 vRefNum = (int16)ReadMacInt32(fs_data + fsReturn);
1005          D(bug("  UTAddNewVCB() returned %d, vRefNum %d\n", r.d[0], vRefNum));
1006          if (r.d[0] & 0xffff)
1007 <                return r.d[0];
1007 >                return (int16)r.d[0];
1008  
1009          // Post diskInsertEvent
1010          D(bug("  posting diskInsertEvent\n"));
# Line 998 | Line 1028 | static int16 fs_unmount_vol(uint32 vcb)
1028          r.a[0] = vcb;
1029          Execute68k(fs_data + fsDisposeVCB, &r);
1030          D(bug("  UTDisposeVCB() returned %d\n", r.d[0]));
1031 <        return r.d[0];
1031 >        return (int16)r.d[0];
1032   }
1033  
1034   // Get information about a volume (HVolumeParam)
# Line 1009 | Line 1039 | static int16 fs_get_vol_info(uint32 pb,
1039          // Fill in struct
1040          if (ReadMacInt32(pb + ioNamePtr))
1041                  pstrcpy((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), VOLUME_NAME);
1042 < #ifdef __BEOS__
1042 > #if defined(__BEOS__) || defined(WIN32)
1043          WriteMacInt32(pb + ioVCrDate, root_stat.st_crtime + TIME_OFFSET);
1044   #else
1045          WriteMacInt32(pb + ioVCrDate, 0);
# Line 1020 | Line 1050 | static int16 fs_get_vol_info(uint32 pb,
1050          WriteMacInt16(pb + ioVBitMap, 0);
1051          WriteMacInt16(pb + ioAllocPtr, 0);
1052          WriteMacInt16(pb + ioVNmAlBlks, 0xffff);        //!!
1053 <        WriteMacInt32(pb + ioVAlBlkSiz, 1024);
1054 <        WriteMacInt32(pb + ioVClpSiz, 1024);
1053 >        WriteMacInt32(pb + ioVAlBlkSiz, AL_BLK_SIZE);
1054 >        WriteMacInt32(pb + ioVClpSiz, CLUMP_SIZE);
1055          WriteMacInt16(pb + ioAlBlSt, 0);
1056          WriteMacInt32(pb + ioVNxtCNID, next_cnid);
1057          WriteMacInt16(pb + ioVFrBlk, 0xffff);           //!!
# Line 1034 | Line 1064 | static int16 fs_get_vol_info(uint32 pb,
1064                  WriteMacInt32(pb + ioVWrCnt, 0);
1065                  WriteMacInt32(pb + ioVFilCnt, 1);                       //!!
1066                  WriteMacInt32(pb + ioVDirCnt, 1);                       //!!
1067 <                memset(Mac2HostAddr(pb + ioVFndrInfo), 0, 32);
1067 >                Mac_memset(pb + ioVFndrInfo, 0, 32);
1068          }
1069          return noErr;
1070   }
# Line 1054 | Line 1084 | static int16 fs_get_vol_parms(uint32 pb)
1084   //      D(bug(" fs_get_vol_parms(%08lx)\n", pb));
1085  
1086          // Return parameter block
1057        uint8 vol[SIZEOF_GetVolParmsInfoBuffer];
1058        WriteMacInt16((uint32)vol + vMVersion, 2);
1059        WriteMacInt32((uint32)vol + vMAttrib, kNoMiniFndr | kNoVNEdit | kNoLclSync | kTrshOffLine | kNoSwitchTo | kNoBootBlks | kNoSysDir | kHasExtFSVol);
1060        WriteMacInt32((uint32)vol + vMLocalHand, 0);
1061        WriteMacInt32((uint32)vol + vMServerAdr, 0);
1062        WriteMacInt32((uint32)vol + vMVolumeGrade, 0);
1063        WriteMacInt16((uint32)vol + vMForeignPrivID, 0);
1087          uint32 actual = ReadMacInt32(pb + ioReqCount);
1088 <        if (actual > sizeof(vol))
1089 <                actual = sizeof(vol);
1067 <        memcpy(Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), vol, actual);
1088 >        if (actual > SIZEOF_GetVolParmsInfoBuffer)
1089 >                actual = SIZEOF_GetVolParmsInfoBuffer;
1090          WriteMacInt32(pb + ioActCount, actual);
1091 +        uint32 p = ReadMacInt32(pb + ioBuffer);
1092 +        if (actual > vMVersion) WriteMacInt16(p + vMVersion, 2);
1093 +        if (actual > vMAttrib) WriteMacInt32(p + vMAttrib, kNoMiniFndr | kNoVNEdit | kNoLclSync | kTrshOffLine | kNoSwitchTo | kNoBootBlks | kNoSysDir | kHasExtFSVol);
1094 +        if (actual > vMLocalHand) WriteMacInt32(p + vMLocalHand, 0);
1095 +        if (actual > vMServerAdr) WriteMacInt32(p + vMServerAdr, 0);
1096 +        if (actual > vMVolumeGrade) WriteMacInt32(p + vMVolumeGrade, 0);
1097 +        if (actual > vMForeignPrivID) WriteMacInt16(p + vMForeignPrivID, 0);
1098          return noErr;
1099   }
1100  
# Line 1080 | Line 1109 | static int16 fs_get_vol(uint32 pb)
1109          r.a[0] = pb;
1110          Execute68k(fs_data + fsGetDefaultVol, &r);
1111          D(bug("  UTGetDefaultVol() returned %d\n", r.d[0]));
1112 <        return r.d[0];
1112 >        return (int16)r.d[0];
1113   }
1114  
1115   // Set default volume (WDParam)
1116   static int16 fs_set_vol(uint32 pb, bool hfs, uint32 vcb)
1117   {
1118 <        D(bug(" fs_set_vol(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID)));
1118 >        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)));
1119          M68kRegisters r;
1120  
1121          // Determine parameters
# Line 1136 | Line 1165 | static int16 fs_set_vol(uint32 pb, bool
1165          r.d[2] = refNum;
1166          Execute68k(fs_data + fsSetDefaultVol, &r);
1167          D(bug("  UTSetDefaultVol() returned %d\n", r.d[0]));
1168 <        return r.d[0];
1168 >        return (int16)r.d[0];
1169   }
1170  
1171   // Query file attributes (HFileParam)
1172   static int16 fs_get_file_info(uint32 pb, bool hfs, uint32 dirID)
1173   {
1174 <        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));
1174 >        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));
1175  
1176          FSItem *fs_item;
1177          int16 dir_index = ReadMacInt16(pb + ioFDirIndex);
1178 <        if (dir_index == 0) {   // Query item specified by ioDirID and ioNamePtr
1178 >        if (dir_index <= 0) {           // Query item specified by ioDirID and ioNamePtr
1179  
1180                  // Find FSItem for given file
1181                  int16 result = get_item_and_path(pb, dirID, fs_item);
# Line 1178 | Line 1207 | read_next_de:
1207                                  return fnfErr;
1208                          }
1209                          if (de->d_name[0] == '.')
1210 <                                goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1210 >                                goto read_next_de;      // Suppress names beginning with '.' (MacOS could interpret these as driver names)
1211                          //!! suppress directories
1212                  }
1213 <                add_path_component(de->d_name);
1213 >                add_path_comp(de->d_name);
1214  
1215                  // Get FSItem for queried item
1216                  fs_item = find_fsitem(de->d_name, p);
# Line 1202 | Line 1231 | read_next_de:
1231          WriteMacInt8(pb + ioFlAttrib, access(full_path, W_OK) == 0 ? 0 : faLocked);
1232          WriteMacInt32(pb + ioDirID, fs_item->id);
1233  
1234 < #ifdef __BEOS__
1234 > #if defined(__BEOS__) || defined(WIN32)
1235          WriteMacInt32(pb + ioFlCrDat, st.st_crtime + TIME_OFFSET);
1236   #else
1237          WriteMacInt32(pb + ioFlCrDat, 0);
1238   #endif
1239          WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET);
1240  
1241 <        memset(Mac2HostAddr(pb + ioFlFndrInfo), 0, SIZEOF_FInfo);
1213 <        uint32 type, creator;   // pb may point to kernel space, but stack is switched
1214 <        get_finder_type(full_path, type, creator);
1215 <        WriteMacInt32(pb + ioFlFndrInfo + fdType, type);
1216 <        WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator);
1217 <        uint16 fflags;
1218 <        get_finder_flags(full_path, fflags);
1219 <        WriteMacInt16(pb + ioFlFndrInfo + fdFlags, fflags);
1241 >        get_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0);
1242  
1243          WriteMacInt16(pb + ioFlStBlk, 0);
1244          WriteMacInt32(pb + ioFlLgLen, st.st_size);
1245 <        WriteMacInt32(pb + ioFlPyLen, (st.st_size + 1023) & ~1023);
1245 >        WriteMacInt32(pb + ioFlPyLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1246          WriteMacInt16(pb + ioFlRStBlk, 0);
1247          uint32 rf_size = get_rfork_size(full_path);
1248          WriteMacInt32(pb + ioFlRLgLen, rf_size);
1249 <        WriteMacInt32(pb + ioFlRPyLen, (rf_size + 1023) & ~1023);
1249 >        WriteMacInt32(pb + ioFlRPyLen, (rf_size | (AL_BLK_SIZE - 1)) + 1);
1250  
1251          if (hfs) {
1252                  WriteMacInt32(pb + ioFlBkDat, 0);
1231                memset(Mac2HostAddr(pb + ioFlXFndrInfo), 0, SIZEOF_FXInfo);
1253                  WriteMacInt32(pb + ioFlParID, fs_item->parent_id);
1254                  WriteMacInt32(pb + ioFlClpSiz, 0);
1255          }
# Line 1238 | Line 1259 | read_next_de:
1259   // Set file attributes (HFileParam)
1260   static int16 fs_set_file_info(uint32 pb, bool hfs, uint32 dirID)
1261   {
1262 <        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));
1262 >        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));
1263  
1264          // Find FSItem for given file/dir
1265          FSItem *fs_item;
# Line 1253 | Line 1274 | static int16 fs_set_file_info(uint32 pb,
1274          if (S_ISDIR(st.st_mode))
1275                  return fnfErr;
1276  
1277 <        // Set attributes
1278 <        set_finder_type(full_path, ReadMacInt32(pb + ioFlFndrInfo + fdType), ReadMacInt32(pb + ioFlFndrInfo + fdCreator));
1279 <        set_finder_flags(full_path, ReadMacInt16(pb + ioFlFndrInfo + fdFlags));
1277 >        // Set Finder info
1278 >        set_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0);
1279 >
1280          //!! times
1281          return noErr;
1282   }
# Line 1263 | Line 1284 | static int16 fs_set_file_info(uint32 pb,
1284   // Query file/directory attributes
1285   static int16 fs_get_cat_info(uint32 pb)
1286   {
1287 <        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)));
1287 >        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)));
1288  
1289          FSItem *fs_item;
1290          int16 dir_index = ReadMacInt16(pb + ioFDirIndex);
1291 <        if (dir_index == -1) {          // Query directory specified by ioDirID
1291 >        if (dir_index < 0) {                    // Query directory specified by ioDirID
1292  
1293                  // Find FSItem for directory
1294                  fs_item = find_fsitem_by_id(ReadMacInt32(pb + ioDrDirID));
# Line 1307 | Line 1328 | read_next_de:
1328                                  return fnfErr;
1329                          }
1330                          if (de->d_name[0] == '.')
1331 <                                goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1331 >                                goto read_next_de;      // Suppress names beginning with '.' (MacOS could interpret these as driver names)
1332                  }
1333 <                add_path_component(de->d_name);
1333 >                add_path_comp(de->d_name);
1334  
1335                  // Get FSItem for queried item
1336                  fs_item = find_fsitem(de->d_name, p);
# Line 1332 | Line 1353 | read_next_de:
1353          WriteMacInt8(pb + ioACUser, 0);
1354          WriteMacInt32(pb + ioDirID, fs_item->id);
1355          WriteMacInt32(pb + ioFlParID, fs_item->parent_id);
1356 < #ifdef __BEOS__
1356 > #if defined(__BEOS__) || defined(WIN32)
1357          WriteMacInt32(pb + ioFlCrDat, st.st_crtime + TIME_OFFSET);
1358   #else
1359          WriteMacInt32(pb + ioFlCrDat, 0);
# Line 1343 | Line 1364 | read_next_de:
1364                  fs_item->mtime = mtime;
1365                  cached = false;
1366          }
1367 <        WriteMacInt32(pb + ioFlMdDat, mtime);
1367 >        WriteMacInt32(pb + ioFlMdDat, mtime + TIME_OFFSET);
1368          WriteMacInt32(pb + ioFlBkDat, 0);
1369 +
1370 +        get_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo);
1371 +
1372          if (S_ISDIR(st.st_mode)) {
1349                memset(Mac2HostAddr(pb + ioDrUsrWds), 0, SIZEOF_DInfo);
1350                memset(Mac2HostAddr(pb + ioDrFndrInfo), 0, SIZEOF_DXInfo);
1351                uint16 fflags;  // pb may point to kernel space, but stack is switched
1352                get_finder_flags(full_path, fflags);
1353                WriteMacInt16(pb + ioDrUsrWds + frFlags, fflags);
1373  
1374                  // Determine number of files in directory (cached)
1375                  int count;
# Line 1365 | Line 1384 | read_next_de:
1384                                          de = readdir(d);
1385                                          if (de == NULL)
1386                                                  break;
1387 +                                        if (de->d_name[0] == '.')
1388 +                                                continue;       // Suppress names beginning with '.'
1389                                          count++;
1390                                  }
1391                                  closedir(d);
# Line 1373 | Line 1394 | read_next_de:
1394                  }
1395                  WriteMacInt16(pb + ioDrNmFls, count);
1396          } else {
1376                memset(Mac2HostAddr(pb + ioFlFndrInfo), 0, SIZEOF_FInfo);
1377                memset(Mac2HostAddr(pb + ioFlXFndrInfo), 0, SIZEOF_FXInfo);
1378                uint32 type, creator;   // pb may point to kernel space, but stack is switched
1379                get_finder_type(full_path, type, creator);
1380                WriteMacInt32(pb + ioFlFndrInfo + fdType, type);
1381                WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator);
1382                uint16 fflags;
1383                get_finder_flags(full_path, fflags);
1384                WriteMacInt16(pb + ioFlFndrInfo + fdFlags, fflags);
1397                  WriteMacInt16(pb + ioFlStBlk, 0);
1398                  WriteMacInt32(pb + ioFlLgLen, st.st_size);
1399 <                WriteMacInt32(pb + ioFlPyLen, (st.st_size + 1023) & ~1023);
1399 >                WriteMacInt32(pb + ioFlPyLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1400                  WriteMacInt16(pb + ioFlRStBlk, 0);
1401                  uint32 rf_size = get_rfork_size(full_path);
1402                  WriteMacInt32(pb + ioFlRLgLen, rf_size);
1403 <                WriteMacInt32(pb + ioFlRPyLen, (rf_size + 1023) & ~1023);
1403 >                WriteMacInt32(pb + ioFlRPyLen, (rf_size | (AL_BLK_SIZE - 1)) + 1);
1404                  WriteMacInt32(pb + ioFlClpSiz, 0);
1405          }
1406          return noErr;
# Line 1397 | Line 1409 | read_next_de:
1409   // Set file/directory attributes
1410   static int16 fs_set_cat_info(uint32 pb)
1411   {
1412 <        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)));
1412 >        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)));
1413  
1414          // Find FSItem for given file/dir
1415          FSItem *fs_item;
# Line 1410 | Line 1422 | static int16 fs_set_cat_info(uint32 pb)
1422          if (stat(full_path, &st) < 0)
1423                  return errno2oserr();
1424  
1425 <        // Set attributes
1426 <        if (S_ISDIR(st.st_mode))
1427 <                set_finder_flags(full_path, ReadMacInt16(pb + ioDrUsrWds + frFlags));
1416 <        else {
1417 <                set_finder_type(full_path, ReadMacInt32(pb + ioFlFndrInfo + fdType), ReadMacInt32(pb + ioFlFndrInfo + fdCreator));
1418 <                set_finder_flags(full_path, ReadMacInt16(pb + ioFlFndrInfo + fdFlags));
1419 <        }
1425 >        // Set Finder info
1426 >        set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo);
1427 >
1428          //!! times
1429          return noErr;
1430   }
# Line 1424 | 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 1463 | Line 1471 | static int16 fs_open(uint32 pb, uint32 d
1471                  if (access(full_path, F_OK))
1472                          return fnfErr;
1473                  fd = open_rfork(full_path, flag);
1474 <                if (fd > 0) {
1475 <                        if (fstat(fd, &st) < 0)
1474 >                if (fd >= 0) {
1475 >                        if (fstat(fd, &st) < 0) {
1476 >                                close(fd);
1477                                  return errno2oserr();
1478 +                        }
1479                  } else {        // Resource fork not supported, silently ignore it ("pseudo" resource fork)
1480                          st.st_size = 0;
1481                          st.st_mode = 0;
# Line 1474 | Line 1484 | static int16 fs_open(uint32 pb, uint32 d
1484                  fd = open(full_path, flag);
1485                  if (fd < 0)
1486                          return errno2oserr();
1487 <                if (fstat(fd, &st) < 0)
1487 >                if (fstat(fd, &st) < 0) {
1488 >                        close(fd);
1489                          return errno2oserr();
1490 +                }
1491          }
1492  
1493          // File open, allocate FCB
# Line 1487 | Line 1499 | static int16 fs_open(uint32 pb, uint32 d
1499          D(bug("  UTAllocateFCB() returned %d, fRefNum %d, fcb %08lx\n", r.d[0], ReadMacInt16(pb + ioRefNum), fcb));
1500          if (r.d[0] & 0xffff) {
1501                  close(fd);
1502 <                return r.d[0];
1502 >                return (int16)r.d[0];
1503          }
1504  
1505          // Initialize FCB, fd is stored in fcbCatPos
1506          WriteMacInt32(fcb + fcbFlNm, fs_item->id);
1507          WriteMacInt8(fcb + fcbFlags, ((flag == O_WRONLY || flag == O_RDWR) ? fcbWriteMask : 0) | (resource_fork ? fcbResourceMask : 0) | (write_ok ? 0 : fcbFileLockedMask));
1508          WriteMacInt32(fcb + fcbEOF, st.st_size);
1509 <        WriteMacInt32(fcb + fcbPLen, (st.st_size + 1023) & ~1023);
1509 >        WriteMacInt32(fcb + fcbPLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1510          WriteMacInt32(fcb + fcbCrPs, 0);
1511          WriteMacInt32(fcb + fcbVPtr, vcb);
1512 <        WriteMacInt32(fcb + fcbClmpSize, 1024);
1513 <        uint32 type, creator;   // fcb may point to kernel space, but stack is switched
1514 <        get_finder_type(full_path, type, creator);
1515 <        WriteMacInt32(fcb + fcbFType, type);
1512 >        WriteMacInt32(fcb + fcbClmpSize, CLUMP_SIZE);
1513 >
1514 >        get_finfo(full_path, fs_data + fsPB, 0);
1515 >        WriteMacInt32(fcb + fcbFType, ReadMacInt32(fs_data + fsPB + fdType));
1516 >
1517          WriteMacInt32(fcb + fcbCatPos, fd);
1518          WriteMacInt32(fcb + fcbDirID, fs_item->parent_id);
1519          cstr2pstr((char *)Mac2HostAddr(fcb + fcbCName), fs_item->name);
# Line 1537 | Line 1550 | static int16 fs_close(uint32 pb)
1550          r.d[0] = ReadMacInt16(pb + ioRefNum);
1551          Execute68k(fs_data + fsReleaseFCB, &r);
1552          D(bug("  UTReleaseFCB() returned %d\n", r.d[0]));
1553 <        return r.d[0];
1553 >        return (int16)r.d[0];
1554   }
1555  
1556   // Query information about FCB (FCBPBRec)
# Line 1556 | Line 1569 | static int16 fs_get_fcb_info(uint32 pb,
1569  
1570                  // Find FCB by index
1571                  WriteMacInt16(pb + ioRefNum, 0);
1572 <                for (int i=0; i<ReadMacInt16(pb + ioFCBIndx); i++) {
1572 >                for (int i=0; i<(int)ReadMacInt16(pb + ioFCBIndx); i++) {
1573                          D(bug("  indexing FCBs\n"));
1574                          r.a[0] = vcb;
1575                          r.a[1] = pb + ioRefNum;
# Line 1565 | Line 1578 | static int16 fs_get_fcb_info(uint32 pb,
1578                          fcb = ReadMacInt32(fs_data + fsReturn);
1579                          D(bug("  UTIndexFCB() returned %d, fcb %p\n", r.d[0], fcb));
1580                          if (r.d[0] & 0xffff)
1581 <                                return r.d[0];
1581 >                                return (int16)r.d[0];
1582                  }
1583          }
1584          if (fcb == 0)
# Line 1613 | Line 1626 | static int16 fs_get_eof(uint32 pb)
1626  
1627          // Adjust FCBs
1628          WriteMacInt32(fcb + fcbEOF, st.st_size);
1629 <        WriteMacInt32(fcb + fcbPLen, (st.st_size + 1023) & ~1023);
1629 >        WriteMacInt32(fcb + fcbPLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1630          WriteMacInt32(pb + ioMisc, st.st_size);
1631          D(bug("  adjusting FCBs\n"));
1632          r.d[0] = ReadMacInt16(pb + ioRefNum);
# Line 1648 | Line 1661 | static int16 fs_set_eof(uint32 pb)
1661  
1662          // Adjust FCBs
1663          WriteMacInt32(fcb + fcbEOF, size);
1664 <        WriteMacInt32(fcb + fcbPLen, (size + 1023) & ~1023);
1664 >        WriteMacInt32(fcb + fcbPLen, (size | (AL_BLK_SIZE - 1)) + 1);
1665          D(bug("  adjusting FCBs\n"));
1666          r.d[0] = ReadMacInt16(pb + ioRefNum);
1667          Execute68k(fs_data + fsAdjustEOF, &r);
# Line 1711 | Line 1724 | static int16 fs_set_fpos(uint32 pb)
1724                          if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_SET) < 0)
1725                                  return posErr;
1726                          break;
1727 +                case fsFromLEOF:
1728 +                        if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_END) < 0)
1729 +                                return posErr;
1730 +                        break;
1731                  case fsFromMark:
1732 <                        if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0)
1732 >                        if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0)
1733                                  return posErr;
1734 +                        break;
1735                  default:
1736                          break;
1737          }
# Line 1728 | Line 1746 | static int16 fs_read(uint32 pb)
1746   {
1747          D(bug(" fs_read(%08lx), refNum %d, buffer %p, count %d, posMode %d, posOffset %d\n", pb, ReadMacInt16(pb + ioRefNum), ReadMacInt32(pb + ioBuffer), ReadMacInt32(pb + ioReqCount), ReadMacInt16(pb + ioPosMode), ReadMacInt32(pb + ioPosOffset)));
1748  
1749 +        // Check parameters
1750 +        if ((int32)ReadMacInt32(pb + ioReqCount) < 0)
1751 +                return paramErr;
1752 +
1753          // Find FCB and fd for file
1754          uint32 fcb = find_fcb(ReadMacInt16(pb + ioRefNum));
1755          if (fcb == 0)
# Line 1759 | Line 1781 | static int16 fs_read(uint32 pb)
1781          }
1782  
1783          // Read
1784 <        size_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1784 >        ssize_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1785 >        int16 read_err = errno2oserr();
1786          D(bug("  actual %d\n", actual));
1787 <        WriteMacInt32(pb + ioActCount, actual);
1787 >        WriteMacInt32(pb + ioActCount, actual >= 0 ? actual : 0);
1788          uint32 pos = lseek(fd, 0, SEEK_CUR);
1789          WriteMacInt32(fcb + fcbCrPs, pos);
1790          WriteMacInt32(pb + ioPosOffset, pos);
1791 <        if (actual != ReadMacInt32(pb + ioReqCount))
1792 <                if (errno)
1770 <                        return errno2oserr();
1771 <                else
1772 <                        return eofErr;
1791 >        if (actual != (ssize_t)ReadMacInt32(pb + ioReqCount))
1792 >                return actual < 0 ? read_err : eofErr;
1793          else
1794                  return noErr;
1795   }
# Line 1779 | Line 1799 | static int16 fs_write(uint32 pb)
1799   {
1800          D(bug(" fs_write(%08lx), refNum %d, buffer %p, count %d, posMode %d, posOffset %d\n", pb, ReadMacInt16(pb + ioRefNum), ReadMacInt32(pb + ioBuffer), ReadMacInt32(pb + ioReqCount), ReadMacInt16(pb + ioPosMode), ReadMacInt32(pb + ioPosOffset)));
1801  
1802 +        // Check parameters
1803 +        if ((int32)ReadMacInt32(pb + ioReqCount) < 0)
1804 +                return paramErr;
1805 +
1806          // Find FCB and fd for file
1807          uint32 fcb = find_fcb(ReadMacInt16(pb + ioRefNum));
1808          if (fcb == 0)
# Line 1810 | Line 1834 | static int16 fs_write(uint32 pb)
1834          }
1835  
1836          // Write
1837 <        size_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1837 >        ssize_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1838 >        int16 write_err = errno2oserr();
1839          D(bug("  actual %d\n", actual));
1840 <        WriteMacInt32(pb + ioActCount, actual);
1840 >        WriteMacInt32(pb + ioActCount, actual >= 0 ? actual : 0);
1841          uint32 pos = lseek(fd, 0, SEEK_CUR);
1842          WriteMacInt32(fcb + fcbCrPs, pos);
1843          WriteMacInt32(pb + ioPosOffset, pos);
1844 <        if (actual != ReadMacInt32(pb + ioReqCount))
1845 <                return errno2oserr();
1844 >        if (actual != (ssize_t)ReadMacInt32(pb + ioReqCount))
1845 >                return write_err;
1846          else
1847                  return noErr;
1848   }
# Line 1825 | Line 1850 | static int16 fs_write(uint32 pb)
1850   // Create file
1851   static int16 fs_create(uint32 pb, uint32 dirID)
1852   {
1853 <        D(bug(" fs_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID));
1853 >        D(bug(" fs_create(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID));
1854  
1855          // Find FSItem for given file
1856          FSItem *fs_item;
# Line 1838 | Line 1863 | static int16 fs_create(uint32 pb, uint32
1863                  return dupFNErr;
1864  
1865          // Create file
1866 <        int fd = creat(full_path, 0664);
1866 >        int fd = creat(full_path, 0666);
1867          if (fd < 0)
1868                  return errno2oserr();
1869          else {
# Line 1850 | Line 1875 | static int16 fs_create(uint32 pb, uint32
1875   // Create directory
1876   static int16 fs_dir_create(uint32 pb)
1877   {
1878 <        D(bug(" fs_dir_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioDirID)));
1878 >        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)));
1879  
1880          // Find FSItem for given directory
1881          FSItem *fs_item;
# Line 1863 | Line 1888 | static int16 fs_dir_create(uint32 pb)
1888                  return dupFNErr;
1889  
1890          // Create directory
1891 <        if (mkdir(full_path, 0775) < 0)
1891 >        if (mkdir(full_path, 0777) < 0)
1892                  return errno2oserr();
1893          else {
1894                  WriteMacInt32(pb + ioDirID, fs_item->id);
# Line 1874 | Line 1899 | static int16 fs_dir_create(uint32 pb)
1899   // Delete file/directory
1900   static int16 fs_delete(uint32 pb, uint32 dirID)
1901   {
1902 <        D(bug(" fs_delete(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID));
1902 >        D(bug(" fs_delete(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID));
1903  
1904          // Find FSItem for given file/dir
1905          FSItem *fs_item;
# Line 1883 | Line 1908 | static int16 fs_delete(uint32 pb, uint32
1908                  return result;
1909  
1910          // Delete file
1911 <        if (remove(full_path) < 0) {
1912 <                int16 err = errno2oserr();
1913 <                if (errno == EISDIR) {  // Workaround for BeOS bug
1889 <                        if (rmdir(full_path) < 0)
1890 <                                return errno2oserr();
1891 <                        else
1892 <                                return noErr;
1893 <                } else
1894 <                        return err;
1895 <        } else
1911 >        if (!extfs_remove(full_path))
1912 >                return errno2oserr();
1913 >        else
1914                  return noErr;
1915   }
1916  
1917   // Rename file/directory
1918   static int16 fs_rename(uint32 pb, uint32 dirID)
1919   {
1920 <        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))));
1920 >        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)));
1921  
1922          // Find path of given file/dir
1923          FSItem *fs_item;
# Line 1912 | Line 1930 | static int16 fs_rename(uint32 pb, uint32
1930          strcpy(old_path, full_path);
1931  
1932          // Find path for new name
1933 <        uint8 new_pb[SIZEOF_IOParam];
1934 <        memcpy(new_pb, Mac2HostAddr(pb), SIZEOF_IOParam);
1917 <        WriteMacInt32((uint32)new_pb + ioNamePtr, ReadMacInt32(pb + ioMisc));
1933 >        Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam);
1934 >        WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioMisc));
1935          FSItem *new_item;
1936 <        result = get_item_and_path((uint32)new_pb, dirID, new_item);
1936 >        result = get_item_and_path(fs_data + fsPB, dirID, new_item);
1937          if (result != noErr)
1938                  return result;
1939  
# Line 1926 | Line 1943 | static int16 fs_rename(uint32 pb, uint32
1943  
1944          // Rename item
1945          D(bug("  renaming %s -> %s\n", old_path, full_path));
1946 <        if (rename(old_path, full_path) < 0)
1946 >        if (!extfs_rename(old_path, full_path))
1947                  return errno2oserr();
1948          else {
1949                  // The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems
1950 +                swap_parent_ids(fs_item->id, new_item->id);
1951                  uint32 t = fs_item->id;
1952                  fs_item->id = new_item->id;
1953                  new_item->id = t;
# Line 1940 | Line 1958 | static int16 fs_rename(uint32 pb, uint32
1958   // Move file/directory (CMovePBRec)
1959   static int16 fs_cat_move(uint32 pb)
1960   {
1961 <        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)));
1961 >        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)));
1962  
1963          // Find path of given file/dir
1964          FSItem *fs_item;
# Line 1953 | Line 1971 | static int16 fs_cat_move(uint32 pb)
1971          strcpy(old_path, full_path);
1972  
1973          // Find path for new directory
1974 <        uint8 new_pb[SIZEOF_IOParam];
1975 <        memcpy(new_pb, Mac2HostAddr(pb), SIZEOF_IOParam);
1958 <        WriteMacInt32((uint32)new_pb + ioNamePtr, ReadMacInt32(pb + ioNewName));
1974 >        Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam);
1975 >        WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioNewName));
1976          FSItem *new_dir_item;
1977 <        result = get_item_and_path((uint32)new_pb, ReadMacInt32(pb + ioNewDirID), new_dir_item);
1977 >        result = get_item_and_path(fs_data + fsPB, ReadMacInt32(pb + ioNewDirID), new_dir_item);
1978          if (result != noErr)
1979                  return result;
1980  
1981          // Append old file/dir name
1982 <        add_path_component(fs_item->name);
1982 >        add_path_comp(fs_item->name);
1983  
1984          // Does the new name already exist?
1985          if (access(full_path, F_OK) == 0)
# Line 1970 | Line 1987 | static int16 fs_cat_move(uint32 pb)
1987  
1988          // Move item
1989          D(bug("  moving %s -> %s\n", old_path, full_path));
1990 <        if (rename(old_path, full_path) < 0)
1990 >        if (!extfs_rename(old_path, full_path))
1991                  return errno2oserr();
1992          else {
1993                  // The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems
1994                  FSItem *new_item = find_fsitem(fs_item->name, new_dir_item);
1995                  if (new_item) {
1996 +                        swap_parent_ids(fs_item->id, new_item->id);
1997                          uint32 t = fs_item->id;
1998                          fs_item->id = new_item->id;
1999                          new_item->id = t;
# Line 1987 | Line 2005 | static int16 fs_cat_move(uint32 pb)
2005   // Open working directory (WDParam)
2006   static int16 fs_open_wd(uint32 pb)
2007   {
2008 <        D(bug(" fs_open_wd(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID)));
2008 >        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)));
2009          M68kRegisters r;
2010  
2011          // Allocate WDCB
2012          D(bug("  allocating WDCB\n"));
2013          r.a[0] = pb;
2014          Execute68k(fs_data + fsAllocateWDCB, &r);
2015 <        D(bug("  UTAllocateWDCB returned %d\n", r.d[0]));
2016 <        return r.d[0];
2015 >        D(bug("  UTAllocateWDCB returned %d, refNum is %d\n", r.d[0], ReadMacInt16(pb + ioVRefNum)));
2016 >        return (int16)r.d[0];
2017   }
2018  
2019   // Close working directory (WDParam)
# Line 2009 | Line 2027 | static int16 fs_close_wd(uint32 pb)
2027          r.d[0] = ReadMacInt16(pb + ioVRefNum);
2028          Execute68k(fs_data + fsReleaseWDCB, &r);
2029          D(bug("  UTReleaseWDCB returned %d\n", r.d[0]));
2030 <        return r.d[0];
2030 >        return (int16)r.d[0];
2031   }
2032  
2033   // Query information about working directory (WDParam)
# Line 2023 | Line 2041 | static int16 fs_get_wd_info(uint32 pb, u
2041                  WriteMacInt32(pb + ioWDProcID, 0);
2042                  WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(vcb + vcbVRefNum));
2043                  if (ReadMacInt32(pb + ioNamePtr))
2044 <                        memcpy(Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), Mac2HostAddr(vcb + vcbVN), 28);
2044 >                        Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), vcb + vcbVN, 28);
2045                  WriteMacInt32(pb + ioWDDirID, ROOT_ID);
2046                  return noErr;
2047          }
# Line 2038 | Line 2056 | static int16 fs_get_wd_info(uint32 pb, u
2056          uint32 wdcb = ReadMacInt32(fs_data + fsReturn);
2057          D(bug("  UTResolveWDCB() returned %d, dirID %d\n", r.d[0], ReadMacInt32(wdcb + wdDirID)));
2058          if (r.d[0] & 0xffff)
2059 <                return r.d[0];
2059 >                return (int16)r.d[0];
2060  
2061          // Return information
2062 <        WriteMacInt16(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID));
2062 >        WriteMacInt32(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID));
2063          WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(ReadMacInt32(wdcb + wdVCBPtr) + vcbVRefNum));
2064          if (ReadMacInt32(pb + ioNamePtr))
2065 <                memcpy(Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), Mac2HostAddr(ReadMacInt32(wdcb + wdVCBPtr) + vcbVN), 28);
2065 >                Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), ReadMacInt32(wdcb + wdVCBPtr) + vcbVN, 28);
2066          WriteMacInt32(pb + ioWDDirID, ReadMacInt32(wdcb + wdDirID));
2067          return noErr;
2068   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines