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.9 by cebix, 1999-11-03T10:56:14Z vs.
Revision 1.34 by gbeauche, 2007-11-03T09:59:39Z

# 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-2005 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 + #if defined __APPLE__ && defined __MACH__
52 + #include <sys/attr.h>
53 + #endif
54 +
55   #include "cpu_emulation.h"
49 #include "macos_util.h"
56   #include "emul_op.h"
57   #include "main.h"
58   #include "disk.h"
# Line 55 | Line 61
61   #include "extfs.h"
62   #include "extfs_defs.h"
63  
64 + #ifdef WIN32
65 + # include "posix_emu.h"
66 + #endif
67 +
68   #define DEBUG 0
69   #include "debug.h"
70  
# Line 65 | Line 75 | enum {
75          fsHFSProcStub = 6,
76          fsDrvStatus = 12,                               // Drive Status record
77          fsFSD = 42,                                             // File system descriptor
78 <        fsPB = 238,                                             // IOParam (for mounting and renaming)
78 >        fsPB = 238,                                             // IOParam (for mounting and renaming), also used for temporary storage
79          fsVMI = 288,                                    // VoumeMountInfoHeader (for mounting)
80          fsParseRec = 296,                               // ParsePathRec struct
81          fsReturn = 306,                                 // Area for return data of 68k routines
# Line 101 | Line 111 | static bool ready = false;
111   static struct stat root_stat;
112  
113   // File system ID/media type
114 < const int16 MY_FSID = 'ba';
115 < const uint32 MY_MEDIA_TYPE = 'basi';
114 > const int16 MY_FSID = EMULATOR_ID_2;
115 > const uint32 MY_MEDIA_TYPE = EMULATOR_ID_4;
116  
117   // CNID of root and root's parent
118   const uint32 ROOT_ID = 2;
# Line 111 | Line 121 | const uint32 ROOT_PARENT_ID = 1;
121   // File system stack size
122   const int STACK_SIZE = 0x10000;
123  
124 + // Allocation block and clump size as reported to MacOS (these are of course
125 + // not the real values and have no meaning on the host OS)
126 + const int AL_BLK_SIZE = 0x4000;
127 + const int CLUMP_SIZE = 0x4000;
128 +
129   // Drive number of our pseudo-drive
130   static int drive_number;
131  
# Line 143 | Line 158 | struct FSItem {
158          uint32 id;                              // CNID of this file/dir
159          uint32 parent_id;               // CNID of parent file/dir
160          FSItem *parent;                 // Pointer to parent
161 <        char name[32];                  // Object name (C string)
161 >        char *name;                             // Object name (C string) - Host OS
162 >        char guest_name[32];    // Object name (C string) - Guest OS
163          time_t mtime;                   // Modification time for get_cat_info caching
164          int cache_dircount;             // Cached number of files in directory
165   };
# Line 154 | Line 170 | static uint32 next_cnid = fsUsrCNID;   //
170  
171  
172   /*
173 + *  Get object creation time
174 + */
175 +
176 + #if defined __APPLE__ && defined __MACH__
177 + struct crtimebuf {
178 +        unsigned long length;
179 +        struct timespec crtime;
180 + };
181 +
182 + static uint32 do_get_creation_time(const char *path)
183 + {
184 +        struct attrlist attr;
185 +        memset(&attr, 0, sizeof(attr));
186 +        attr.bitmapcount = ATTR_BIT_MAP_COUNT;
187 +        attr.commonattr = ATTR_CMN_CRTIME;
188 +
189 +        crtimebuf buf;
190 +        if (getattrlist(path, &attr, &buf, sizeof(buf), FSOPT_NOFOLLOW) < 0)
191 +                return 0;
192 +        return TimeToMacTime(buf.crtime.tv_sec);
193 + }
194 +
195 + static uint32 get_creation_time(const char *path)
196 + {
197 +        if (path == NULL)
198 +                return 0;
199 +        if (path == RootPath) {
200 +                static uint32 root_crtime = UINT_MAX;
201 +                if (root_crtime == UINT_MAX)
202 +                        root_crtime = do_get_creation_time(path);
203 +                return root_crtime;
204 +        }
205 +        return do_get_creation_time(path);
206 + }
207 + #endif
208 +
209 +
210 + /*
211   *  Find FSItem for given CNID
212   */
213  
# Line 168 | Line 222 | static FSItem *find_fsitem_by_id(uint32
222          return NULL;
223   }
224  
225 + /*
226 + *  Create FSItem with the given parameters
227 + */
228 +
229 + static FSItem *create_fsitem(const char *name, const char *guest_name, FSItem *parent)
230 + {
231 +        FSItem *p = new FSItem;
232 +        last_fs_item->next = p;
233 +        p->next = NULL;
234 +        last_fs_item = p;
235 +        p->id = next_cnid++;
236 +        p->parent_id = parent->id;
237 +        p->parent = parent;
238 +        p->name = new char[strlen(name) + 1];
239 +        strcpy(p->name, name);
240 +        strncpy(p->guest_name, guest_name, 31);
241 +        p->guest_name[31] = 0;
242 +        p->mtime = 0;
243 +        return p;
244 + }
245  
246   /*
247   *  Find FSItem for given name and parent, construct new FSItem if not found
# Line 183 | Line 257 | static FSItem *find_fsitem(const char *n
257          }
258  
259          // Not found, construct new FSItem
260 <        p = new FSItem;
187 <        last_fs_item->next = p;
188 <        p->next = NULL;
189 <        last_fs_item = p;
190 <        p->id = next_cnid++;
191 <        p->parent_id = parent->id;
192 <        p->parent = parent;
193 <        strncpy(p->name, name, 31);
194 <        p->name[31] = 0;
195 <        p->mtime = 0;
196 <        return p;
260 >        return create_fsitem(name, host_encoding_to_macroman(name), parent);
261   }
262  
263 + /*
264 + *  Find FSItem for given guest_name and parent, construct new FSItem if not found
265 + */
266 +
267 + static FSItem *find_fsitem_guest(const char *guest_name, FSItem *parent)
268 + {
269 +        FSItem *p = first_fs_item;
270 +        while (p) {
271 +                if (p->parent == parent && !strcmp(p->guest_name, guest_name))
272 +                        return p;
273 +                p = p->next;
274 +        }
275 +
276 +        // Not found, construct new FSItem
277 +        return create_fsitem(macroman_to_host_encoding(guest_name), guest_name, parent);
278 + }
279  
280   /*
281   *  Get full path (->full_path) for given FSItem
# Line 223 | Line 303 | static void get_path_for_fsitem(FSItem *
303  
304  
305   /*
306 + *  Exchange parent CNIDs in all FSItems
307 + */
308 +
309 + static void swap_parent_ids(uint32 parent1, uint32 parent2)
310 + {
311 +        FSItem *p = first_fs_item;
312 +        while (p) {
313 +                if (p->parent_id == parent1)
314 +                        p->parent_id = parent2;
315 +                else if (p->parent_id == parent2)
316 +                        p->parent_id = parent1;
317 +                p = p->next;
318 +        }
319 + }
320 +
321 +
322 + /*
323   *  String handling functions
324   */
325  
# Line 240 | Line 337 | static void cstr2pstr(char *dst, const c
337          *dst++ = strlen(src);
338          char c;
339          while ((c = *src++) != 0) {
340 +                // Note: we are converting host ':' characters to Mac '/' characters here
341 +                // '/' is not a path separator as this function is only used on object names
342                  if (c == ':')
343                          c = '/';
344                  *dst++ = c;
345          }
346   }
347  
249 // Convert pascal string to C string
250 static void pstr2cstr(char *dst, const char *src)
251 {
252        int size = *src++;
253        while (size--) {
254                char c = *src++;
255                if (c == '/')
256                        c = ':';
257                *dst++ = c;
258        }
259        *dst = 0;
260 }
261
348   // Convert string (no length byte) to C string, length given separately
349   static void strn2cstr(char *dst, const char *src, int size)
350   {
351          while (size--) {
352                  char c = *src++;
353 +                // Note: we are converting Mac '/' characters to host ':' characters here
354 +                // '/' is not a path separator as this function is only used on object names
355                  if (c == '/')
356                          c = ':';
357                  *dst++ = c;
# Line 328 | Line 416 | void ExtFSInit(void)
416          p->id = ROOT_PARENT_ID;
417          p->parent_id = 0;
418          p->parent = NULL;
419 +        p->name = new char[1];
420          p->name[0] = 0;
421 +        p->guest_name[0] = 0;
422  
423          // Create root FSItem
424          p = new FSItem;
# Line 338 | Line 428 | void ExtFSInit(void)
428          p->id = ROOT_ID;
429          p->parent_id = ROOT_PARENT_ID;
430          p->parent = first_fs_item;
431 <        strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32);
431 >        const char *volume_name = GetString(STR_EXTFS_VOLUME_NAME);
432 >        p->name = new char[strlen(volume_name) + 1];
433 >        strcpy(p->name, volume_name);
434 >        strncpy(p->guest_name, host_encoding_to_macroman(p->name), 32);
435 >        p->guest_name[31] = 0;
436  
437          // Find path for root
438          if ((RootPath = PrefsFindString("extfs")) != NULL) {
# Line 361 | Line 455 | void ExtFSExit(void)
455          FSItem *p = first_fs_item, *next;
456          while (p) {
457                  next = p->next;
458 +                delete[] p->name;
459                  delete p;
460                  p = next;
461          }
# Line 387 | Line 482 | void InstallExtFS(void)
482          // FSM present?
483          r.d[0] = gestaltFSAttr;
484          Execute68kTrap(0xa1ad, &r);     // Gestalt()
485 <        D(bug("FSAttr %ld, %08lx\n", r.d[0], r.a[0]));
485 >        D(bug("FSAttr %d, %08x\n", r.d[0], r.a[0]));
486          if ((r.d[0] & 0xffff) || !(r.a[0] & (1 << gestaltHasFileSystemManager))) {
487                  printf("WARNING: No FSM present, disabling ExtFS\n");
488                  return;
# Line 396 | Line 491 | void InstallExtFS(void)
491          // Yes, version >=1.2?
492          r.d[0] = gestaltFSMVersion;
493          Execute68kTrap(0xa1ad, &r);     // Gestalt()
494 <        D(bug("FSMVersion %ld, %08lx\n", r.d[0], r.a[0]));
494 >        D(bug("FSMVersion %d, %08x\n", r.d[0], r.a[0]));
495          if ((r.d[0] & 0xffff) || (r.a[0] < 0x0120)) {
496                  printf("WARNING: FSM <1.2 found, disabling ExtFS\n");
497                  return;
# Line 666 | Line 761 | int16 ExtFSComm(uint16 message, uint32 p
761                  }
762  
763                  case ffsIDDiskMessage: {                // Check if volume is handled by our FS
764 <                        if (ReadMacInt16(paramBlock + ioVRefNum) == drive_number)
764 >                        if ((int16)ReadMacInt16(paramBlock + ioVRefNum) == drive_number)
765                                  return noErr;
766                          else
767                                  return extFSErr;
# Line 710 | Line 805 | static int16 get_current_dir(uint32 pb,
805          if (no_vol_name)
806                  WriteMacInt32(pb + ioNamePtr, name_ptr);
807          int16 status = ReadMacInt16(fs_data + fsReturn);
713        int16 more_matches = ReadMacInt16(fs_data + fsReturn + 2);
714        int16 vRefNum = ReadMacInt16(fs_data + fsReturn + 4);
715        uint32 vcb = ReadMacInt32(fs_data + fsReturn + 6);
808          D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
809 <        result = r.d[0] & 0xffff;
809 >        result = (int16)(r.d[0] & 0xffff);
810  
811          if (result == noErr) {
812                  switch (status) {
# Line 739 | Line 831 | static int16 get_current_dir(uint32 pb,
831                                          Execute68k(fs_data + fsResolveWDCB, &r);
832                                          uint32 wdcb = ReadMacInt32(fs_data + fsReturn);
833                                          D(bug("  UTResolveWDCB() returned %d, dirID %d\n", r.d[0], ReadMacInt32(wdcb + wdDirID)));
834 <                                        result = r.d[0] & 0xffff;
834 >                                        result = (int16)(r.d[0] & 0xffff);
835                                          if (result == noErr)
836                                                  current_dir = ReadMacInt32(wdcb + wdDirID);
837                                  }
# Line 755 | Line 847 | static int16 get_current_dir(uint32 pb,
847                                          r.a[0] = wdpb;
848                                          Execute68k(fs_data + fsGetDefaultVol, &r);
849                                          D(bug("  UTGetDefaultVol() returned %d, dirID %d\n", r.d[0], ReadMacInt32(wdpb + ioWDDirID)));
850 <                                        result = r.d[0] & 0xffff;
850 >                                        result = (int16)(r.d[0] & 0xffff);
851                                          if (result == noErr)
852                                                  current_dir = ReadMacInt32(wdpb + ioWDDirID);
853                                  }
# Line 781 | Line 873 | static int16 get_path_component_name(uin
873          r.a[0] = rec;
874          Execute68k(fs_data + fsGetPathComponentName, &r);
875   //      D(bug("  UTGetPathComponentName returned %d\n", r.d[0]));
876 <        return r.d[0] & 0xffff;
876 >        return (int16)(r.d[0] & 0xffff);
877   }
878  
879  
# Line 817 | Line 909 | static int16 get_item_and_path(uint32 pb
909          r.a[1] = ReadMacInt32(parseRec + ppNamePtr);
910          Execute68k(fs_data + fsParsePathname, &r);
911          D(bug("  UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset)));
912 <        result = r.d[0] & 0xffff;
912 >        result = (int16)(r.d[0] & 0xffff);
913          if (result == noErr) {
914  
915                  // Check for leading delimiter of the partial pathname
# Line 852 | Line 944 | static int16 get_item_and_path(uint32 pb
944                                                  char name[32];
945                                                  strn2cstr(name, (char *)Mac2HostAddr(ReadMacInt32(parseRec + ppNamePtr)) + ReadMacInt16(parseRec + ppStartOffset) + 1, ReadMacInt16(parseRec + ppComponentLength));
946                                                  D(bug("  entering %s\n", name));
947 <                                                p = find_fsitem(name, p);
947 >                                                p = find_fsitem_guest(name, p);
948                                                  current_dir = p->id;
949  
950                                                  // startOffset = start of next component
# Line 875 | Line 967 | static int16 get_item_and_path(uint32 pb
967                                          char name[32];
968                                          strn2cstr(name, (char *)Mac2HostAddr(ReadMacInt32(parseRec + ppNamePtr)) + ReadMacInt16(parseRec + ppStartOffset) + 1, ReadMacInt16(parseRec + ppComponentLength));
969                                          D(bug("  object is %s\n", name));
970 <                                        item = find_fsitem(name, p);
970 >                                        item = find_fsitem_guest(name, p);
971                                  }
972                          }
973                  }
# Line 930 | Line 1022 | static uint32 find_fcb(int16 refNum)
1022   static int16 fs_mount_vol(uint32 pb)
1023   {
1024          D(bug(" fs_mount_vol(%08lx), vRefNum %d\n", pb, ReadMacInt16(pb + ioVRefNum)));
1025 <        if (ReadMacInt16(pb + ioVRefNum) == drive_number)
1025 >        if ((int16)ReadMacInt16(pb + ioVRefNum) == drive_number)
1026                  return noErr;
1027          else
1028                  return extFSErr;
# Line 947 | Line 1039 | static int16 fs_volume_mount(uint32 pb)
1039          r.a[0] = fs_data + fsReturn;
1040          r.a[1] = fs_data + fsReturn + 2;
1041          Execute68k(fs_data + fsAllocateVCB, &r);
1042 + #if DEBUG
1043          uint16 sysVCBLength = ReadMacInt16(fs_data + fsReturn);
1044 + #endif
1045          uint32 vcb = ReadMacInt32(fs_data + fsReturn + 2);
1046          D(bug("  UTAllocateVCB() returned %d, vcb %08lx, size %d\n", r.d[0], vcb, sysVCBLength));
1047          if (r.d[0] & 0xffff)
1048 <                return r.d[0];
1048 >                return (int16)r.d[0];
1049  
1050          // Init VCB
1051          WriteMacInt16(vcb + vcbSigWord, 0x4244);
1052 < #ifdef __BEOS__
1053 <        WriteMacInt32(vcb + vcbCrDate, root_stat.st_crtime + TIME_OFFSET);
1052 > #if defined(__BEOS__) || defined(WIN32)
1053 >        WriteMacInt32(vcb + vcbCrDate, TimeToMacTime(root_stat.st_crtime));
1054 > #elif defined __APPLE__ && defined __MACH__
1055 >        WriteMacInt32(vcb + vcbCrDate, get_creation_time(RootPath));
1056   #else
1057          WriteMacInt32(vcb + vcbCrDate, 0);
1058   #endif
1059 <        WriteMacInt32(vcb + vcbLsMod, root_stat.st_mtime + TIME_OFFSET);
1059 >        WriteMacInt32(vcb + vcbLsMod, TimeToMacTime(root_stat.st_mtime));
1060          WriteMacInt32(vcb + vcbVolBkUp, 0);
1061          WriteMacInt16(vcb + vcbNmFls, 1);                       //!!
1062          WriteMacInt16(vcb + vcbNmRtDirs, 1);            //!!
1063          WriteMacInt16(vcb + vcbNmAlBlks, 0xffff);       //!!
1064 <        WriteMacInt32(vcb + vcbAlBlkSiz, 1024);
1065 <        WriteMacInt32(vcb + vcbClpSiz, 1024);
1064 >        WriteMacInt32(vcb + vcbAlBlkSiz, AL_BLK_SIZE);
1065 >        WriteMacInt32(vcb + vcbClpSiz, CLUMP_SIZE);
1066          WriteMacInt32(vcb + vcbNxtCNID, next_cnid);
1067          WriteMacInt16(vcb + vcbFreeBks, 0xffff);        //!!
1068          Host2Mac_memcpy(vcb + vcbVN, VOLUME_NAME, 28);
# Line 980 | Line 1076 | static int16 fs_volume_mount(uint32 pb)
1076          r.a[0] = fs_data + fsReturn;
1077          r.a[1] = vcb;
1078          Execute68k(fs_data + fsAddNewVCB, &r);
1079 <        int16 vRefNum = ReadMacInt32(fs_data + fsReturn);
1079 >        int16 vRefNum = (int16)ReadMacInt32(fs_data + fsReturn);
1080          D(bug("  UTAddNewVCB() returned %d, vRefNum %d\n", r.d[0], vRefNum));
1081          if (r.d[0] & 0xffff)
1082 <                return r.d[0];
1082 >                return (int16)r.d[0];
1083  
1084          // Post diskInsertEvent
1085          D(bug("  posting diskInsertEvent\n"));
# Line 1007 | Line 1103 | static int16 fs_unmount_vol(uint32 vcb)
1103          r.a[0] = vcb;
1104          Execute68k(fs_data + fsDisposeVCB, &r);
1105          D(bug("  UTDisposeVCB() returned %d\n", r.d[0]));
1106 <        return r.d[0];
1106 >        return (int16)r.d[0];
1107   }
1108  
1109   // Get information about a volume (HVolumeParam)
# Line 1018 | Line 1114 | static int16 fs_get_vol_info(uint32 pb,
1114          // Fill in struct
1115          if (ReadMacInt32(pb + ioNamePtr))
1116                  pstrcpy((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), VOLUME_NAME);
1117 < #ifdef __BEOS__
1118 <        WriteMacInt32(pb + ioVCrDate, root_stat.st_crtime + TIME_OFFSET);
1117 > #if defined(__BEOS__) || defined(WIN32)
1118 >        WriteMacInt32(pb + ioVCrDate, TimeToMacTime(root_stat.st_crtime));
1119 > #elif defined __APPLE__ && defined __MACH__
1120 >        WriteMacInt32(pb + ioVCrDate, get_creation_time(RootPath));
1121   #else
1122          WriteMacInt32(pb + ioVCrDate, 0);
1123   #endif
1124 <        WriteMacInt32(pb + ioVLsMod, root_stat.st_mtime + TIME_OFFSET);
1124 >        WriteMacInt32(pb + ioVLsMod, TimeToMacTime(root_stat.st_mtime));
1125          WriteMacInt16(pb + ioVAtrb, 0);
1126          WriteMacInt16(pb + ioVNmFls, 1);                        //!!
1127          WriteMacInt16(pb + ioVBitMap, 0);
1128          WriteMacInt16(pb + ioAllocPtr, 0);
1129          WriteMacInt16(pb + ioVNmAlBlks, 0xffff);        //!!
1130 <        WriteMacInt32(pb + ioVAlBlkSiz, 1024);
1131 <        WriteMacInt32(pb + ioVClpSiz, 1024);
1130 >        WriteMacInt32(pb + ioVAlBlkSiz, AL_BLK_SIZE);
1131 >        WriteMacInt32(pb + ioVClpSiz, CLUMP_SIZE);
1132          WriteMacInt16(pb + ioAlBlSt, 0);
1133          WriteMacInt32(pb + ioVNxtCNID, next_cnid);
1134          WriteMacInt16(pb + ioVFrBlk, 0xffff);           //!!
# Line 1063 | Line 1161 | static int16 fs_get_vol_parms(uint32 pb)
1161   //      D(bug(" fs_get_vol_parms(%08lx)\n", pb));
1162  
1163          // Return parameter block
1066        uint8 vol[SIZEOF_GetVolParmsInfoBuffer];
1067        WriteMacInt16((uint32)vol + vMVersion, 2);
1068        WriteMacInt32((uint32)vol + vMAttrib, kNoMiniFndr | kNoVNEdit | kNoLclSync | kTrshOffLine | kNoSwitchTo | kNoBootBlks | kNoSysDir | kHasExtFSVol);
1069        WriteMacInt32((uint32)vol + vMLocalHand, 0);
1070        WriteMacInt32((uint32)vol + vMServerAdr, 0);
1071        WriteMacInt32((uint32)vol + vMVolumeGrade, 0);
1072        WriteMacInt16((uint32)vol + vMForeignPrivID, 0);
1164          uint32 actual = ReadMacInt32(pb + ioReqCount);
1165 <        if (actual > sizeof(vol))
1166 <                actual = sizeof(vol);
1076 <        Host2Mac_memcpy(ReadMacInt32(pb + ioBuffer), vol, actual);
1165 >        if (actual > SIZEOF_GetVolParmsInfoBuffer)
1166 >                actual = SIZEOF_GetVolParmsInfoBuffer;
1167          WriteMacInt32(pb + ioActCount, actual);
1168 +        uint32 p = ReadMacInt32(pb + ioBuffer);
1169 +        if (actual > vMVersion) WriteMacInt16(p + vMVersion, 2);
1170 +        if (actual > vMAttrib) WriteMacInt32(p + vMAttrib, kNoMiniFndr | kNoVNEdit | kNoLclSync | kTrshOffLine | kNoSwitchTo | kNoBootBlks | kNoSysDir | kHasExtFSVol);
1171 +        if (actual > vMLocalHand) WriteMacInt32(p + vMLocalHand, 0);
1172 +        if (actual > vMServerAdr) WriteMacInt32(p + vMServerAdr, 0);
1173 +        if (actual > vMVolumeGrade) WriteMacInt32(p + vMVolumeGrade, 0);
1174 +        if (actual > vMForeignPrivID) WriteMacInt16(p + vMForeignPrivID, 0);
1175          return noErr;
1176   }
1177  
# Line 1089 | Line 1186 | static int16 fs_get_vol(uint32 pb)
1186          r.a[0] = pb;
1187          Execute68k(fs_data + fsGetDefaultVol, &r);
1188          D(bug("  UTGetDefaultVol() returned %d\n", r.d[0]));
1189 <        return r.d[0];
1189 >        return (int16)r.d[0];
1190   }
1191  
1192   // Set default volume (WDParam)
# Line 1145 | Line 1242 | static int16 fs_set_vol(uint32 pb, bool
1242          r.d[2] = refNum;
1243          Execute68k(fs_data + fsSetDefaultVol, &r);
1244          D(bug("  UTSetDefaultVol() returned %d\n", r.d[0]));
1245 <        return r.d[0];
1245 >        return (int16)r.d[0];
1246   }
1247  
1248   // Query file attributes (HFileParam)
# Line 1187 | Line 1284 | read_next_de:
1284                                  return fnfErr;
1285                          }
1286                          if (de->d_name[0] == '.')
1287 <                                goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1287 >                                goto read_next_de;      // Suppress names beginning with '.' (MacOS could interpret these as driver names)
1288                          //!! suppress directories
1289                  }
1290                  add_path_comp(de->d_name);
# Line 1206 | Line 1303 | read_next_de:
1303  
1304          // Fill in struct from fs_item and stats
1305          if (ReadMacInt32(pb + ioNamePtr))
1306 <                cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->name);
1306 >                cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->guest_name);
1307          WriteMacInt16(pb + ioFRefNum, 0);
1308          WriteMacInt8(pb + ioFlAttrib, access(full_path, W_OK) == 0 ? 0 : faLocked);
1309          WriteMacInt32(pb + ioDirID, fs_item->id);
1310  
1311 < #ifdef __BEOS__
1312 <        WriteMacInt32(pb + ioFlCrDat, st.st_crtime + TIME_OFFSET);
1311 > #if defined(__BEOS__) || defined(WIN32)
1312 >        WriteMacInt32(pb + ioFlCrDat, TimeToMacTime(st.st_crtime));
1313 > #elif defined __APPLE__ && defined __MACH__
1314 >        WriteMacInt32(pb + ioFlCrDat, get_creation_time(full_path));
1315   #else
1316          WriteMacInt32(pb + ioFlCrDat, 0);
1317   #endif
1318 <        WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET);
1318 >        WriteMacInt32(pb + ioFlMdDat, TimeToMacTime(st.st_mtime));
1319  
1320 <        Mac_memset(pb + ioFlFndrInfo, 0, SIZEOF_FInfo);
1222 <        uint32 type, creator;   // pb may point to kernel space, but stack is switched
1223 <        get_finder_type(full_path, type, creator);
1224 <        WriteMacInt32(pb + ioFlFndrInfo + fdType, type);
1225 <        WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator);
1226 <        uint16 fflags;
1227 <        get_finder_flags(full_path, fflags);
1228 <        WriteMacInt16(pb + ioFlFndrInfo + fdFlags, fflags);
1320 >        get_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0, false);
1321  
1322          WriteMacInt16(pb + ioFlStBlk, 0);
1323          WriteMacInt32(pb + ioFlLgLen, st.st_size);
1324 <        WriteMacInt32(pb + ioFlPyLen, (st.st_size + 1023) & ~1023);
1324 >        WriteMacInt32(pb + ioFlPyLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1325          WriteMacInt16(pb + ioFlRStBlk, 0);
1326          uint32 rf_size = get_rfork_size(full_path);
1327          WriteMacInt32(pb + ioFlRLgLen, rf_size);
1328 <        WriteMacInt32(pb + ioFlRPyLen, (rf_size + 1023) & ~1023);
1328 >        WriteMacInt32(pb + ioFlRPyLen, (rf_size | (AL_BLK_SIZE - 1)) + 1);
1329  
1330          if (hfs) {
1331                  WriteMacInt32(pb + ioFlBkDat, 0);
1240                Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo);
1332                  WriteMacInt32(pb + ioFlParID, fs_item->parent_id);
1333                  WriteMacInt32(pb + ioFlClpSiz, 0);
1334          }
# Line 1262 | Line 1353 | static int16 fs_set_file_info(uint32 pb,
1353          if (S_ISDIR(st.st_mode))
1354                  return fnfErr;
1355  
1356 <        // Set attributes
1357 <        set_finder_type(full_path, ReadMacInt32(pb + ioFlFndrInfo + fdType), ReadMacInt32(pb + ioFlFndrInfo + fdCreator));
1358 <        set_finder_flags(full_path, ReadMacInt16(pb + ioFlFndrInfo + fdFlags));
1356 >        // Set Finder info
1357 >        set_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0, false);
1358 >
1359          //!! times
1360          return noErr;
1361   }
# Line 1316 | Line 1407 | read_next_de:
1407                                  return fnfErr;
1408                          }
1409                          if (de->d_name[0] == '.')
1410 <                                goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1410 >                                goto read_next_de;      // Suppress names beginning with '.' (MacOS could interpret these as driver names)
1411                  }
1412                  add_path_comp(de->d_name);
1413  
# Line 1335 | Line 1426 | read_next_de:
1426  
1427          // Fill in struct from fs_item and stats
1428          if (ReadMacInt32(pb + ioNamePtr))
1429 <                cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->name);
1429 >                cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->guest_name);
1430          WriteMacInt16(pb + ioFRefNum, 0);
1431          WriteMacInt8(pb + ioFlAttrib, (S_ISDIR(st.st_mode) ? faIsDir : 0) | (access(full_path, W_OK) == 0 ? 0 : faLocked));
1432          WriteMacInt8(pb + ioACUser, 0);
1433          WriteMacInt32(pb + ioDirID, fs_item->id);
1434          WriteMacInt32(pb + ioFlParID, fs_item->parent_id);
1435 < #ifdef __BEOS__
1436 <        WriteMacInt32(pb + ioFlCrDat, st.st_crtime + TIME_OFFSET);
1435 > #if defined(__BEOS__) || defined(WIN32)
1436 >        WriteMacInt32(pb + ioFlCrDat, TimeToMacTime(st.st_crtime));
1437 > #elif defined __APPLE__ && defined __MACH__
1438 >        WriteMacInt32(pb + ioFlCrDat, get_creation_time(full_path));
1439   #else
1440          WriteMacInt32(pb + ioFlCrDat, 0);
1441   #endif
# Line 1352 | Line 1445 | read_next_de:
1445                  fs_item->mtime = mtime;
1446                  cached = false;
1447          }
1448 <        WriteMacInt32(pb + ioFlMdDat, mtime);
1448 >        WriteMacInt32(pb + ioFlMdDat, TimeToMacTime(mtime));
1449          WriteMacInt32(pb + ioFlBkDat, 0);
1450 +
1451 +        get_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo, S_ISDIR(st.st_mode));
1452 +
1453          if (S_ISDIR(st.st_mode)) {
1358                Mac_memset(pb + ioDrUsrWds, 0, SIZEOF_DInfo);
1359                Mac_memset(pb + ioDrFndrInfo, 0, SIZEOF_DXInfo);
1360                uint16 fflags;  // pb may point to kernel space, but stack is switched
1361                get_finder_flags(full_path, fflags);
1362                WriteMacInt16(pb + ioDrUsrWds + frFlags, fflags);
1454  
1455                  // Determine number of files in directory (cached)
1456                  int count;
# Line 1374 | Line 1465 | read_next_de:
1465                                          de = readdir(d);
1466                                          if (de == NULL)
1467                                                  break;
1468 +                                        if (de->d_name[0] == '.')
1469 +                                                continue;       // Suppress names beginning with '.'
1470                                          count++;
1471                                  }
1472                                  closedir(d);
# Line 1382 | Line 1475 | read_next_de:
1475                  }
1476                  WriteMacInt16(pb + ioDrNmFls, count);
1477          } else {
1385                Mac_memset(pb + ioFlFndrInfo, 0, SIZEOF_FInfo);
1386                Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo);
1387                uint32 type, creator;   // pb may point to kernel space, but stack is switched
1388                get_finder_type(full_path, type, creator);
1389                WriteMacInt32(pb + ioFlFndrInfo + fdType, type);
1390                WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator);
1391                uint16 fflags;
1392                get_finder_flags(full_path, fflags);
1393                WriteMacInt16(pb + ioFlFndrInfo + fdFlags, fflags);
1478                  WriteMacInt16(pb + ioFlStBlk, 0);
1479                  WriteMacInt32(pb + ioFlLgLen, st.st_size);
1480 <                WriteMacInt32(pb + ioFlPyLen, (st.st_size + 1023) & ~1023);
1480 >                WriteMacInt32(pb + ioFlPyLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1481                  WriteMacInt16(pb + ioFlRStBlk, 0);
1482                  uint32 rf_size = get_rfork_size(full_path);
1483                  WriteMacInt32(pb + ioFlRLgLen, rf_size);
1484 <                WriteMacInt32(pb + ioFlRPyLen, (rf_size + 1023) & ~1023);
1484 >                WriteMacInt32(pb + ioFlRPyLen, (rf_size | (AL_BLK_SIZE - 1)) + 1);
1485                  WriteMacInt32(pb + ioFlClpSiz, 0);
1486          }
1487          return noErr;
# Line 1419 | Line 1503 | static int16 fs_set_cat_info(uint32 pb)
1503          if (stat(full_path, &st) < 0)
1504                  return errno2oserr();
1505  
1506 <        // Set attributes
1507 <        if (S_ISDIR(st.st_mode))
1508 <                set_finder_flags(full_path, ReadMacInt16(pb + ioDrUsrWds + frFlags));
1425 <        else {
1426 <                set_finder_type(full_path, ReadMacInt32(pb + ioFlFndrInfo + fdType), ReadMacInt32(pb + ioFlFndrInfo + fdCreator));
1427 <                set_finder_flags(full_path, ReadMacInt16(pb + ioFlFndrInfo + fdFlags));
1428 <        }
1506 >        // Set Finder info
1507 >        set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo, S_ISDIR(st.st_mode));
1508 >
1509          //!! times
1510          return noErr;
1511   }
# Line 1472 | Line 1552 | static int16 fs_open(uint32 pb, uint32 d
1552                  if (access(full_path, F_OK))
1553                          return fnfErr;
1554                  fd = open_rfork(full_path, flag);
1555 <                if (fd > 0) {
1556 <                        if (fstat(fd, &st) < 0)
1555 >                if (fd >= 0) {
1556 >                        if (fstat(fd, &st) < 0) {
1557 >                                close(fd);
1558                                  return errno2oserr();
1559 +                        }
1560                  } else {        // Resource fork not supported, silently ignore it ("pseudo" resource fork)
1561                          st.st_size = 0;
1562                          st.st_mode = 0;
# Line 1483 | Line 1565 | static int16 fs_open(uint32 pb, uint32 d
1565                  fd = open(full_path, flag);
1566                  if (fd < 0)
1567                          return errno2oserr();
1568 <                if (fstat(fd, &st) < 0)
1568 >                if (fstat(fd, &st) < 0) {
1569 >                        close(fd);
1570                          return errno2oserr();
1571 +                }
1572          }
1573  
1574          // File open, allocate FCB
# Line 1496 | Line 1580 | static int16 fs_open(uint32 pb, uint32 d
1580          D(bug("  UTAllocateFCB() returned %d, fRefNum %d, fcb %08lx\n", r.d[0], ReadMacInt16(pb + ioRefNum), fcb));
1581          if (r.d[0] & 0xffff) {
1582                  close(fd);
1583 <                return r.d[0];
1583 >                return (int16)r.d[0];
1584          }
1585  
1586          // Initialize FCB, fd is stored in fcbCatPos
1587          WriteMacInt32(fcb + fcbFlNm, fs_item->id);
1588          WriteMacInt8(fcb + fcbFlags, ((flag == O_WRONLY || flag == O_RDWR) ? fcbWriteMask : 0) | (resource_fork ? fcbResourceMask : 0) | (write_ok ? 0 : fcbFileLockedMask));
1589          WriteMacInt32(fcb + fcbEOF, st.st_size);
1590 <        WriteMacInt32(fcb + fcbPLen, (st.st_size + 1023) & ~1023);
1590 >        WriteMacInt32(fcb + fcbPLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1591          WriteMacInt32(fcb + fcbCrPs, 0);
1592          WriteMacInt32(fcb + fcbVPtr, vcb);
1593 <        WriteMacInt32(fcb + fcbClmpSize, 1024);
1594 <        uint32 type, creator;   // fcb may point to kernel space, but stack is switched
1595 <        get_finder_type(full_path, type, creator);
1596 <        WriteMacInt32(fcb + fcbFType, type);
1593 >        WriteMacInt32(fcb + fcbClmpSize, CLUMP_SIZE);
1594 >
1595 >        get_finfo(full_path, fs_data + fsPB, 0, false);
1596 >        WriteMacInt32(fcb + fcbFType, ReadMacInt32(fs_data + fsPB + fdType));
1597 >
1598          WriteMacInt32(fcb + fcbCatPos, fd);
1599          WriteMacInt32(fcb + fcbDirID, fs_item->parent_id);
1600 <        cstr2pstr((char *)Mac2HostAddr(fcb + fcbCName), fs_item->name);
1600 >        cstr2pstr((char *)Mac2HostAddr(fcb + fcbCName), fs_item->guest_name);
1601          return noErr;
1602   }
1603  
# Line 1546 | Line 1631 | static int16 fs_close(uint32 pb)
1631          r.d[0] = ReadMacInt16(pb + ioRefNum);
1632          Execute68k(fs_data + fsReleaseFCB, &r);
1633          D(bug("  UTReleaseFCB() returned %d\n", r.d[0]));
1634 <        return r.d[0];
1634 >        return (int16)r.d[0];
1635   }
1636  
1637   // Query information about FCB (FCBPBRec)
# Line 1565 | Line 1650 | static int16 fs_get_fcb_info(uint32 pb,
1650  
1651                  // Find FCB by index
1652                  WriteMacInt16(pb + ioRefNum, 0);
1653 <                for (int i=0; i<ReadMacInt16(pb + ioFCBIndx); i++) {
1653 >                for (int i=0; i<(int)ReadMacInt16(pb + ioFCBIndx); i++) {
1654                          D(bug("  indexing FCBs\n"));
1655                          r.a[0] = vcb;
1656                          r.a[1] = pb + ioRefNum;
# Line 1574 | Line 1659 | static int16 fs_get_fcb_info(uint32 pb,
1659                          fcb = ReadMacInt32(fs_data + fsReturn);
1660                          D(bug("  UTIndexFCB() returned %d, fcb %p\n", r.d[0], fcb));
1661                          if (r.d[0] & 0xffff)
1662 <                                return r.d[0];
1662 >                                return (int16)r.d[0];
1663                  }
1664          }
1665          if (fcb == 0)
# Line 1622 | Line 1707 | static int16 fs_get_eof(uint32 pb)
1707  
1708          // Adjust FCBs
1709          WriteMacInt32(fcb + fcbEOF, st.st_size);
1710 <        WriteMacInt32(fcb + fcbPLen, (st.st_size + 1023) & ~1023);
1710 >        WriteMacInt32(fcb + fcbPLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
1711          WriteMacInt32(pb + ioMisc, st.st_size);
1712          D(bug("  adjusting FCBs\n"));
1713          r.d[0] = ReadMacInt16(pb + ioRefNum);
# Line 1657 | Line 1742 | static int16 fs_set_eof(uint32 pb)
1742  
1743          // Adjust FCBs
1744          WriteMacInt32(fcb + fcbEOF, size);
1745 <        WriteMacInt32(fcb + fcbPLen, (size + 1023) & ~1023);
1745 >        WriteMacInt32(fcb + fcbPLen, (size | (AL_BLK_SIZE - 1)) + 1);
1746          D(bug("  adjusting FCBs\n"));
1747          r.d[0] = ReadMacInt16(pb + ioRefNum);
1748          Execute68k(fs_data + fsAdjustEOF, &r);
# Line 1742 | Line 1827 | static int16 fs_read(uint32 pb)
1827   {
1828          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)));
1829  
1830 +        // Check parameters
1831 +        if ((int32)ReadMacInt32(pb + ioReqCount) < 0)
1832 +                return paramErr;
1833 +
1834          // Find FCB and fd for file
1835          uint32 fcb = find_fcb(ReadMacInt16(pb + ioRefNum));
1836          if (fcb == 0)
# Line 1773 | Line 1862 | static int16 fs_read(uint32 pb)
1862          }
1863  
1864          // Read
1865 <        size_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1865 >        ssize_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1866 >        int16 read_err = errno2oserr();
1867          D(bug("  actual %d\n", actual));
1868 <        WriteMacInt32(pb + ioActCount, actual);
1868 >        WriteMacInt32(pb + ioActCount, actual >= 0 ? actual : 0);
1869          uint32 pos = lseek(fd, 0, SEEK_CUR);
1870          WriteMacInt32(fcb + fcbCrPs, pos);
1871          WriteMacInt32(pb + ioPosOffset, pos);
1872 <        if (actual != ReadMacInt32(pb + ioReqCount))
1873 <                if (errno)
1784 <                        return errno2oserr();
1785 <                else
1786 <                        return eofErr;
1872 >        if (actual != (ssize_t)ReadMacInt32(pb + ioReqCount))
1873 >                return actual < 0 ? read_err : eofErr;
1874          else
1875                  return noErr;
1876   }
# Line 1793 | Line 1880 | static int16 fs_write(uint32 pb)
1880   {
1881          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)));
1882  
1883 +        // Check parameters
1884 +        if ((int32)ReadMacInt32(pb + ioReqCount) < 0)
1885 +                return paramErr;
1886 +
1887          // Find FCB and fd for file
1888          uint32 fcb = find_fcb(ReadMacInt16(pb + ioRefNum));
1889          if (fcb == 0)
# Line 1824 | Line 1915 | static int16 fs_write(uint32 pb)
1915          }
1916  
1917          // Write
1918 <        size_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1918 >        ssize_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1919 >        int16 write_err = errno2oserr();
1920          D(bug("  actual %d\n", actual));
1921 <        WriteMacInt32(pb + ioActCount, actual);
1921 >        WriteMacInt32(pb + ioActCount, actual >= 0 ? actual : 0);
1922          uint32 pos = lseek(fd, 0, SEEK_CUR);
1923          WriteMacInt32(fcb + fcbCrPs, pos);
1924          WriteMacInt32(pb + ioPosOffset, pos);
1925 <        if (actual != ReadMacInt32(pb + ioReqCount))
1926 <                return errno2oserr();
1925 >        if (actual != (ssize_t)ReadMacInt32(pb + ioReqCount))
1926 >                return write_err;
1927          else
1928                  return noErr;
1929   }
# Line 1897 | Line 1989 | static int16 fs_delete(uint32 pb, uint32
1989                  return result;
1990  
1991          // Delete file
1992 <        if (remove(full_path) < 0) {
1993 <                int16 err = errno2oserr();
1994 <                if (errno == EISDIR) {  // Workaround for BeOS bug
1903 <                        if (rmdir(full_path) < 0)
1904 <                                return errno2oserr();
1905 <                        else
1906 <                                return noErr;
1907 <                } else
1908 <                        return err;
1909 <        } else
1992 >        if (!extfs_remove(full_path))
1993 >                return errno2oserr();
1994 >        else
1995                  return noErr;
1996   }
1997  
# Line 1939 | Line 2024 | static int16 fs_rename(uint32 pb, uint32
2024  
2025          // Rename item
2026          D(bug("  renaming %s -> %s\n", old_path, full_path));
2027 <        if (rename(old_path, full_path) < 0)
2027 >        if (!extfs_rename(old_path, full_path))
2028                  return errno2oserr();
2029          else {
2030                  // The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems
2031 +                swap_parent_ids(fs_item->id, new_item->id);
2032                  uint32 t = fs_item->id;
2033                  fs_item->id = new_item->id;
2034                  new_item->id = t;
# Line 1966 | Line 2052 | static int16 fs_cat_move(uint32 pb)
2052          strcpy(old_path, full_path);
2053  
2054          // Find path for new directory
2055 <        Mac2Host_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam);
2055 >        Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam);
2056          WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioNewName));
2057          FSItem *new_dir_item;
2058          result = get_item_and_path(fs_data + fsPB, ReadMacInt32(pb + ioNewDirID), new_dir_item);
# Line 1982 | Line 2068 | static int16 fs_cat_move(uint32 pb)
2068  
2069          // Move item
2070          D(bug("  moving %s -> %s\n", old_path, full_path));
2071 <        if (rename(old_path, full_path) < 0)
2071 >        if (!extfs_rename(old_path, full_path))
2072                  return errno2oserr();
2073          else {
2074                  // The ID of the old file/dir has to stay the same, so we swap the IDs of the FSItems
2075                  FSItem *new_item = find_fsitem(fs_item->name, new_dir_item);
2076                  if (new_item) {
2077 +                        swap_parent_ids(fs_item->id, new_item->id);
2078                          uint32 t = fs_item->id;
2079                          fs_item->id = new_item->id;
2080                          new_item->id = t;
# Line 2007 | Line 2094 | static int16 fs_open_wd(uint32 pb)
2094          r.a[0] = pb;
2095          Execute68k(fs_data + fsAllocateWDCB, &r);
2096          D(bug("  UTAllocateWDCB returned %d, refNum is %d\n", r.d[0], ReadMacInt16(pb + ioVRefNum)));
2097 <        return r.d[0];
2097 >        return (int16)r.d[0];
2098   }
2099  
2100   // Close working directory (WDParam)
# Line 2021 | Line 2108 | static int16 fs_close_wd(uint32 pb)
2108          r.d[0] = ReadMacInt16(pb + ioVRefNum);
2109          Execute68k(fs_data + fsReleaseWDCB, &r);
2110          D(bug("  UTReleaseWDCB returned %d\n", r.d[0]));
2111 <        return r.d[0];
2111 >        return (int16)r.d[0];
2112   }
2113  
2114   // Query information about working directory (WDParam)
# Line 2050 | Line 2137 | static int16 fs_get_wd_info(uint32 pb, u
2137          uint32 wdcb = ReadMacInt32(fs_data + fsReturn);
2138          D(bug("  UTResolveWDCB() returned %d, dirID %d\n", r.d[0], ReadMacInt32(wdcb + wdDirID)));
2139          if (r.d[0] & 0xffff)
2140 <                return r.d[0];
2140 >                return (int16)r.d[0];
2141  
2142          // Return information
2143 <        WriteMacInt16(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID));
2143 >        WriteMacInt32(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID));
2144          WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(ReadMacInt32(wdcb + wdVCBPtr) + vcbVRefNum));
2145          if (ReadMacInt32(pb + ioNamePtr))
2146                  Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), ReadMacInt32(wdcb + wdVCBPtr) + vcbVN, 28);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines