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.4 by cebix, 1999-10-20T17:23:53Z

# Line 325 | Line 325 | void ExtFSInit(void)
325          cstr2pstr(FS_NAME, GetString(STR_EXTFS_NAME));
326          cstr2pstr(VOLUME_NAME, GetString(STR_EXTFS_VOLUME_NAME));
327  
328 <        // Create root FSItem
328 >        // Create root's parent FSItem
329          FSItem *p = new FSItem;
330          first_fs_item = last_fs_item = p;
331          p->next = NULL;
332 +        p->id = ROOT_PARENT_ID;
333 +        p->parent_id = 0;
334 +        p->parent = NULL;
335 +        p->name[0] = 0;
336 +
337 +        // Create root FSItem
338 +        p = new FSItem;
339 +        last_fs_item->next = p;
340 +        p->next = NULL;
341 +        last_fs_item = p;
342          p->id = ROOT_ID;
343          p->parent_id = ROOT_PARENT_ID;
344 <        p->parent = NULL;
344 >        p->parent = first_fs_item;
345          strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32);
346  
347          // Find path for root
# Line 689 | Line 699 | static int16 get_current_dir(uint32 pb,
699          int16 result;
700  
701          // Determine volume
702 < //      D(bug("  determining volume\n"));
702 >        D(bug("  determining volume, dirID %d\n", dirID));
703          r.a[0] = pb;
704          r.a[1] = fs_data + fsReturn;
705          r.a[2] = fs_data + fsReturn + 2;
# Line 707 | Line 717 | static int16 get_current_dir(uint32 pb,
717          int16 more_matches = ReadMacInt16(fs_data + fsReturn + 2);
718          int16 vRefNum = ReadMacInt16(fs_data + fsReturn + 4);
719          uint32 vcb = ReadMacInt32(fs_data + fsReturn + 6);
720 < //      D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
720 >        D(bug("  UTDetermineVol() returned %d, status %d\n", r.d[0], status));
721          result = r.d[0] & 0xffff;
722  
723          if (result == noErr) {
# Line 790 | Line 800 | static int16 get_item_and_path(uint32 pb
800          uint32 current_dir;
801          if ((result = get_current_dir(pb, dirID, current_dir, no_vol_name)) != noErr)
802                  return result;
803 +        D(bug("  current dir %08x\n", current_dir));
804          FSItem *p = find_fsitem_by_id(current_dir);
805          if (p == NULL)
806                  return dirNFErr;
# Line 803 | Line 814 | static int16 get_item_and_path(uint32 pb
814          WriteMacInt8(parseRec + ppFoundDelimiter, false);
815  
816          // Get length of volume name
817 < //      D(bug("  parsing pathname\n"));
817 >        D(bug("  parsing pathname\n"));
818          r.a[0] = parseRec + ppStartOffset;
819          r.a[1] = ReadMacInt32(parseRec + ppNamePtr);
820          Execute68k(fs_data + fsParsePathname, &r);
821 < //      D(bug("  UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset)));
821 >        D(bug("  UTParsePathname() returned %d, startOffset %d\n", r.d[0], ReadMacInt16(parseRec + ppStartOffset)));
822          result = r.d[0] & 0xffff;
823          if (result == noErr) {
824  
# Line 1086 | Line 1097 | static int16 fs_get_vol(uint32 pb)
1097   // Set default volume (WDParam)
1098   static int16 fs_set_vol(uint32 pb, bool hfs, uint32 vcb)
1099   {
1100 <        D(bug(" fs_set_vol(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID)));
1100 >        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)));
1101          M68kRegisters r;
1102  
1103          // Determine parameters
# Line 1142 | Line 1153 | static int16 fs_set_vol(uint32 pb, bool
1153   // Query file attributes (HFileParam)
1154   static int16 fs_get_file_info(uint32 pb, bool hfs, uint32 dirID)
1155   {
1156 <        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));
1156 >        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));
1157  
1158          FSItem *fs_item;
1159 <        int16 dir_index = ReadMacInt16(pb + ioFDirIndex);
1160 <        if (dir_index == 0) {   // Query item specified by ioDirID and ioNamePtr
1159 >        int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex);
1160 >        if (dir_index <= 0) {           // Query item specified by ioDirID and ioNamePtr
1161  
1162                  // Find FSItem for given file
1163                  int16 result = get_item_and_path(pb, dirID, fs_item);
# Line 1238 | Line 1249 | read_next_de:
1249   // Set file attributes (HFileParam)
1250   static int16 fs_set_file_info(uint32 pb, bool hfs, uint32 dirID)
1251   {
1252 <        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));
1252 >        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));
1253  
1254          // Find FSItem for given file/dir
1255          FSItem *fs_item;
# Line 1263 | Line 1274 | static int16 fs_set_file_info(uint32 pb,
1274   // Query file/directory attributes
1275   static int16 fs_get_cat_info(uint32 pb)
1276   {
1277 <        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)));
1277 >        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)));
1278  
1279          FSItem *fs_item;
1280 <        int16 dir_index = ReadMacInt16(pb + ioFDirIndex);
1281 <        if (dir_index == -1) {          // Query directory specified by ioDirID
1280 >        int16 dir_index = (int16)ReadMacInt16(pb + ioFDirIndex);
1281 >        if (dir_index < 0) {                    // Query directory specified by ioDirID
1282  
1283                  // Find FSItem for directory
1284                  fs_item = find_fsitem_by_id(ReadMacInt32(pb + ioDrDirID));
# Line 1397 | Line 1408 | read_next_de:
1408   // Set file/directory attributes
1409   static int16 fs_set_cat_info(uint32 pb)
1410   {
1411 <        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)));
1411 >        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)));
1412  
1413          // Find FSItem for given file/dir
1414          FSItem *fs_item;
# Line 1424 | Line 1435 | static int16 fs_set_cat_info(uint32 pb)
1435   // Open file
1436   static int16 fs_open(uint32 pb, uint32 dirID, uint32 vcb, bool resource_fork)
1437   {
1438 <        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)));
1438 >        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)));
1439          M68kRegisters r;
1440  
1441          // Find FSItem for given file
# Line 1711 | Line 1722 | static int16 fs_set_fpos(uint32 pb)
1722                          if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_SET) < 0)
1723                                  return posErr;
1724                          break;
1725 +                case fsFromLEOF:
1726 +                        if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_END) < 0)
1727 +                                return posErr;
1728 +                        break;
1729                  case fsFromMark:
1730 <                        if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0)
1730 >                        if (lseek(fd, (int32)ReadMacInt32(pb + ioPosOffset), SEEK_CUR) < 0)
1731                                  return posErr;
1732 +                        break;
1733                  default:
1734                          break;
1735          }
# Line 1825 | Line 1841 | static int16 fs_write(uint32 pb)
1841   // Create file
1842   static int16 fs_create(uint32 pb, uint32 dirID)
1843   {
1844 <        D(bug(" fs_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID));
1844 >        D(bug(" fs_create(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID));
1845  
1846          // Find FSItem for given file
1847          FSItem *fs_item;
# Line 1850 | Line 1866 | static int16 fs_create(uint32 pb, uint32
1866   // Create directory
1867   static int16 fs_dir_create(uint32 pb)
1868   {
1869 <        D(bug(" fs_dir_create(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioDirID)));
1869 >        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)));
1870  
1871          // Find FSItem for given directory
1872          FSItem *fs_item;
# Line 1874 | Line 1890 | static int16 fs_dir_create(uint32 pb)
1890   // Delete file/directory
1891   static int16 fs_delete(uint32 pb, uint32 dirID)
1892   {
1893 <        D(bug(" fs_delete(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), dirID));
1893 >        D(bug(" fs_delete(%08lx), vRefNum %d, name %.31s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr) + 1), dirID));
1894  
1895          // Find FSItem for given file/dir
1896          FSItem *fs_item;
# Line 1899 | Line 1915 | static int16 fs_delete(uint32 pb, uint32
1915   // Rename file/directory
1916   static int16 fs_rename(uint32 pb, uint32 dirID)
1917   {
1918 <        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))));
1918 >        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)));
1919  
1920          // Find path of given file/dir
1921          FSItem *fs_item;
# Line 1940 | Line 1956 | static int16 fs_rename(uint32 pb, uint32
1956   // Move file/directory (CMovePBRec)
1957   static int16 fs_cat_move(uint32 pb)
1958   {
1959 <        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)));
1959 >        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)));
1960  
1961          // Find path of given file/dir
1962          FSItem *fs_item;
# Line 1987 | Line 2003 | static int16 fs_cat_move(uint32 pb)
2003   // Open working directory (WDParam)
2004   static int16 fs_open_wd(uint32 pb)
2005   {
2006 <        D(bug(" fs_open_wd(%08lx), vRefNum %d, name %#s, dirID %d\n", pb, ReadMacInt16(pb + ioVRefNum), Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), ReadMacInt32(pb + ioWDDirID)));
2006 >        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)));
2007          M68kRegisters r;
2008  
2009          // Allocate WDCB

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines