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.8 by cebix, 1999-11-01T16:24:06Z vs.
Revision 1.12 by cebix, 1999-11-08T17:00:04Z

# Line 65 | Line 65 | enum {
65          fsHFSProcStub = 6,
66          fsDrvStatus = 12,                               // Drive Status record
67          fsFSD = 42,                                             // File system descriptor
68 <        fsPB = 238,                                             // IOParam (for mounting)
68 >        fsPB = 238,                                             // IOParam (for mounting and renaming)
69          fsVMI = 288,                                    // VoumeMountInfoHeader (for mounting)
70          fsParseRec = 296,                               // ParsePathRec struct
71          fsReturn = 306,                                 // Area for return data of 68k routines
# Line 604 | Line 604 | void InstallExtFS(void)
604          WriteMacInt16(fs_data + fsFSD + fsdLength, SIZEOF_FSDRec);
605          WriteMacInt16(fs_data + fsFSD + fsdVersion, fsdVersion1);
606          WriteMacInt16(fs_data + fsFSD + fileSystemFSID, MY_FSID);
607 <        memcpy(Mac2HostAddr(fs_data + fsFSD + fileSystemName), FS_NAME, 32);
607 >        Host2Mac_memcpy(fs_data + fsFSD + fileSystemName, FS_NAME, 32);
608          WriteMacInt32(fs_data + fsFSD + fileSystemCommProc, fs_data + fsCommProcStub);
609          WriteMacInt32(fs_data + fsFSD + fsdHFSCI + compInterfProc, fs_data + fsHFSProcStub);
610          WriteMacInt32(fs_data + fsFSD + fsdHFSCI + stackTop, fs_stack + STACK_SIZE);
# Line 658 | Line 658 | int16 ExtFSComm(uint16 message, uint32 p
658  
659                  case ffsGetIconMessage: {               // Get disk/drive icon
660                          if (ReadMacInt8(paramBlock + iconType) == kLargeIcon && ReadMacInt32(paramBlock + requestSize) >= sizeof(ExtFSIcon)) {
661 <                                memcpy(Mac2HostAddr(ReadMacInt32(paramBlock + iconBufferPtr)), ExtFSIcon, sizeof(ExtFSIcon));
661 >                                Host2Mac_memcpy(ReadMacInt32(paramBlock + iconBufferPtr), ExtFSIcon, sizeof(ExtFSIcon));
662                                  WriteMacInt32(paramBlock + actualSize, sizeof(ExtFSIcon));
663                                  return noErr;
664                          } else
# Line 969 | Line 969 | static int16 fs_volume_mount(uint32 pb)
969          WriteMacInt32(vcb + vcbClpSiz, 1024);
970          WriteMacInt32(vcb + vcbNxtCNID, next_cnid);
971          WriteMacInt16(vcb + vcbFreeBks, 0xffff);        //!!
972 <        memcpy(Mac2HostAddr(vcb + vcbVN), VOLUME_NAME, 28);
972 >        Host2Mac_memcpy(vcb + vcbVN, VOLUME_NAME, 28);
973          WriteMacInt16(vcb + vcbFSID, MY_FSID);
974          WriteMacInt32(vcb + vcbFilCnt, 1);                      //!!
975          WriteMacInt32(vcb + vcbDirCnt, 1);                      //!!
# Line 1043 | Line 1043 | static int16 fs_get_vol_info(uint32 pb,
1043                  WriteMacInt32(pb + ioVWrCnt, 0);
1044                  WriteMacInt32(pb + ioVFilCnt, 1);                       //!!
1045                  WriteMacInt32(pb + ioVDirCnt, 1);                       //!!
1046 <                memset(Mac2HostAddr(pb + ioVFndrInfo), 0, 32);
1046 >                Mac_memset(pb + ioVFndrInfo, 0, 32);
1047          }
1048          return noErr;
1049   }
# Line 1073 | Line 1073 | static int16 fs_get_vol_parms(uint32 pb)
1073          uint32 actual = ReadMacInt32(pb + ioReqCount);
1074          if (actual > sizeof(vol))
1075                  actual = sizeof(vol);
1076 <        memcpy(Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), vol, actual);
1076 >        Host2Mac_memcpy(ReadMacInt32(pb + ioBuffer), vol, actual);
1077          WriteMacInt32(pb + ioActCount, actual);
1078          return noErr;
1079   }
# Line 1187 | Line 1187 | read_next_de:
1187                                  return fnfErr;
1188                          }
1189                          if (de->d_name[0] == '.')
1190 <                                goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1190 >                                goto read_next_de;      // Suppress names beginning with '.' (MacOS could interpret these as driver names)
1191                          //!! suppress directories
1192                  }
1193                  add_path_comp(de->d_name);
# Line 1218 | Line 1218 | read_next_de:
1218   #endif
1219          WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET);
1220  
1221 <        memset(Mac2HostAddr(pb + ioFlFndrInfo), 0, SIZEOF_FInfo);
1221 >        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);
# Line 1237 | Line 1237 | read_next_de:
1237  
1238          if (hfs) {
1239                  WriteMacInt32(pb + ioFlBkDat, 0);
1240 <                memset(Mac2HostAddr(pb + ioFlXFndrInfo), 0, SIZEOF_FXInfo);
1240 >                Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo);
1241                  WriteMacInt32(pb + ioFlParID, fs_item->parent_id);
1242                  WriteMacInt32(pb + ioFlClpSiz, 0);
1243          }
# Line 1316 | Line 1316 | read_next_de:
1316                                  return fnfErr;
1317                          }
1318                          if (de->d_name[0] == '.')
1319 <                                goto read_next_de;      // Suppress name beginning with '.' (MacOS could interpret these as driver names)
1319 >                                goto read_next_de;      // Suppress names beginning with '.' (MacOS could interpret these as driver names)
1320                  }
1321                  add_path_comp(de->d_name);
1322  
# Line 1352 | Line 1352 | read_next_de:
1352                  fs_item->mtime = mtime;
1353                  cached = false;
1354          }
1355 <        WriteMacInt32(pb + ioFlMdDat, mtime);
1355 >        WriteMacInt32(pb + ioFlMdDat, mtime + TIME_OFFSET);
1356          WriteMacInt32(pb + ioFlBkDat, 0);
1357          if (S_ISDIR(st.st_mode)) {
1358 <                memset(Mac2HostAddr(pb + ioDrUsrWds), 0, SIZEOF_DInfo);
1359 <                memset(Mac2HostAddr(pb + ioDrFndrInfo), 0, SIZEOF_DXInfo);
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);
# Line 1374 | Line 1374 | read_next_de:
1374                                          de = readdir(d);
1375                                          if (de == NULL)
1376                                                  break;
1377 +                                        if (de->d_name[0] == '.')
1378 +                                                continue;       // Suppress names beginning with '.'
1379                                          count++;
1380                                  }
1381                                  closedir(d);
# Line 1382 | Line 1384 | read_next_de:
1384                  }
1385                  WriteMacInt16(pb + ioDrNmFls, count);
1386          } else {
1387 <                memset(Mac2HostAddr(pb + ioFlFndrInfo), 0, SIZEOF_FInfo);
1388 <                memset(Mac2HostAddr(pb + ioFlXFndrInfo), 0, SIZEOF_FXInfo);
1387 >                Mac_memset(pb + ioFlFndrInfo, 0, SIZEOF_FInfo);
1388 >                Mac_memset(pb + ioFlXFndrInfo, 0, SIZEOF_FXInfo);
1389                  uint32 type, creator;   // pb may point to kernel space, but stack is switched
1390                  get_finder_type(full_path, type, creator);
1391                  WriteMacInt32(pb + ioFlFndrInfo + fdType, type);
# Line 1774 | Line 1776 | static int16 fs_read(uint32 pb)
1776  
1777          // Read
1778          size_t actual = extfs_read(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1779 +        int16 read_err = errno2oserr();
1780          D(bug("  actual %d\n", actual));
1781          WriteMacInt32(pb + ioActCount, actual);
1782          uint32 pos = lseek(fd, 0, SEEK_CUR);
1783          WriteMacInt32(fcb + fcbCrPs, pos);
1784          WriteMacInt32(pb + ioPosOffset, pos);
1785          if (actual != ReadMacInt32(pb + ioReqCount))
1786 <                if (errno)
1784 <                        return errno2oserr();
1785 <                else
1786 <                        return eofErr;
1786 >                return read_err ? read_err : eofErr;
1787          else
1788                  return noErr;
1789   }
# Line 1825 | Line 1825 | static int16 fs_write(uint32 pb)
1825  
1826          // Write
1827          size_t actual = extfs_write(fd, Mac2HostAddr(ReadMacInt32(pb + ioBuffer)), ReadMacInt32(pb + ioReqCount));
1828 +        int16 write_err = errno2oserr();
1829          D(bug("  actual %d\n", actual));
1830          WriteMacInt32(pb + ioActCount, actual);
1831          uint32 pos = lseek(fd, 0, SEEK_CUR);
1832          WriteMacInt32(fcb + fcbCrPs, pos);
1833          WriteMacInt32(pb + ioPosOffset, pos);
1834          if (actual != ReadMacInt32(pb + ioReqCount))
1835 <                return errno2oserr();
1835 >                return write_err;
1836          else
1837                  return noErr;
1838   }
# Line 1897 | Line 1898 | static int16 fs_delete(uint32 pb, uint32
1898                  return result;
1899  
1900          // Delete file
1901 <        if (remove(full_path) < 0) {
1902 <                int16 err = errno2oserr();
1903 <                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
1901 >        if (!extfs_remove(full_path))
1902 >                return errno2oserr();
1903 >        else
1904                  return noErr;
1905   }
1906  
# Line 1926 | Line 1920 | static int16 fs_rename(uint32 pb, uint32
1920          strcpy(old_path, full_path);
1921  
1922          // Find path for new name
1923 <        uint8 new_pb[SIZEOF_IOParam];
1924 <        memcpy(new_pb, Mac2HostAddr(pb), SIZEOF_IOParam);
1931 <        WriteMacInt32((uint32)new_pb + ioNamePtr, ReadMacInt32(pb + ioMisc));
1923 >        Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam);
1924 >        WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioMisc));
1925          FSItem *new_item;
1926 <        result = get_item_and_path((uint32)new_pb, dirID, new_item);
1926 >        result = get_item_and_path(fs_data + fsPB, dirID, new_item);
1927          if (result != noErr)
1928                  return result;
1929  
# Line 1967 | Line 1960 | static int16 fs_cat_move(uint32 pb)
1960          strcpy(old_path, full_path);
1961  
1962          // Find path for new directory
1963 <        uint8 new_pb[SIZEOF_IOParam];
1964 <        memcpy(new_pb, Mac2HostAddr(pb), SIZEOF_IOParam);
1972 <        WriteMacInt32((uint32)new_pb + ioNamePtr, ReadMacInt32(pb + ioNewName));
1963 >        Mac2Mac_memcpy(fs_data + fsPB, pb, SIZEOF_IOParam);
1964 >        WriteMacInt32(fs_data + fsPB + ioNamePtr, ReadMacInt32(pb + ioNewName));
1965          FSItem *new_dir_item;
1966 <        result = get_item_and_path((uint32)new_pb, ReadMacInt32(pb + ioNewDirID), new_dir_item);
1966 >        result = get_item_and_path(fs_data + fsPB, ReadMacInt32(pb + ioNewDirID), new_dir_item);
1967          if (result != noErr)
1968                  return result;
1969  
# Line 2037 | Line 2029 | static int16 fs_get_wd_info(uint32 pb, u
2029                  WriteMacInt32(pb + ioWDProcID, 0);
2030                  WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(vcb + vcbVRefNum));
2031                  if (ReadMacInt32(pb + ioNamePtr))
2032 <                        memcpy(Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), Mac2HostAddr(vcb + vcbVN), 28);
2032 >                        Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), vcb + vcbVN, 28);
2033                  WriteMacInt32(pb + ioWDDirID, ROOT_ID);
2034                  return noErr;
2035          }
# Line 2055 | Line 2047 | static int16 fs_get_wd_info(uint32 pb, u
2047                  return r.d[0];
2048  
2049          // Return information
2050 <        WriteMacInt16(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID));
2050 >        WriteMacInt32(pb + ioWDProcID, ReadMacInt32(wdcb + wdProcID));
2051          WriteMacInt16(pb + ioWDVRefNum, ReadMacInt16(ReadMacInt32(wdcb + wdVCBPtr) + vcbVRefNum));
2052          if (ReadMacInt32(pb + ioNamePtr))
2053 <                memcpy(Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), Mac2HostAddr(ReadMacInt32(wdcb + wdVCBPtr) + vcbVN), 28);
2053 >                Mac2Mac_memcpy(ReadMacInt32(pb + ioNamePtr), ReadMacInt32(wdcb + wdVCBPtr) + vcbVN, 28);
2054          WriteMacInt32(pb + ioWDDirID, ReadMacInt32(wdcb + wdDirID));
2055          return noErr;
2056   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines