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.18 by cebix, 2000-07-14T21:29:08Z vs.
Revision 1.21 by cebix, 2000-07-22T16:07:16Z

# Line 72 | Line 72 | enum {
72          fsHFSProcStub = 6,
73          fsDrvStatus = 12,                               // Drive Status record
74          fsFSD = 42,                                             // File system descriptor
75 <        fsPB = 238,                                             // IOParam (for mounting and renaming)
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
# Line 108 | 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 120 | Line 120 | 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 ALBLK_SIZE = 0x4000;
123 > const int AL_BLK_SIZE = 0x4000;
124   const int CLUMP_SIZE = 0x4000;
125  
126   // Drive number of our pseudo-drive
# Line 277 | Line 277 | static void cstr2pstr(char *dst, const c
277          }
278   }
279  
280 // Convert pascal string to C string
281 static void pstr2cstr(char *dst, const char *src)
282 {
283        int size = *src++;
284        while (size--) {
285                char c = *src++;
286                // Note: we are converting Mac '/' characters to host ':' characters here
287                // '/' is not a path separator as this function is only used on object names
288                if (c == '/')
289                        c = ':';
290                *dst++ = c;
291        }
292        *dst = 0;
293 }
294
280   // Convert string (no length byte) to C string, length given separately
281   static void strn2cstr(char *dst, const char *src, int size)
282   {
# Line 423 | 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 432 | 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 702 | 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 966 | 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 1002 | Line 987 | static int16 fs_volume_mount(uint32 pb)
987          WriteMacInt16(vcb + vcbNmRtDirs, 1);            //!!
988          WriteMacInt16(vcb + vcbNmAlBlks, 0xffff);       //!!
989          WriteMacInt32(vcb + vcbAlBlkSiz, AL_BLK_SIZE);
990 <        WriteMacInt32(vcb + vcbClpSiz, CLUMPSIZE);
990 >        WriteMacInt32(vcb + vcbClpSiz, CLUMP_SIZE);
991          WriteMacInt32(vcb + vcbNxtCNID, next_cnid);
992          WriteMacInt16(vcb + vcbFreeBks, 0xffff);        //!!
993          Host2Mac_memcpy(vcb + vcbVN, VOLUME_NAME, 28);
# Line 1253 | Line 1238 | read_next_de:
1238   #endif
1239          WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET);
1240  
1241 <        Mac_memset(pb + ioFlFndrInfo, 0, SIZEOF_FInfo);
1257 <        uint32 type, creator;   // pb may point to kernel space, but stack is switched
1258 <        get_finder_type(full_path, type, creator);
1259 <        WriteMacInt32(pb + ioFlFndrInfo + fdType, type);
1260 <        WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator);
1261 <        uint16 fflags;
1262 <        get_finder_flags(full_path, fflags);
1263 <        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);
# Line 1272 | Line 1250 | read_next_de:
1250  
1251          if (hfs) {
1252                  WriteMacInt32(pb + ioFlBkDat, 0);
1275                Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo);
1253                  WriteMacInt32(pb + ioFlParID, fs_item->parent_id);
1254                  WriteMacInt32(pb + ioFlClpSiz, 0);
1255          }
# Line 1297 | 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 1389 | Line 1366 | read_next_de:
1366          }
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)) {
1393                Mac_memset(pb + ioDrUsrWds, 0, SIZEOF_DInfo);
1394                Mac_memset(pb + ioDrFndrInfo, 0, SIZEOF_DXInfo);
1395                uint16 fflags;  // pb may point to kernel space, but stack is switched
1396                get_finder_flags(full_path, fflags);
1397                WriteMacInt16(pb + ioDrUsrWds + frFlags, fflags);
1373  
1374                  // Determine number of files in directory (cached)
1375                  int count;
# Line 1419 | Line 1394 | read_next_de:
1394                  }
1395                  WriteMacInt16(pb + ioDrNmFls, count);
1396          } else {
1422                Mac_memset(pb + ioFlFndrInfo, 0, SIZEOF_FInfo);
1423                Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo);
1424                uint32 type, creator;   // pb may point to kernel space, but stack is switched
1425                get_finder_type(full_path, type, creator);
1426                WriteMacInt32(pb + ioFlFndrInfo + fdType, type);
1427                WriteMacInt32(pb + ioFlFndrInfo + fdCreator, creator);
1428                uint16 fflags;
1429                get_finder_flags(full_path, fflags);
1430                WriteMacInt16(pb + ioFlFndrInfo + fdFlags, fflags);
1397                  WriteMacInt16(pb + ioFlStBlk, 0);
1398                  WriteMacInt32(pb + ioFlLgLen, st.st_size);
1399                  WriteMacInt32(pb + ioFlPyLen, (st.st_size | (AL_BLK_SIZE - 1)) + 1);
# Line 1456 | 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));
1462 <        } else {
1463 <                set_finder_type(full_path, ReadMacInt32(pb + ioFlFndrInfo + fdType), ReadMacInt32(pb + ioFlFndrInfo + fdCreator));
1464 <                set_finder_flags(full_path, ReadMacInt16(pb + ioFlFndrInfo + fdFlags));
1465 <        }
1425 >        // Set Finder info
1426 >        set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo);
1427 >
1428          //!! times
1429          return noErr;
1430   }
# Line 1548 | Line 1510 | static int16 fs_open(uint32 pb, uint32 d
1510          WriteMacInt32(fcb + fcbCrPs, 0);
1511          WriteMacInt32(fcb + fcbVPtr, vcb);
1512          WriteMacInt32(fcb + fcbClmpSize, CLUMP_SIZE);
1513 <        uint32 type, creator;   // BeOS: fcb may point to kernel space, but stack is switched
1514 <        get_finder_type(full_path, type, creator);
1515 <        WriteMacInt32(fcb + fcbFType, type);
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 1606 | 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 1825 | Line 1788 | static int16 fs_read(uint32 pb)
1788          uint32 pos = lseek(fd, 0, SEEK_CUR);
1789          WriteMacInt32(fcb + fcbCrPs, pos);
1790          WriteMacInt32(pb + ioPosOffset, pos);
1791 <        if (actual != ReadMacInt32(pb + ioReqCount))
1791 >        if (actual != (ssize_t)ReadMacInt32(pb + ioReqCount))
1792                  return actual < 0 ? read_err : eofErr;
1793          else
1794                  return noErr;
# Line 1878 | Line 1841 | static int16 fs_write(uint32 pb)
1841          uint32 pos = lseek(fd, 0, SEEK_CUR);
1842          WriteMacInt32(fcb + fcbCrPs, pos);
1843          WriteMacInt32(pb + ioPosOffset, pos);
1844 <        if (actual != ReadMacInt32(pb + ioReqCount))
1844 >        if (actual != (ssize_t)ReadMacInt32(pb + ioReqCount))
1845                  return write_err;
1846          else
1847                  return noErr;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines